Source Code Cross Referenced for LayoutStyle.java in  » Swing-Library » abeille-forms-designer » com » jgoodies » forms » util » 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 » Swing Library » abeille forms designer » com.jgoodies.forms.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2002-2004 JGoodies Karsten Lentzsch. All Rights Reserved.
003:         *
004:         * Redistribution and use in source and binary forms, with or without 
005:         * modification, are permitted provided that the following conditions are met:
006:         * 
007:         *  o Redistributions of source code must retain the above copyright notice, 
008:         *    this list of conditions and the following disclaimer. 
009:         *     
010:         *  o Redistributions in binary form must reproduce the above copyright notice, 
011:         *    this list of conditions and the following disclaimer in the documentation 
012:         *    and/or other materials provided with the distribution. 
013:         *     
014:         *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015:         *    its contributors may be used to endorse or promote products derived 
016:         *    from this software without specific prior written permission. 
017:         *     
018:         * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019:         * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020:         * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021:         * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022:         * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023:         * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024:         * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025:         * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026:         * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027:         * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028:         * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029:         */
030:
031:        package com.jgoodies.forms.util;
032:
033:        import java.util.logging.Logger;
034:
035:        import com.jgoodies.forms.layout.ConstantSize;
036:        import com.jgoodies.forms.layout.Size;
037:
038:        /**
039:         * An abstract class that describes a layout and design style guide. It provides
040:         * constants used to lay out panels consistently.
041:         * <p>
042:         * 
043:         * This class is work in progress and the API may change without notice.
044:         * Therefore it is recommended to not write custom subclasses for production
045:         * code. A future version of this class will likely collaborate with a class
046:         * <code>LogicalSize</code> or <code>StyledSize</code>.
047:         * 
048:         * @author Karsten Lentzsch
049:         * @version $Revision: 1.2 $
050:         * 
051:         * @see com.jgoodies.forms.util.MacLayoutStyle
052:         * @see com.jgoodies.forms.util.WindowsLayoutStyle
053:         * @see com.jgoodies.forms.factories.FormFactory
054:         * @see com.jgoodies.forms.factories.Borders
055:         */
056:
057:        public abstract class LayoutStyle {
058:
059:            /**
060:             * Holds the current layout style.
061:             */
062:            private static LayoutStyle current = initialLayoutStyle();
063:
064:            // Computing the initial layout style *************************************
065:
066:            /**
067:             * Computes and returns the initial <code>LayoutStyle</code>. Checks the
068:             * OS name and returns <code>MacLayoutStyle</code> on Mac OS X and
069:             * <code>WindowLayoutStyle</code> on all other platforms.
070:             * 
071:             * @return MacLayoutStyle on Mac, WindowsLayoutStyle on all other platforms
072:             */
073:            private static LayoutStyle initialLayoutStyle() {
074:                if (isOSMac())
075:                    return MacLayoutStyle.INSTANCE;
076:                else
077:                    return WindowsLayoutStyle.INSTANCE;
078:            }
079:
080:            /**
081:             * Checks and answers whether Java runs on a Mac by requesting the system
082:             * property <em>os.name</em>.
083:             * 
084:             * @return true on Mac, false on all other Platforms
085:             */
086:            private static boolean isOSMac() {
087:                return getSystemProperty("os.name").startsWith("Mac");
088:            }
089:
090:            /**
091:             * Tries to look up the System property for the given key. In untrusted
092:             * environments this may throw a SecurityException. In this case we catch
093:             * the exception and answer <code>null</code>.
094:             * 
095:             * @param key
096:             *            the name of the system property
097:             * @return the system property's String value, or a blank string if there's
098:             *         no such value, or a SecurityException has been catched
099:             */
100:            private static String getSystemProperty(String key) {
101:                try {
102:                    return System.getProperty(key);
103:                } catch (SecurityException e) {
104:                    Logger.getLogger(LayoutStyle.class.getName()).warning(
105:                            "Can't read the System property " + key + ".");
106:                    return "";
107:                }
108:            }
109:
110:            // Accessing the current style ******************************************
111:
112:            /**
113:             * Returns the current <code>LayoutStyle</code>.
114:             * 
115:             * @return the current <code>LayoutStyle</code>
116:             */
117:            public static LayoutStyle getCurrent() {
118:                return current;
119:            }
120:
121:            /**
122:             * Set a new <code>LayoutStyle</code>
123:             * 
124:             * @param newLayoutStyle
125:             *            the style to be set
126:             */
127:            public static void setCurrent(LayoutStyle newLayoutStyle) {
128:                current = newLayoutStyle;
129:            }
130:
131:            // Layout Sizes *********************************************************
132:
133:            /**
134:             * Returns this style's default button width.
135:             * 
136:             * @return the default button width
137:             * 
138:             * @see #getDefaultButtonHeight()
139:             */
140:            abstract public Size getDefaultButtonWidth();
141:
142:            /**
143:             * Returns this style's default button height.
144:             * 
145:             * @return the default button height
146:             * 
147:             * @see #getDefaultButtonWidth()
148:             */
149:            abstract public Size getDefaultButtonHeight();
150:
151:            /**
152:             * Returns this style's horizontal margin for general dialogs.
153:             * 
154:             * @return the horizontal margin for general dialogs
155:             * 
156:             * @see #getDialogMarginY()
157:             * @see #getTabbedDialogMarginX()
158:             */
159:            abstract public ConstantSize getDialogMarginX();
160:
161:            /**
162:             * Returns this style's vertical margin for general dialogs.
163:             * 
164:             * @return the vertical margin for general dialogs
165:             * 
166:             * @see #getDialogMarginX()
167:             * @see #getTabbedDialogMarginY()
168:             */
169:            abstract public ConstantSize getDialogMarginY();
170:
171:            /**
172:             * Returns this style's horizontal margin for dialogs that consist of a
173:             * tabbed pane.
174:             * 
175:             * @return the horizontal margin for dialogs that consist of a tabbed pane
176:             * @since 1.0.3
177:             * 
178:             * @see #getTabbedDialogMarginY()
179:             * @see #getDialogMarginX()
180:             */
181:            abstract public ConstantSize getTabbedDialogMarginX();
182:
183:            /**
184:             * Returns this style's vertical margin for dialogs that consist of a tabbed
185:             * pane.
186:             * 
187:             * @return the vertical margin for dialogs that consist of a tabbed pane
188:             * @since 1.0.3
189:             * 
190:             * @see #getTabbedDialogMarginX()
191:             * @see #getDialogMarginY()
192:             */
193:            abstract public ConstantSize getTabbedDialogMarginY();
194:
195:            /**
196:             * Returns a gap used to separate a label and associated control.
197:             * 
198:             * @return a gap between label and associated control
199:             * 
200:             * @see #getRelatedComponentsPadX()
201:             * @see #getUnrelatedComponentsPadX()
202:             */
203:            abstract public ConstantSize getLabelComponentPadX();
204:
205:            /**
206:             * Returns a horizontal gap used to separate related controls.
207:             * 
208:             * @return a horizontal gap between related controls
209:             * 
210:             * @see #getLabelComponentPadX()
211:             * @see #getRelatedComponentsPadY()
212:             * @see #getUnrelatedComponentsPadX()
213:             */
214:            abstract public ConstantSize getRelatedComponentsPadX();
215:
216:            /**
217:             * Returns a vertical gap used to separate related controls.
218:             * 
219:             * @return a vertical gap between related controls
220:             * 
221:             * @see #getRelatedComponentsPadX()
222:             * @see #getUnrelatedComponentsPadY()
223:             */
224:            abstract public ConstantSize getRelatedComponentsPadY();
225:
226:            /**
227:             * Returns a horizontal gap used to separate unrelated controls.
228:             * 
229:             * @return a horizontal gap between unrelated controls
230:             * 
231:             * @see #getLabelComponentPadX()
232:             * @see #getUnrelatedComponentsPadY()
233:             * @see #getRelatedComponentsPadX()
234:             */
235:            abstract public ConstantSize getUnrelatedComponentsPadX();
236:
237:            /**
238:             * Returns a vertical gap used to separate unrelated controls.
239:             * 
240:             * @return a vertical gap between unrelated controls
241:             * 
242:             * @see #getUnrelatedComponentsPadX()
243:             * @see #getRelatedComponentsPadY()
244:             */
245:            abstract public ConstantSize getUnrelatedComponentsPadY();
246:
247:            /**
248:             * Returns a narrow vertical pad used to separate lines.
249:             * 
250:             * @return a narrow vertical pad used to separate lines
251:             * 
252:             * @see #getLinePad()
253:             * @see #getParagraphPad()
254:             */
255:            abstract public ConstantSize getNarrowLinePad();
256:
257:            /**
258:             * Returns a narrow vertical pad used to separate lines.
259:             * 
260:             * @return a vertical pad used to separate lines
261:             * 
262:             * @see #getNarrowLinePad()
263:             * @see #getParagraphPad()
264:             */
265:            abstract public ConstantSize getLinePad();
266:
267:            /**
268:             * Returns a pad used to separate paragraphs.
269:             * 
270:             * @return a vertical pad used to separate paragraphs
271:             * 
272:             * @see #getNarrowLinePad()
273:             * @see #getLinePad()
274:             */
275:            abstract public ConstantSize getParagraphPad();
276:
277:            /**
278:             * Returns a pad used to separate a button bar from a component.
279:             * 
280:             * @return a vertical pad used to separate paragraphs
281:             * @since 1.0.3
282:             * 
283:             * @see #getRelatedComponentsPadY()
284:             * @see #getUnrelatedComponentsPadY()
285:             */
286:            abstract public ConstantSize getButtonBarPad();
287:
288:            /**
289:             * Checks and answers whether buttons are typically ordered from left to
290:             * right or from right to left. Useful for building button bars that shall
291:             * comply with the platform's layout style guide.
292:             * <p>
293:             * 
294:             * For example the Windows style guide recommends to layout out
295:             * <em>OK, Cancel, Apply</em> from left to right, where the Mac Aqua style
296:             * guide recommends to layout out these buttons from right to left.
297:             * <p>
298:             * 
299:             * Although most button sequences shall honor this order some buttons
300:             * require a left to right order. For example <em>Back, Next</em> or
301:             * <em>Move Left, Move Right</em>.
302:             * <p>
303:             * 
304:             * @return true if buttons are typically ordered from left to right
305:             * @since 1.0.3
306:             * 
307:             * @see com.jgoodies.forms.builder.ButtonBarBuilder
308:             * @see com.jgoodies.forms.factories.ButtonBarFactory
309:             */
310:            abstract public boolean isLeftToRightButtonOrder();
311:
312:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.