1 7 8 package java.awt; 9 10 23 public class Insets implements Cloneable , java.io.Serializable { 24 25 33 public int top; 34 35 43 public int left; 44 45 53 public int bottom; 54 55 63 public int right; 64 65 68 private static final long serialVersionUID = -2272572637695466749L; 69 70 static { 71 72 Toolkit.loadLibraries(); 73 if (!GraphicsEnvironment.isHeadless()) { 74 initIDs(); 75 } 76 } 77 78 86 public Insets(int top, int left, int bottom, int right) { 87 this.top = top; 88 this.left = left; 89 this.bottom = bottom; 90 this.right = right; 91 } 92 93 102 public void set(int top, int left, int bottom, int right) { 103 this.top = top; 104 this.left = left; 105 this.bottom = bottom; 106 this.right = right; 107 } 108 109 118 public boolean equals(Object obj) { 119 if (obj instanceof Insets ) { 120 Insets insets = (Insets )obj; 121 return ((top == insets.top) && (left == insets.left) && 122 (bottom == insets.bottom) && (right == insets.right)); 123 } 124 return false; 125 } 126 127 132 public int hashCode() { 133 int sum1 = left + bottom; 134 int sum2 = right + top; 135 int val1 = sum1 * (sum1 + 1)/2 + left; 136 int val2 = sum2 * (sum2 + 1)/2 + top; 137 int sum3 = val1 + val2; 138 return sum3 * (sum3 + 1)/2 + val2; 139 } 140 141 150 public String toString() { 151 return getClass().getName() + "[top=" + top + ",left=" + left + ",bottom=" + bottom + ",right=" + right + "]"; 152 } 153 154 158 public Object clone() { 159 try { 160 return super.clone(); 161 } catch (CloneNotSupportedException e) { 162 throw new InternalError (); 164 } 165 } 166 169 private static native void initIDs(); 170 171 } 172 | Popular Tags |