1 14 package org.compiere.print.layout; 15 16 import java.awt.*; 17 import java.awt.geom.*; 18 19 25 public class Dimension2DImpl extends Dimension2D 26 { 27 30 public Dimension2DImpl() 31 { 32 } 34 38 public Dimension2DImpl(Dimension dim) 39 { 40 setSize (dim); 41 } 43 48 public Dimension2DImpl(double width, double height) 49 { 50 setSize (width, height); 51 } 53 54 public double width = 0; 55 56 public double height = 0; 57 58 63 public void setSize (double width, double height) 64 { 65 this.width = width; 66 this.height = height; 67 } 69 73 public void setSize (Dimension dim) 74 { 75 this.width = dim.getWidth(); 76 this.height = dim.getHeight(); 77 } 79 84 public void addBelow (double width, double height) 85 { 86 if (this.width < width) 87 this.width = width; 88 this.height += height; 89 } 91 95 public void addBelow (Dimension dim) 96 { 97 addBelow (dim.width, dim.height); 98 } 100 103 public void roundUp() 104 { 105 width = Math.ceil(width); 106 height = Math.ceil(height); 107 } 109 110 114 public double getWidth() 115 { 116 return width; 117 } 119 123 public double getHeight() 124 { 125 return height; 126 } 128 129 130 134 public int hashCode() 135 { 136 long bits = Double.doubleToLongBits(width); 137 bits ^= Double.doubleToLongBits(height) * 31; 138 return (((int) bits) ^ ((int) (bits >> 32))); 139 } 141 146 public boolean equals (Object obj) 147 { 148 if (obj != null && obj instanceof Dimension2D) 149 { 150 Dimension2D d = (Dimension2D)obj; 151 if (d.getWidth() == width && d.getHeight() == height) 152 return true; 153 } 154 return false; 155 } 157 161 public String toString() 162 { 163 StringBuffer sb = new StringBuffer (); 164 sb.append("Dimension2D[w=").append(width).append(",h=").append(height).append("]"); 165 return sb.toString(); 166 } 168 } | Popular Tags |