18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt;
27
28 /**
29 * An <code>Insets</code> object is a representation of the borders
30 * of a container. It specifies the space that a container must leave
31 * at each of its edges. The space can be a border, a blank space, or
32 * a title.
33 *
34 * @author Arthur van Hoff
35 * @author Sami Shaio
36 * @see java.awt.LayoutManager
37 * @see java.awt.Container
38 * @since JDK1.0
39 */
40 public class Insets implements Cloneable, java.io.Serializable {
41
42 /**
43 * The inset from the top.
44 * This value is added to the Top of the rectangle
45 * to yield a new location for the Top.
46 *
47 * @serial
48 * @see #clone()
49 */
50 public int top;
51
52 /**
53 * The inset from the left.
54 * This value is added to the Left of the rectangle
55 * to yield a new location for the Left edge.
56 *
57 * @serial
58 * @see #clone()
113 * @param top the inset from the top.
114 * @param left the inset from the left.
115 * @param bottom the inset from the bottom.
116 * @param right the inset from the right.
117 * @since 1.5
118 */
119 public void set(int top, int left, int bottom, int right) {
120 this.top = top;
121 this.left = left;
122 this.bottom = bottom;
123 this.right = right;
124 }
125
126 /**
127 * Checks whether two insets objects are equal. Two instances
128 * of <code>Insets</code> are equal if the four integer values
129 * of the fields <code>top</code>, <code>left</code>,
130 * <code>bottom</code>, and <code>right</code> are all equal.
131 * @return <code>true</code> if the two insets are equal;
132 * otherwise <code>false</code>.
133 * @since JDK1.1
134 */
135 public boolean equals(Object obj) {
136 if (obj instanceof Insets) {
137 Insets insets = (Insets)obj;
138 return ((top == insets.top) && (left == insets.left) &&
139 (bottom == insets.bottom) && (right == insets.right));
140 }
141 return false;
142 }
143
144 /**
145 * Returns the hash code for this Insets.
146 *
147 * @return a hash code for this Insets.
148 */
149 public int hashCode() {
150 int sum1 = left + bottom;
151 int sum2 = right + top;
152 int val1 = sum1 * (sum1 + 1)/2 + left;
153 int val2 = sum2 * (sum2 + 1)/2 + top;
|
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 package java.awt;
27
28 /**
29 * An <code>Insets</code> object is a representation of the borders
30 * of a container. It specifies the space that a container must leave
31 * at each of its edges. The space can be a border, a blank space, or
32 * a title.
33 *
34 * @author Arthur van Hoff
35 * @author Sami Shaio
36 * @see java.awt.LayoutManager
37 * @see java.awt.Container
38 * @since 1.0
39 */
40 public class Insets implements Cloneable, java.io.Serializable {
41
42 /**
43 * The inset from the top.
44 * This value is added to the Top of the rectangle
45 * to yield a new location for the Top.
46 *
47 * @serial
48 * @see #clone()
49 */
50 public int top;
51
52 /**
53 * The inset from the left.
54 * This value is added to the Left of the rectangle
55 * to yield a new location for the Left edge.
56 *
57 * @serial
58 * @see #clone()
113 * @param top the inset from the top.
114 * @param left the inset from the left.
115 * @param bottom the inset from the bottom.
116 * @param right the inset from the right.
117 * @since 1.5
118 */
119 public void set(int top, int left, int bottom, int right) {
120 this.top = top;
121 this.left = left;
122 this.bottom = bottom;
123 this.right = right;
124 }
125
126 /**
127 * Checks whether two insets objects are equal. Two instances
128 * of <code>Insets</code> are equal if the four integer values
129 * of the fields <code>top</code>, <code>left</code>,
130 * <code>bottom</code>, and <code>right</code> are all equal.
131 * @return <code>true</code> if the two insets are equal;
132 * otherwise <code>false</code>.
133 * @since 1.1
134 */
135 public boolean equals(Object obj) {
136 if (obj instanceof Insets) {
137 Insets insets = (Insets)obj;
138 return ((top == insets.top) && (left == insets.left) &&
139 (bottom == insets.bottom) && (right == insets.right));
140 }
141 return false;
142 }
143
144 /**
145 * Returns the hash code for this Insets.
146 *
147 * @return a hash code for this Insets.
148 */
149 public int hashCode() {
150 int sum1 = left + bottom;
151 int sum2 = right + top;
152 int val1 = sum1 * (sum1 + 1)/2 + left;
153 int val2 = sum2 * (sum2 + 1)/2 + top;
|