/[classpath]/classpath/java/awt/Insets.java
ViewVC logotype

Diff of /classpath/java/awt/Insets.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by mark, Tue Jan 22 22:26:58 2002 UTC revision 1.6 by ericb, Mon May 6 02:43:17 2002 UTC
# Line 1  Line 1 
1  /* Insets.java -- Information about a container border.  /* Insets.java -- information about a container border
2     Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.     Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
# Line 38  exception statement from your version. * Line 38  exception statement from your version. *
38    
39  package java.awt;  package java.awt;
40    
41  /**  import java.io.Serializable;
   * This class represents the "margin" or space around a container.  
   *  
   * @author Aaron M. Renn (arenn@urbanophile.com)  
   */  
 public class Insets implements Cloneable, java.io.Serializable  
 {  
   
 /*  
  * Instance Variable  
  */  
   
 /**  
   * @serial The top inset  
   */  
 public int top;  
   
 /**  
   * @serial This bottom inset  
   */  
 public int bottom;  
42    
43  /**  /**
44    * @serial The left inset   * This class represents the "margin" or space around a container.
45    */   *
46  public int left;   * @author Aaron M. Renn <arenn@urbanophile.com>
47     * @author Eric Blake <ebb9@email.byu.edu>
48  /**   * @status
   * @serial The right inset  
   */  
 public int right;  
   
 /*************************************************************************/  
   
 /**  
   * Initializes a new instance of <code>Inset</code> with the specified  
   * inset values.  
   *  
   * @param top The top inset  
   * @param left The left inset  
   * @param bottom The bottom inset  
   * @param right The right inset  
   */  
 public  
 Insets(int top, int left, int bottom, int right)  
 {  
   this.top = top;  
   this.left = left;  
   this.bottom = bottom;  
   this.right = right;  
 }  
   
 /*************************************************************************/  
   
 /*  
  * Instance Methods  
49   */   */
50    public class Insets implements Cloneable, Serializable
 /**  
   * Tests whether this object is equal to the specified object.  This will  
   * be true if and only if the specified object:  
   * <p>  
   * <ul>  
   * <li>Is not <code>null</code>.  
   * <li>Is an instance of <code>Insets</code>.  
   * <li>Has the same top, bottom, left, and right inset values as this object.  
   * </ul>  
   *  
   * @param obj The object to test against.  
   *  
   * @return <code>true</code> if the specified object is equal to this  
   * one, <code>false</code> otherwise.  
   */  
 public boolean  
 equals(Object obj)  
 {  
   if (!(obj instanceof Insets))  
     return(false);  
   
   Insets i = (Insets)obj;  
   
   if (i.top != top)  
     return(false);  
   if (i.bottom != bottom)  
     return(false);  
   if (i.left != left)  
     return(false);  
   if (i.right != right)  
     return(false);  
   
   return(true);  
 }  
   
 public int  
 hashCode()  
 {  
   return top + bottom + left + right;  
 }  
   
 /*************************************************************************/  
   
 /**  
   * Returns a string representation of this object.  
   *  
   * @return A string representation of this object.  
   */  
 public String  
 toString()  
 {  
   return(getClass().getName() + "(top=" + top + ",bottom=" + bottom +  
          ",left=" + left + ",right=" + right + ")");  
 }  
   
 /*************************************************************************/  
   
 /**  
   * Returns a copy of this object.  
   *  
   * @return A copy of this object.  
   */  
 public Object  
 clone()  
51  {  {
52    try    /**
53      {     * Compatible with JDK 1.0+.
54        return(super.clone());     */
55      }    private static final long serialVersionUID = -2272572637695466749L;
56    catch(Exception e)  
57      {    /**
58        return(null);     * The gap from the top.
59      }     *
60  }     * @serial the top inset
61       */
62  } // class Insets    public int top;
63    
64      /**
65       * The gap from the left.
66       *
67       * @serial the left inset
68       */
69      public int left;
70    
71      /**
72       * The gap from the bottom.
73       *
74       * @serial the bottom inset
75       */
76      public int bottom;
77    
78      /**
79       * The gap from the right.
80       *
81       * @serial the right inset
82       */
83      public int right;
84    
85      /**
86       * Initializes a new instance of <code>Inset</code> with the specified
87       * inset values.
88       *
89       * @param top the top inset
90       * @param left the left inset
91       * @param bottom the bottom inset
92       * @param right the right inset
93       */
94      public Insets(int top, int left, int bottom, int right)
95      {
96        this.top = top;
97        this.left = left;
98        this.bottom = bottom;
99        this.right = right;
100      }
101    
102      /**
103       * Tests whether this object is equal to the specified object. The other
104       * object must be an instance of Insets with identical field values.
105       *
106       * @param obj the object to test against
107       * @return true if the specified object is equal to this one
108       */
109      public boolean equals(Object obj)
110      {
111        if (! (obj instanceof Insets))
112          return false;
113        Insets i = (Insets) obj;
114        return top == i.top && bottom == i.bottom
115          && left == i.left && right == i.right;
116      }
117    
118      /**
119       * Returns a hashcode for this instance. The formula is unspecified, but
120       * appears to be <code>XXX what is it? </code>.
121       *
122       * @return the hashcode
123       */
124      public int hashCode()
125      {
126        // This can't be right...
127        return top + bottom + left + right;
128      }
129    
130      /**
131       * Returns a string representation of this object, which will be non-null.
132       * The format is unspecified, but appears to be <code>XXX what is it?</code>.
133       *
134       * @return a string representation of this object
135       */
136      public String toString()
137      {
138        return getClass().getName() + "(top=" + top + ",bottom=" + bottom +
139          ",left=" + left + ",right=" + right + ')';
140      }
141    
142      /**
143       * Returns a copy of this object.
144       *
145       * @return a copy of this object
146       */
147      public Object clone()
148      {
149        try
150          {
151            return super.clone();
152          }
153        catch (CloneNotSupportedException e)
154          {
155            throw (Error) new InternalError().initCause(e); // Impossible
156          }
157      }
158    } // class Insets

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26