1 29 30 package nextapp.echo2.app; 31 import java.io.Serializable ; 32 33 40 public class Insets 41 implements Serializable { 42 43 private Extent top; 44 private Extent bottom; 45 private Extent left; 46 private Extent right; 47 48 56 public Insets(int leftPx, int topPx, int rightPx, int bottomPx) { 57 super(); 58 59 this.left = leftPx == 0 ? null : new Extent(leftPx, Extent.PX); 60 this.top = topPx == 0 ? null : new Extent(topPx, Extent.PX); 61 this.right = rightPx == 0 ? null : new Extent(rightPx, Extent.PX); 62 this.bottom = bottomPx == 0 ? null : new Extent(bottomPx, Extent.PX); 63 } 64 65 75 public Insets(Extent left, Extent top, Extent right, Extent bottom) { 76 super(); 77 78 this.left = left; 79 this.top = top; 80 this.right = right; 81 this.bottom = bottom; 82 } 83 84 90 public Insets(int sizePx) { 91 this(new Extent(sizePx, Extent.PX)); 92 } 93 94 102 public Insets(Extent size) { 103 this(size, size, size, size); 104 } 105 106 113 public Insets(int horizontal, int vertical) { 114 this(new Extent(horizontal, Extent.PX), new Extent(vertical, Extent.PX)); 115 } 116 117 124 public Insets(Extent horizontal, Extent vertical) { 125 this(horizontal, vertical, horizontal, vertical); 126 } 127 128 131 public boolean equals(Object o) { 132 if (!(o instanceof Insets)) { 133 return false; 134 } 135 Insets that = (Insets) o; 136 if (this.left != that.left && (this.left == null || !this.left.equals(that.left))) { 137 return false; 138 } 139 if (this.top != that.top && (this.top == null || !this.top.equals(that.top))) { 140 return false; 141 } 142 if (this.right != that.right && (this.right == null || !this.right.equals(that.right))) { 143 return false; 144 } 145 if (this.bottom != that.bottom && (this.bottom == null || !this.bottom.equals(that.bottom))) { 146 return false; 147 } 148 return true; 149 } 150 151 158 public Extent getBottom() { 159 return bottom; 160 } 161 162 169 public Extent getLeft() { 170 return left; 171 } 172 173 180 public Extent getRight() { 181 return right; 182 } 183 184 191 public Extent getTop() { 192 return top; 193 } 194 } 195 | Popular Tags |