Source Code Cross Referenced for STitledBorder.java in  » Swing-Library » wings3 » org » wings » border » 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 » wings3 » org.wings.border 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2000,2005 wingS development team.
003:         *
004:         * This file is part of wingS (http://wingsframework.org).
005:         *
006:         * wingS is free software; you can redistribute it and/or modify
007:         * it under the terms of the GNU Lesser General Public License
008:         * as published by the Free Software Foundation; either version 2.1
009:         * of the License, or (at your option) any later version.
010:         *
011:         * Please see COPYING for the complete licence.
012:         */
013:        package org.wings.border;
014:
015:        import java.awt.Insets;
016:        import org.wings.*;
017:        import java.awt.Color;
018:        import java.util.Map;
019:        import org.wings.SConstants;
020:        import org.wings.style.CSSAttributeSet;
021:        import org.wings.style.Selector;
022:        import org.wings.plaf.css.TitleBorderCG;
023:
024:        /**
025:         * Adds a border with a title to a component.
026:         *
027:         */
028:        public class STitledBorder extends SAbstractBorder {
029:
030:            /**
031:             * Use the default vertical orientation for the title text.
032:             */
033:            static public final int DEFAULT_POSITION = 0;
034:            /** Position the title above the border's top line. */
035:            static public final int ABOVE_TOP = 1;
036:            /** Position the title in the middle of the border's top line. */
037:            static public final int TOP = 2;
038:            /** Position the title below the border's top line. */
039:            static public final int BELOW_TOP = 3;
040:            /** Position the title above the border's bottom line. */
041:            static public final int ABOVE_BOTTOM = 4;
042:            /** Position the title in the middle of the border's bottom line. */
043:            static public final int BOTTOM = 5;
044:            /** Position the title below the border's bottom line. */
045:            static public final int BELOW_BOTTOM = 6;
046:
047:            /**
048:             * Use the default justification for the title text.
049:             */
050:            static public final int DEFAULT_JUSTIFICATION = 0;
051:            /** Position title text at the left side of the border line. */
052:            static public final int LEFT = 1;
053:            /** Position title text in the center of the border line. */
054:            static public final int CENTER = 2;
055:            /** Position title text at the right side of the border line. */
056:            static public final int RIGHT = 3;
057:            /** Position title text at the left side of the border line
058:             *  for left to right orientation, at the right side of the 
059:             *  border line for right to left orientation.
060:             */
061:            static public final int LEADING = 4;
062:            /** Position title text at the right side of the border line
063:             *  for left to right orientation, at the left side of the 
064:             *  border line for right to left orientation.
065:             */
066:            static public final int TRAILING = 5;
067:
068:            // Space between the border and the component's edge
069:            static protected final int EDGE_SPACING = 2;
070:
071:            // Space between the border and text
072:            static protected final int TEXT_SPACING = 2;
073:
074:            // Horizontal inset of text that is left or right justified
075:            static protected final int TEXT_INSET_H = 5;
076:
077:            /**
078:             * Map of {@link Selector} to CSS {@link Style}s currently assigned to this component.
079:             */
080:            protected Map dynamicStyles;
081:
082:            /**
083:             * Two different selectoren, one for fieldset and one for legend
084:             **/
085:            public static final Selector SELECTOR_FIELDSET = new Selector(
086:                    "Fieldset");
087:            public static final Selector SELECTOR_LEGEND = new Selector(
088:                    "Legend");
089:
090:            //private SBorder border;
091:            private String title;
092:
093:            private SFont font = null;
094:
095:            private Color color = null;
096:
097:            private int titleJustification = DEFAULT_JUSTIFICATION;
098:
099:            private SBorder border = null;
100:
101:            /**
102:             * Constructor for STitledBorder.
103:             * 
104:             */
105:            public STitledBorder(SBorder border) {
106:                this (border, "");
107:            }
108:
109:            /**
110:             * Constructor for STitledBorder. Default border
111:             * type is {@link SEtchedBorder}, thickness 2
112:             */
113:            public STitledBorder(String title) {
114:                this ((SBorder) null, title);
115:            }
116:
117:            /**
118:             * Constructor for STitledBorder.
119:             *
120:             * @param border the border to use
121:             * @param title  the title to display
122:             */
123:            public STitledBorder(SBorder border, String title) {
124:                this (border, title, DEFAULT_JUSTIFICATION, DEFAULT_POSITION);
125:            }
126:
127:            /**
128:             * Constructor for STitledBorder
129:             * Creates a STitledBorder instance with the specified border, title, title-justification, and title-position.
130:             *
131:             * @param border the border to use
132:             * @param title  the title to display
133:             * @param titleJustification (not used)
134:             * @param titlePosition (not used)
135:             */
136:
137:            public STitledBorder(SBorder border, String title,
138:                    int titleJustification, int titlePosition) {
139:                this (border, title, titleJustification, titlePosition, null);
140:            }
141:
142:            /**
143:             * Constructor for STitledBorder
144:             * Creates a STitledBorder instance with the specified border, title, title-justification, title-position, and title-font.
145:             *
146:             * @param border the border to use
147:             * @param title  the title to display
148:             * @param titleJustification
149:             * @param titlePosition (not used)
150:             * @param titleFont the font to used
151:             */
152:
153:            public STitledBorder(SBorder border, String title,
154:                    int titleJustification, int titlePosition, SFont titleFont) {
155:                this (border, title, titleJustification, titlePosition,
156:                        titleFont, null);
157:            }
158:
159:            /**
160:             * Constructor for STitledBorder
161:             * Creates a TitledBorder instance with the specified border, title, title-justification, title-position, title-font, and title-color.
162:             *
163:             * @param border the border to use
164:             * @param title  the title to display
165:             * @param titleJustification
166:             * @param titlePosition (not used)
167:             * @param titleFont the font to use
168:             * @param titleColor the color to use
169:             */
170:
171:            public STitledBorder(SBorder border, String title,
172:                    int titleJustification, int titlePosition, SFont titleFont,
173:                    Color titleColor) {
174:                setBorder(border);
175:                setTitle(title);
176:                setTitleFont(titleFont);
177:                setTitleColor(titleColor);
178:                setTitleJustification(titleJustification);
179:                setCG(new TitleBorderCG());
180:            }
181:
182:            /**
183:             * Gets the border.
184:             *
185:             * @return Returns a SBorder
186:             * 
187:             */
188:            public SBorder getBorder() {
189:                return border;
190:            }
191:
192:            /**
193:             * Sets the border.
194:             *
195:             * @param border The border to set
196:             * 
197:             */
198:            public void setBorder(SBorder border) {
199:                if ((component != null) && (isDifferent(this .border, border)))
200:                    component.reload();
201:                this .border = border;
202:            }
203:
204:            /**
205:             * Gets the title.
206:             *
207:             * @return Returns a String
208:             */
209:            public String getTitle() {
210:                return title;
211:            }
212:
213:            /**
214:             * Sets the title.
215:             *
216:             * @param title The title to set
217:             */
218:            public void setTitle(String title) {
219:                if ((component != null) && (isDifferent(this .title, title)))
220:                    component.reload();
221:                this .title = title;
222:            }
223:
224:            /**
225:             * Sets the title-font of the titled border.
226:             *
227:             * @param titleFont - the font for the border title
228:             **/
229:            public void setTitleFont(SFont titleFont) {
230:                if ((component != null) && (isDifferent(this .font, titleFont)))
231:                    component.reload();
232:                this .font = titleFont;
233:            }
234:
235:            /**
236:             * Sets the title-color of the titled border.
237:             *
238:             * @param titleColor - the color for the border title
239:             **/
240:            public void setTitleColor(Color titleColor) {
241:                if ((component != null)
242:                        && (isDifferent(this .color, titleColor)))
243:                    component.reload();
244:                this .color = titleColor;
245:            }
246:
247:            /**
248:             * Returns the title-font of the titled border.
249:             *
250:             **/
251:            public SFont getTitleFont() {
252:                return font;
253:            }
254:
255:            /**
256:             * Returns the title-color of the titled border.
257:             *
258:             **/
259:            public Color getTitleColor() {
260:                return color;
261:            }
262:
263:            /**
264:             * Returns the title-justification of the titled border.
265:             **/
266:            public int getTitleJustification() {
267:                return titleJustification;
268:            }
269:
270:            /**
271:             * Sets the title-justification of the titled border.
272:             * @param titleJustification, Default, Center, Right, Left
273:             **/
274:
275:            public void setTitleJustification(int titleJustification) {
276:                if ((component != null)
277:                        && (this .titleJustification != titleJustification))
278:                    component.reload();
279:                this .titleJustification = titleJustification;
280:            }
281:
282:            /**
283:             * use this method for changing a variable. if a new value is different
284:             * from the old value set the new one and notify e.g. the reloadmanager...
285:             */
286:            protected static boolean isDifferent(Object oldObject,
287:                    Object newObject) {
288:                if (oldObject == newObject)
289:                    return false;
290:
291:                if (oldObject == null)
292:                    return true;
293:
294:                return !oldObject.equals(newObject);
295:            }
296:
297:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.