Dimension.js 1.8 KB

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