You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Dimension2DDouble.java 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.util;
  16. import java.awt.geom.Dimension2D;
  17. /**
  18. * @since 4.1.0
  19. */
  20. public class Dimension2DDouble extends Dimension2D {
  21. double width;
  22. double height;
  23. public Dimension2DDouble() {
  24. width = 0d;
  25. height = 0d;
  26. }
  27. public Dimension2DDouble(double width, double height) {
  28. this.width = width;
  29. this.height = height;
  30. }
  31. @Override
  32. public double getWidth() {
  33. return width;
  34. }
  35. @Override
  36. public double getHeight() {
  37. return height;
  38. }
  39. @Override
  40. public void setSize(double width, double height) {
  41. this.width = width;
  42. this.height = height;
  43. }
  44. @Override
  45. public boolean equals(Object obj) {
  46. if (obj instanceof Dimension2DDouble) {
  47. Dimension2DDouble other = (Dimension2DDouble) obj;
  48. return width == other.width && height == other.height;
  49. }
  50. return false;
  51. }
  52. @Override
  53. public int hashCode() {
  54. double sum = width + height;
  55. return (int) Math.ceil(sum * (sum + 1) / 2 + width);
  56. }
  57. @Override
  58. public String toString() {
  59. return "Dimension2DDouble[" + width + ", " + height + "]";
  60. }
  61. }