Source Code Cross Referenced for Insets.java in  » 6.0-JDK-Core » AWT » java » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » AWT » java.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1995-2003 Sun Microsystems, Inc.  All Rights Reserved.
003         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004         *
005         * This code is free software; you can redistribute it and/or modify it
006         * under the terms of the GNU General Public License version 2 only, as
007         * published by the Free Software Foundation.  Sun designates this
008         * particular file as subject to the "Classpath" exception as provided
009         * by Sun in the LICENSE file that accompanied this code.
010         *
011         * This code is distributed in the hope that it will be useful, but WITHOUT
012         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014         * version 2 for more details (a copy is included in the LICENSE file that
015         * accompanied this code).
016         *
017         * You should have received a copy of the GNU General Public License version
018         * 2 along with this work; if not, write to the Free Software Foundation,
019         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020         *
021         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022         * CA 95054 USA or visit www.sun.com if you need additional information or
023         * have any questions.
024         */
025
026        package java.awt;
027
028        /**
029         * An <code>Insets</code> object is a representation of the borders 
030         * of a container. It specifies the space that a container must leave 
031         * at each of its edges. The space can be a border, a blank space, or 
032         * a title. 
033         *
034         * @version 	1.37, 05/05/07
035         * @author 	Arthur van Hoff
036         * @author 	Sami Shaio
037         * @see         java.awt.LayoutManager
038         * @see         java.awt.Container
039         * @since       JDK1.0
040         */
041        public class Insets implements  Cloneable, java.io.Serializable {
042
043            /**
044             * The inset from the top.
045             * This value is added to the Top of the rectangle
046             * to yield a new location for the Top.
047             *
048             * @serial
049             * @see #clone()
050             */
051            public int top;
052
053            /**
054             * The inset from the left.
055             * This value is added to the Left of the rectangle
056             * to yield a new location for the Left edge.
057             *
058             * @serial
059             * @see #clone()
060             */
061            public int left;
062
063            /**
064             * The inset from the bottom.
065             * This value is subtracted from the Bottom of the rectangle
066             * to yield a new location for the Bottom.
067             *
068             * @serial
069             * @see #clone()
070             */
071            public int bottom;
072
073            /**
074             * The inset from the right.
075             * This value is subtracted from the Right of the rectangle
076             * to yield a new location for the Right edge.
077             *
078             * @serial
079             * @see #clone()
080             */
081            public int right;
082
083            /*
084             * JDK 1.1 serialVersionUID 
085             */
086            private static final long serialVersionUID = -2272572637695466749L;
087
088            static {
089                /* ensure that the necessary native libraries are loaded */
090                Toolkit.loadLibraries();
091                if (!GraphicsEnvironment.isHeadless()) {
092                    initIDs();
093                }
094            }
095
096            /**
097             * Creates and initializes a new <code>Insets</code> object with the 
098             * specified top, left, bottom, and right insets. 
099             * @param       top   the inset from the top.
100             * @param       left   the inset from the left.
101             * @param       bottom   the inset from the bottom.
102             * @param       right   the inset from the right.
103             */
104            public Insets(int top, int left, int bottom, int right) {
105                this .top = top;
106                this .left = left;
107                this .bottom = bottom;
108                this .right = right;
109            }
110
111            /**
112             * Set top, left, bottom, and right to the specified values
113             *
114             * @param       top   the inset from the top.
115             * @param       left   the inset from the left.
116             * @param       bottom   the inset from the bottom.
117             * @param       right   the inset from the right.
118             * @since 1.5
119             */
120            public void set(int top, int left, int bottom, int right) {
121                this .top = top;
122                this .left = left;
123                this .bottom = bottom;
124                this .right = right;
125            }
126
127            /**
128             * Checks whether two insets objects are equal. Two instances 
129             * of <code>Insets</code> are equal if the four integer values
130             * of the fields <code>top</code>, <code>left</code>, 
131             * <code>bottom</code>, and <code>right</code> are all equal.
132             * @return      <code>true</code> if the two insets are equal;
133             *                          otherwise <code>false</code>.
134             * @since       JDK1.1
135             */
136            public boolean equals(Object obj) {
137                if (obj instanceof  Insets) {
138                    Insets insets = (Insets) obj;
139                    return ((top == insets.top) && (left == insets.left)
140                            && (bottom == insets.bottom) && (right == insets.right));
141                }
142                return false;
143            }
144
145            /**
146             * Returns the hash code for this Insets.
147             *
148             * @return    a hash code for this Insets.
149             */
150            public int hashCode() {
151                int sum1 = left + bottom;
152                int sum2 = right + top;
153                int val1 = sum1 * (sum1 + 1) / 2 + left;
154                int val2 = sum2 * (sum2 + 1) / 2 + top;
155                int sum3 = val1 + val2;
156                return sum3 * (sum3 + 1) / 2 + val2;
157            }
158
159            /**
160             * Returns a string representation of this <code>Insets</code> object. 
161             * This method is intended to be used only for debugging purposes, and 
162             * the content and format of the returned string may vary between 
163             * implementations. The returned string may be empty but may not be 
164             * <code>null</code>.
165             * 
166             * @return  a string representation of this <code>Insets</code> object.
167             */
168            public String toString() {
169                return getClass().getName() + "[top=" + top + ",left=" + left
170                        + ",bottom=" + bottom + ",right=" + right + "]";
171            }
172
173            /**
174             * Create a copy of this object.
175             * @return     a copy of this <code>Insets</code> object.
176             */
177            public Object clone() {
178                try {
179                    return super .clone();
180                } catch (CloneNotSupportedException e) {
181                    // this shouldn't happen, since we are Cloneable
182                    throw new InternalError();
183                }
184            }
185
186            /**
187             * Initialize JNI field and method IDs
188             */
189            private static native void initIDs();
190
191        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.