Source Code Cross Referenced for Dimension.java in  » Scripting » hecl » org » awt » Java Source Code / Java DocumentationJava Source Code and Java Documentation

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 geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Scripting » hecl » org.awt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005, 2006 data2c GmbH (www.data2c.com)
003:         *
004:         * Author: Wolfgang S. Kechel - wolfgang.kechel@data2c.com
005:         *
006:         * J2ME version of java.awt.Dimension. 
007:         */
008:        //#ifndef j2se
009:        package org.awt;
010:
011:        import org.awt.geom.Dimension2D;
012:
013:        /**
014:         * The <code>Dimension</code> class encapsulates the width and 
015:         * height of a component (in integer precision) in a single object. 
016:         * The class is 
017:         * associated with certain properties of components. Several methods 
018:         * defined by the <code>Component</code> class and the 
019:         * <code>LayoutManager</code> interface return a 
020:         * <code>Dimension</code> object. 
021:         * <p>
022:         * Normally the values of <code>width</code> 
023:         * and <code>height</code> are non-negative integers. 
024:         * The constructors that allow you to create a dimension do 
025:         * not prevent you from setting a negative value for these properties. 
026:         * If the value of <code>width</code> or <code>height</code> is 
027:         * negative, the behavior of some methods defined by other objects is 
028:         * undefined. 
029:         */
030:        public class Dimension extends Dimension2D /*implements java.io.Serializable*/{
031:
032:            /**
033:             * The width dimension; negative values can be used. 
034:             *
035:             * @serial
036:             * @see #getSize
037:             * @see #setSize
038:             */
039:            public int width;
040:
041:            /**
042:             * The height dimension; negative values can be used. 
043:             *
044:             * @serial
045:             * @see #getSize
046:             * @see #setSize
047:             */
048:            public int height;
049:
050:            /** 
051:             * Creates an instance of <code>Dimension</code> with a width 
052:             * of zero and a height of zero. 
053:             */
054:            public Dimension() {
055:                this (0, 0);
056:            }
057:
058:            /** 
059:             * Creates an instance of <code>Dimension</code> whose width  
060:             * and height are the same as for the specified dimension. 
061:             *
062:             * @param    d   the specified dimension for the 
063:             *               <code>width</code> and 
064:             *               <code>height</code> values
065:             */
066:            public Dimension(Dimension d) {
067:                this (d.width, d.height);
068:            }
069:
070:            /** 
071:             * Constructs a <code>Dimension</code> and initializes
072:             * it to the specified width and specified height.
073:             *
074:             * @param width the specified width 
075:             * @param height the specified height
076:             */
077:            public Dimension(int width, int height) {
078:                this .width = width;
079:                this .height = height;
080:            }
081:
082:            /**
083:             * Returns the width of this dimension in double precision.
084:             * @return the width of this dimension in double precision
085:             */
086:            public double getWidth() {
087:                return width;
088:            }
089:
090:            /**
091:             * Returns the height of this dimension in double precision.
092:             * @return the height of this dimension in double precision
093:             */
094:            public double getHeight() {
095:                return height;
096:            }
097:
098:            /**
099:             * Sets the size of this <code>Dimension</code> object to
100:             * the specified width and height in double precision.
101:             * Note that if <code>width</code> or <code>height</code>
102:             * are larger than <code>Integer.MAX_VALUE</code>, they will
103:             * be reset to <code>Integer.MAX_VALUE</code>.
104:             *
105:             * @param width  the new width for the <code>Dimension</code> object
106:             * @param height the new height for the <code>Dimension</code> object
107:             */
108:            public void setSize(double width, double height) {
109:                this .width = (int) Math.ceil(width);
110:                this .height = (int) Math.ceil(height);
111:            }
112:
113:            /**
114:             * Gets the size of this <code>Dimension</code> object.
115:             * This method is included for completeness, to parallel the
116:             * <code>getSize</code> method defined by <code>Component</code>.
117:             *
118:             * @return   the size of this dimension, a new instance of 
119:             *           <code>Dimension</code> with the same width and height
120:             * @see      java.awt.Dimension#setSize
121:             * @see      java.awt.Component#getSize
122:             */
123:            public Dimension getSize() {
124:                return new Dimension(width, height);
125:            }
126:
127:            /**
128:             * Sets the size of this <code>Dimension</code> object to the specified size.
129:             * This method is included for completeness, to parallel the
130:             * <code>setSize</code> method defined by <code>Component</code>.
131:             * @param    d  the new size for this <code>Dimension</code> object
132:             * @see      java.awt.Dimension#getSize
133:             * @see      java.awt.Component#setSize
134:             */
135:            public void setSize(Dimension d) {
136:                setSize(d.width, d.height);
137:            }
138:
139:            /**
140:             * Sets the size of this <code>Dimension</code> object 
141:             * to the specified width and height.
142:             * This method is included for completeness, to parallel the
143:             * <code>setSize</code> method defined by <code>Component</code>.
144:             *
145:             * @param    width   the new width for this <code>Dimension</code> object
146:             * @param    height  the new height for this <code>Dimension</code> object
147:             * @see      java.awt.Dimension#getSize
148:             * @see      java.awt.Component#setSize
149:             */
150:            public void setSize(int width, int height) {
151:                this .width = width;
152:                this .height = height;
153:            }
154:
155:            /**
156:             * Checks whether two dimension objects have equal values.
157:             */
158:            public boolean equals(Object obj) {
159:                if (obj instanceof  Dimension) {
160:                    Dimension d = (Dimension) obj;
161:                    return (width == d.width) && (height == d.height);
162:                }
163:                return false;
164:            }
165:
166:            /**
167:             * Returns the hash code for this <code>Dimension</code>.
168:             *
169:             * @return    a hash code for this <code>Dimension</code>
170:             */
171:            public int hashCode() {
172:                int sum = width + height;
173:                return sum * (sum + 1) / 2 + width;
174:            }
175:
176:            /**
177:             * Returns a string representation of the values of this 
178:             * <code>Dimension</code> object's <code>height</code> and 
179:             * <code>width</code> fields. This method is intended to be used only 
180:             * for debugging purposes, and the content and format of the returned 
181:             * string may vary between implementations. The returned string may be 
182:             * empty but may not be <code>null</code>.
183:             * 
184:             * @return  a string representation of this <code>Dimension</code> 
185:             *          object
186:             */
187:            public String toString() {
188:                return "Dimension[w=" + width + ", h=" + height + "]";
189:            }
190:        }
191:        //#endif
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.