Source Code Cross Referenced for PropertyPanel.java in  » Graphic-Library » apollo » org » apollo » view » 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 » Graphic Library » apollo » org.apollo.view 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apollo.view;
002:
003:        import java.awt.Component;
004:        import java.awt.ComponentOrientation;
005:        import java.awt.GridBagConstraints;
006:        import java.awt.GridBagLayout;
007:        import java.awt.Insets;
008:
009:        import javax.swing.JLabel;
010:        import javax.swing.JPanel;
011:        import javax.swing.JSplitPane;
012:
013:        /**
014:         * Component that builds property frames.
015:         * 
016:         * Can be:
017:         * 
018:         * | Label     | Component | Label | Component  |
019:         * | Component | Component         | Label      |
020:         * | Component                                  |
021:         * | Label     | Component                      |
022:         * | Labelable             | Labelable          | 
023:         * 
024:         * TODO: DOCUMENT ME!
025:         *
026:         * @author <a href="mailto:vitor@babaxp.org">Vitor Fernando Pamplona</a>
027:         * 
028:         * @since 30/06/2004
029:         * @version $Id: PropertyPanel.java,v 1.1 2005/04/29 06:04:40 brainbr Exp $
030:         */
031:        public class PropertyPanel extends JPanel {
032:
033:            private static final long serialVersionUID = 1L;
034:
035:            private final GridBagLayout layout = new GridBagLayout();
036:
037:            private final GridBagConstraints cons = new GridBagConstraints();
038:
039:            /**
040:             * Relative Positions
041:             */
042:            public static final int REMAINDER_POSITION = GridBagConstraints.REMAINDER;
043:
044:            public static final int RELATIVE_POSITION = GridBagConstraints.RELATIVE;
045:
046:            /**
047:             * Resizable
048:             */
049:            public static final int NONE_RESIZABLE = 0;
050:
051:            public static final int HEIGHT_RESIZABLE = 1;
052:
053:            public static final int WIDTH_RESIZABLE = 2;
054:
055:            public static final int BOTH_RESIZABLE = 3;
056:
057:            /**
058:             * Values to addComp
059:             */
060:            private static final int RESIZABLE = 1;
061:
062:            private static final int NOTRESIZABLE = 0;
063:
064:            /**
065:             * if is second column
066:             */
067:            private boolean isSecondColumn = false;
068:
069:            /**
070:             * if is second line
071:             */
072:            private boolean isSecondLine = false;
073:
074:            /**
075:             * lines that are previewed in the layout
076:             */
077:            private int linesPreviewed = 0;
078:
079:            /**
080:             * lines already ready
081:             */
082:            private int linesBuilded = 0;
083:
084:            /**
085:             * temporari line height
086:             */
087:            private int tempHeight = 0;
088:
089:            /**
090:             * if there is insets in components
091:             * if True then new Insets(3,3,3,3);
092:             * if False then new Insets(6,6,0,0); 
093:             */
094:            private boolean margin = false;
095:
096:            public PropertyPanel() {
097:                super ();
098:                setLayout(layout);
099:                setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
100:                cons.fill = GridBagConstraints.BOTH;
101:                cons.anchor = GridBagConstraints.NORTHWEST;
102:            }
103:
104:            public PropertyPanel(boolean margemTotal) {
105:                super ();
106:                setLayout(layout);
107:                setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
108:                cons.fill = GridBagConstraints.BOTH;
109:                cons.anchor = GridBagConstraints.NORTHWEST;
110:                this .margin = margemTotal;
111:            }
112:
113:            public PropertyPanel(Component comp1, Component comp2) {
114:                super ();
115:                setLayout(layout);
116:                setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
117:                cons.fill = GridBagConstraints.BOTH;
118:                cons.anchor = GridBagConstraints.NORTHWEST;
119:                this .add(comp1);
120:                this .add(comp2, REMAINDER_POSITION, 1);
121:            }
122:
123:            private void addComp(Component comp, int altura, int largura,
124:                    int redimensionaLargura, int redimensionaAltura) {
125:                cons.weightx = redimensionaLargura;
126:                cons.weighty = redimensionaAltura;
127:                cons.gridheight = altura;
128:                cons.gridwidth = largura;
129:                cons.insets = newInsets();
130:
131:                super .add(comp, cons);
132:
133:                tempHeight = Math.max(altura, tempHeight);
134:
135:                // if this is the second time
136:                if (largura == REMAINDER_POSITION) {
137:                    linesBuilded++;
138:                    linesPreviewed += tempHeight;
139:
140:                    isSecondLine = true;
141:                    isSecondColumn = !(linesBuilded == linesPreviewed);
142:                } else {
143:                    isSecondColumn = true;
144:                }
145:
146:            }
147:
148:            private void addComp(String comp, int altura, int largura,
149:                    int redimensionaLargura, int redimensionaAltura) {
150:                addComp(new JLabel(comp), altura, largura, redimensionaLargura,
151:                        redimensionaAltura);
152:            }
153:
154:            public Component add(Component comp) {
155:                addComp(comp, 1, 1, RESIZABLE, NOTRESIZABLE);
156:                return comp;
157:            }
158:
159:            public Component add(String comp) {
160:                return add(new JLabel(comp));
161:            }
162:
163:            public Component add(Component comp, int redimensionavel) {
164:                return add(comp, 1, 1, redimensionavel);
165:            }
166:
167:            public Component add(String comp, int redimensionavel) {
168:                return add(new JLabel(comp), redimensionavel);
169:            }
170:
171:            public Component add(Component comp, int largura, int altura) {
172:                addComp(comp, altura, largura, RESIZABLE, NOTRESIZABLE);
173:                return comp;
174:            }
175:
176:            public void add(String comp, int largura, int altura) {
177:                addComp(comp, altura, largura, RESIZABLE, NOTRESIZABLE);
178:            }
179:
180:            public Component add(String comp, int largura, int altura,
181:                    int redimensionavel) {
182:                return add(new JLabel(comp), largura, altura, redimensionavel);
183:            }
184:
185:            public Component add(Component comp, int largura, int altura,
186:                    int redimensionavel) {
187:                if (redimensionavel == NONE_RESIZABLE)
188:                    addComp(comp, altura, largura, NOTRESIZABLE, NOTRESIZABLE);
189:                else if (redimensionavel == WIDTH_RESIZABLE)
190:                    addComp(comp, altura, largura, RESIZABLE, NOTRESIZABLE);
191:                else if (redimensionavel == HEIGHT_RESIZABLE)
192:                    addComp(comp, altura, largura, NOTRESIZABLE, RESIZABLE);
193:                else if (redimensionavel == BOTH_RESIZABLE) {
194:                    addComp(comp, altura, largura, RESIZABLE, RESIZABLE);
195:                }
196:                return comp;
197:            }
198:
199:            private Insets newInsets() {
200:                if (margin)
201:                    return new Insets(3, 3, 3, 3);
202:
203:                int top = 0;
204:                int left = 0;
205:
206:                if (isSecondLine)
207:                    top = 6;
208:
209:                if (isSecondColumn)
210:                    left = 6;
211:
212:                return new Insets(top, left, 0, 0);
213:            }
214:
215:            // ------------------------------------------------------------------------
216:            // Add components ending line 
217:            // ------------------------------------------------------------------------
218:
219:            public void addNewLine(Component comp) {
220:                add(comp, REMAINDER_POSITION, 1);
221:            }
222:
223:            public void addNewLine(String comp) {
224:                addNewLine(new JLabel(comp), NONE_RESIZABLE);
225:            }
226:
227:            public void addNewLine(Component comp, int redimensionavel) {
228:                add(comp, REMAINDER_POSITION, 1, redimensionavel);
229:            }
230:
231:            public void addNewLine(String str, Component comp) {
232:                if (this .getComponentOrientation().equals(
233:                        ComponentOrientation.LEFT_TO_RIGHT)) {
234:                    add(str, NONE_RESIZABLE);
235:                    add(comp, REMAINDER_POSITION, 1);
236:                } else {
237:                    add(comp, RELATIVE_POSITION, 1);
238:                    add(str, REMAINDER_POSITION, 1, NONE_RESIZABLE);
239:                }
240:            }
241:
242:            public void addNewLine(String str, Component comp, String str2,
243:                    Component comp2) {
244:                if (this .getComponentOrientation().equals(
245:                        ComponentOrientation.LEFT_TO_RIGHT)) {
246:                    add(str, NONE_RESIZABLE);
247:                    add(comp, 1, 1, WIDTH_RESIZABLE);
248:                    add(str2, NONE_RESIZABLE);
249:                    add(comp2, REMAINDER_POSITION, 1, WIDTH_RESIZABLE);
250:                } else {
251:                    add(comp2, WIDTH_RESIZABLE);
252:                    add(str2, NONE_RESIZABLE);
253:                    add(comp, RELATIVE_POSITION, 1, WIDTH_RESIZABLE);
254:                    add(str, REMAINDER_POSITION, 1, NONE_RESIZABLE);
255:                }
256:            }
257:
258:            public Component addNewLine(String str, Component comp,
259:                    int redimensionavel) {
260:                if (this .getComponentOrientation().equals(
261:                        ComponentOrientation.LEFT_TO_RIGHT)) {
262:                    add(str, NONE_RESIZABLE);
263:                    return add(comp, REMAINDER_POSITION, 1, redimensionavel);
264:                }
265:
266:                Component retorno = add(comp, RELATIVE_POSITION, 1,
267:                        redimensionavel);
268:                add(str, REMAINDER_POSITION, 1, NONE_RESIZABLE);
269:                return retorno;
270:            }
271:
272:            public Component addNewLine(Component comp, String str,
273:                    int redimensionavel) {
274:                Component c = add(comp, RELATIVE_POSITION, 1, redimensionavel);
275:                add(str, REMAINDER_POSITION, 1, NONE_RESIZABLE);
276:                return c;
277:            }
278:
279:            public Component addNewLine(Component comp, String str) {
280:                Component c = add(comp, RELATIVE_POSITION, 1);
281:                add(str, REMAINDER_POSITION, 1, NONE_RESIZABLE);
282:                return c;
283:            }
284:
285:            // ------------------------------------------------------------------------
286:            // Add components with splits.
287:            // ------------------------------------------------------------------------
288:            public void addNewLineSplit(Component comp, Component comp2,
289:                    int redimensionavel) {
290:                JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
291:                        comp, comp2);
292:                addNewLine(split, redimensionavel);
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.