001: /*
002: * @(#)Insets.java 1.22 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package java.awt;
029:
030: /**
031: * An <code>Insets</code> object is a representation of the borders
032: * of a container. It specifies the space that a container must leave
033: * at each of its edges. The space can be a border, a blank space, or
034: * a title.
035: *
036: * @version 1.18, 08/19/02
037: * @author Arthur van Hoff
038: * @author Sami Shaio
039: * @see java.awt.LayoutManager
040: * @see java.awt.Container
041: * @since JDK1.0
042: */
043: public class Insets implements Cloneable, java.io.Serializable {
044: /**
045: * The inset from the top.
046: * @since JDK1.0
047: */
048: public int top;
049: /**
050: * The inset from the left.
051: * @since JDK1.0
052: */
053: public int left;
054: /**
055: * The inset from the bottom.
056: * @since JDK1.0
057: */
058: public int bottom;
059: /**
060: * The inset from the right.
061: * @since JDK1.0
062: */
063: public int right;
064: /*
065: * JDK 1.1 serialVersionUID
066: */
067: private static final long serialVersionUID = -2272572637695466749L;
068:
069: /**
070: * Creates and initializes a new <code>Insets</code> object with the
071: * specified top, left, bottom, and right insets.
072: * @param top the inset from the top.
073: * @param left the inset from the left.
074: * @param bottom the inset from the bottom.
075: * @param right the inset from the right.
076: * @since JDK1.0
077: */
078: public Insets(int top, int left, int bottom, int right) {
079: this .top = top;
080: this .left = left;
081: this .bottom = bottom;
082: this .right = right;
083: }
084:
085: /**
086: * Checks whether two insets objects are equal. Two instances
087: * of <code>Insets</code> are equal if the four integer values
088: * of the fields <code>top</code>, <code>left</code>,
089: * <code>bottom</code>, and <code>right</code> are all equal.
090: * @return <code>true</code> if the two insets are equal;
091: * otherwise <code>false</code>.
092: * @since JDK1.1
093: */
094: public boolean equals(Object obj) {
095: if (obj instanceof Insets) {
096: Insets insets = (Insets) obj;
097: return ((top == insets.top) && (left == insets.left)
098: && (bottom == insets.bottom) && (right == insets.right));
099: }
100: return false;
101: }
102:
103: /**
104: * Returns a <code>String</code> object representing this
105: * <code>Insets</code> object's values.
106: * @return a string representation of this <code>Insets</code> object,
107: * including the values of its member fields.
108: * @since JDK1.0
109: */
110: public String toString() {
111: return getClass().getName() + "[top=" + top + ",left=" + left
112: + ",bottom=" + bottom + ",right=" + right + "]";
113: }
114:
115: /**
116: * Create a copy of this object.
117: * @return a copy of this <code>Insets</code> object.
118: * @since JDK1.0
119: */
120: public Object clone() {
121: try {
122: return super .clone();
123: } catch (CloneNotSupportedException e) {
124: // this shouldn't happen, since we are Cloneable
125: throw new InternalError();
126: }
127: }
128: }
|