Dimension.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2009 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. import IllegalArgumentException from './IllegalArgumentException';
  17. /*namespace com.google.zxing {*/
  18. /**
  19. * Simply encapsulates a width and height.
  20. */
  21. var Dimension = /** @class */ (function () {
  22. function Dimension(width /*int*/, height /*int*/) {
  23. this.width = width;
  24. this.height = height;
  25. if (width < 0 || height < 0) {
  26. throw new IllegalArgumentException();
  27. }
  28. }
  29. Dimension.prototype.getWidth = function () {
  30. return this.width;
  31. };
  32. Dimension.prototype.getHeight = function () {
  33. return this.height;
  34. };
  35. /*@Override*/
  36. Dimension.prototype.equals = function (other) {
  37. if (other instanceof Dimension) {
  38. var d = other;
  39. return this.width === d.width && this.height === d.height;
  40. }
  41. return false;
  42. };
  43. /*@Override*/
  44. Dimension.prototype.hashCode = function () {
  45. return this.width * 32713 + this.height;
  46. };
  47. /*@Override*/
  48. Dimension.prototype.toString = function () {
  49. return this.width + 'x' + this.height;
  50. };
  51. return Dimension;
  52. }());
  53. export default Dimension;