Source Code Cross Referenced for AbsoluteLayout.java in  » Database-DBMS » Ozone-1.1 » org » ozoneDB » core » monitor » 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 » Database DBMS » Ozone 1.1 » org.ozoneDB.core.monitor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$Id: AbsoluteLayout.java,v 1.2 2002/07/29 11:30:23 per_nyfelt Exp $
002:        //from the NetBeans redist directory
003:
004:        package org.ozoneDB.core.monitor;
005:
006:        import java.awt.*;
007:
008:        /**
009:         * AbsoluteLayout is a LayoutManager that works as a replacement
010:         * for "null" layout to allow placement of components in absolute
011:         * positions.
012:         * 
013:         * 
014:         * @version 1.01, Aug 19, 1998 ($Revision: 1.2 $)
015:         * @author  Ian Formanek (modified softwarebuero m&b
016:         */
017:        public class AbsoluteLayout implements  LayoutManager2,
018:                java.io.Serializable {
019:
020:            /** A mapping <Component, AbsoluteConstraints> */
021:            protected java.util.Hashtable constraints = new java.util.Hashtable();
022:
023:            /** urspruengliche groesse des umgebenden containers*/
024:            public Dimension bounds;
025:
026:            /** generated Serialized Version UID */
027:            final static long serialVersionUID = -1919857869177070440L;
028:
029:            /**
030:             * Adds the specified component with the specified name to
031:             * the layout.
032:             * @param name the component name
033:             * @param comp the component to be added
034:             */
035:            public void addLayoutComponent(String name, Component comp) {
036:                throw new IllegalArgumentException();
037:            }
038:
039:            /**
040:             * Removes the specified component from the layout.
041:             * @param comp the component to be removed
042:             */
043:            public void removeLayoutComponent(Component comp) {
044:                constraints.remove(comp);
045:            }
046:
047:            /**
048:             * Calculates the preferred dimension for the specified
049:             * panel given the components in the specified parent container.
050:             * @param parent the component to be laid out
051:             *
052:             * @see #minimumLayoutSize
053:             */
054:            public Dimension preferredLayoutSize(Container parent) {
055:                int maxWidth = 0;
056:                int maxHeight = 0;
057:                for (java.util.Enumeration e = constraints.keys(); e
058:                        .hasMoreElements();) {
059:                    Component comp = (Component) e.nextElement();
060:                    AbsoluteConstraints ac = (AbsoluteConstraints) constraints
061:                            .get(comp);
062:                    Dimension size = comp.getPreferredSize();
063:
064:                    int width = ac.getWidth() == -1 ? size.width : ac
065:                            .getWidth();
066:                    int height = ac.getHeight() == -1 ? size.height : ac
067:                            .getHeight();
068:
069:                    if (ac.x + width > maxWidth) {
070:                        maxWidth = ac.x + width;
071:                    }
072:                    if (ac.y + height > maxHeight) {
073:                        maxHeight = ac.y + height;
074:                    }
075:                }
076:                return new Dimension(maxWidth, maxHeight);
077:            }
078:
079:            /**
080:             * Calculates the minimum dimension for the specified
081:             * panel given the components in the specified parent container.
082:             * @param parent the component to be laid out
083:             * @see #preferredLayoutSize
084:             */
085:            public Dimension minimumLayoutSize(Container parent) {
086:                int maxWidth = 0;
087:                int maxHeight = 0;
088:                for (java.util.Enumeration e = constraints.keys(); e
089:                        .hasMoreElements();) {
090:                    Component comp = (Component) e.nextElement();
091:                    AbsoluteConstraints ac = (AbsoluteConstraints) constraints
092:                            .get(comp);
093:
094:                    Dimension size = comp.getMinimumSize();
095:
096:                    int width = ac.getWidth() == -1 ? size.width : ac
097:                            .getWidth();
098:                    int height = ac.getHeight() == -1 ? size.height : ac
099:                            .getHeight();
100:
101:                    if (ac.x + width > maxWidth) {
102:                        maxWidth = ac.x + width;
103:                    }
104:                    if (ac.y + height > maxHeight) {
105:                        maxHeight = ac.y + height;
106:                    }
107:                }
108:                return new Dimension(maxWidth, maxHeight);
109:            }
110:
111:            /**
112:             * Sets the original size of the parent container. Needs not
113:             * to be called in any case.
114:             */
115:            public void realizeSize(Dimension bounds) {
116:                bounds = new Dimension(bounds);
117:            }
118:
119:            /**
120:             * Lays out the container in the specified panel.
121:             * @param parent the component which needs to be laid out
122:             */
123:            public void layoutContainer(Container parent) {
124:                Dimension parentSize = parent.getSize();
125:                if (bounds == null) {
126:                    bounds = new Dimension(parentSize);
127:                }
128:
129:                for (java.util.Enumeration e = constraints.keys(); e
130:                        .hasMoreElements();) {
131:                    Component comp = (Component) e.nextElement();
132:                    AbsoluteConstraints ac = (AbsoluteConstraints) constraints
133:                            .get(comp);
134:                    Dimension size = comp.getPreferredSize();
135:
136:                    int x = ac.x;
137:                    int y = ac.y;
138:                    int width = ac.getWidth() == -1 ? size.width : ac
139:                            .getWidth();
140:                    int height = ac.getHeight() == -1 ? size.height : ac
141:                            .getHeight();
142:
143:                    if ((ac.policy & AbsoluteConstraints.X_PROP) != 0) {
144:                        x = (int) ((double) ac.x / (double) bounds.width * (double) parentSize.width);
145:                    }
146:                    if ((ac.policy & AbsoluteConstraints.Y_PROP) != 0) {
147:                        y = (int) ((double) ac.y / (double) bounds.height * (double) parentSize.height);
148:                    }
149:                    if ((ac.policy & AbsoluteConstraints.X_ABS) != 0) {
150:                        x = (parentSize.width - (bounds.width - ac.x));
151:                    }
152:                    if ((ac.policy & AbsoluteConstraints.Y_ABS) != 0) {
153:                        y = (parentSize.height - (bounds.height - ac.y));
154:                    }
155:
156:                    if ((ac.policy & AbsoluteConstraints.X2_PROP) != 0) {
157:                        width = ((int) ((double) (ac.x + width)
158:                                / (double) bounds.width * (double) parentSize.width) - x);
159:                    }
160:                    if ((ac.policy & AbsoluteConstraints.Y2_PROP) != 0) {
161:                        height = ((int) ((double) (ac.y + height)
162:                                / (double) bounds.height * (double) parentSize.height) - y);
163:                    }
164:                    if ((ac.policy & AbsoluteConstraints.X2_ABS) != 0) {
165:                        int x2 = bounds.width - ac.x + width;
166:                        width = (parentSize.width - x - x2);
167:                    }
168:                    if ((ac.policy & AbsoluteConstraints.Y2_ABS) != 0) {
169:                        int y2 = bounds.height - ac.y + height;
170:                        height = (parentSize.height - y - y2);
171:                    }
172:
173:                    comp.setBounds(x, y, width, height);
174:                }
175:            }
176:
177:            /**
178:             * Adds the specified component to the layout, using the specified
179:             * constraint object.
180:             * @param comp the component to be added
181:             * @param constr  where/how the component is added to the layout.
182:             */
183:            public void addLayoutComponent(Component comp, Object constr) {
184:                if (!(constr instanceof  AbsoluteConstraints)) {
185:                    throw new IllegalArgumentException();
186:                }
187:                constraints.put(comp, constr);
188:            }
189:
190:            /**
191:             * Returns the maximum size of this component.
192:             * @see java.awt.Component#getMinimumSize()
193:             * @see java.awt.Component#getPreferredSize()
194:             * @see LayoutManager
195:             */
196:            public Dimension maximumLayoutSize(Container target) {
197:                return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
198:            }
199:
200:            /**
201:             * Returns the alignment along the x axis.  This specifies how
202:             * the component would like to be aligned relative to other
203:             * components.  The value should be a number between 0 and 1
204:             * where 0 represents alignment along the origin, 1 is aligned
205:             * the furthest away from the origin, 0.5 is centered, etc.
206:             */
207:            public float getLayoutAlignmentX(Container target) {
208:                return 0;
209:            }
210:
211:            /**
212:             * Returns the alignment along the y axis.  This specifies how
213:             * the component would like to be aligned relative to other
214:             * components.  The value should be a number between 0 and 1
215:             * where 0 represents alignment along the origin, 1 is aligned
216:             * the furthest away from the origin, 0.5 is centered, etc.
217:             */
218:            public float getLayoutAlignmentY(Container target) {
219:                return 0;
220:            }
221:
222:            /**
223:             * Invalidates the layout, indicating that if the layout manager
224:             * has cached information it should be discarded.
225:             */
226:            public void invalidateLayout(Container target) {
227:            }
228:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.