Source Code Cross Referenced for ComponentProperties.java in  » Swing-Library » InfoNode-Docking-Windows » net » infonode » properties » gui » 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 » InfoNode Docking Windows » net.infonode.properties.gui.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 NNL Technology AB
003:         * Visit www.infonode.net for information about InfoNode(R) 
004:         * products and how to contact NNL Technology AB.
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
019:         * MA 02111-1307, USA.
020:         */
021:
022:        // $Id: ComponentProperties.java,v 1.17 2005/12/04 13:46:05 jesper Exp $
023:        package net.infonode.properties.gui.util;
024:
025:        import net.infonode.gui.InsetsUtil;
026:        import net.infonode.gui.panel.BaseContainer;
027:        import net.infonode.gui.panel.BaseContainerUtil;
028:        import net.infonode.properties.propertymap.*;
029:        import net.infonode.properties.types.BorderProperty;
030:        import net.infonode.properties.types.ColorProperty;
031:        import net.infonode.properties.types.FontProperty;
032:        import net.infonode.properties.types.InsetsProperty;
033:        import net.infonode.util.Direction;
034:
035:        import javax.swing.*;
036:        import javax.swing.border.Border;
037:        import javax.swing.border.CompoundBorder;
038:        import javax.swing.border.EmptyBorder;
039:        import java.awt.*;
040:
041:        /**
042:         * Properties and property values for a {@link JComponent}.
043:         *
044:         * @author $Author: jesper $
045:         * @version $Revision: 1.17 $
046:         */
047:        public class ComponentProperties extends PropertyMapContainer {
048:            /**
049:             * Property group for all component properties.
050:             */
051:            public static final PropertyMapGroup PROPERTIES = new PropertyMapGroup(
052:                    "Component Properties", "");
053:
054:            /**
055:             * Component border.
056:             */
057:            public static final BorderProperty BORDER = new BorderProperty(
058:                    PROPERTIES, "Border", "Component border.",
059:                    PropertyMapValueHandler.INSTANCE);
060:
061:            /**
062:             * Component insets inside the border.
063:             */
064:            public static final InsetsProperty INSETS = new InsetsProperty(
065:                    PROPERTIES, "Insets",
066:                    "Component insets inside the border.",
067:                    PropertyMapValueHandler.INSTANCE);
068:
069:            /**
070:             * Component foreground color.
071:             */
072:            public static final ColorProperty FOREGROUND_COLOR = new ColorProperty(
073:                    PROPERTIES, "Foreground Color",
074:                    "Component foreground color.",
075:                    PropertyMapValueHandler.INSTANCE);
076:
077:            /**
078:             * Component text font.
079:             */
080:            public static final FontProperty FONT = new FontProperty(
081:                    PROPERTIES, "Font", "Component text font.",
082:                    PropertyMapValueHandler.INSTANCE);
083:
084:            /**
085:             * Component background color. A null value means that no background will be painted.
086:             */
087:            public static final ColorProperty BACKGROUND_COLOR = new ColorProperty(
088:                    PROPERTIES,
089:                    "Background Color",
090:                    "Component background color. A null value means that no background will be painted.",
091:                    PropertyMapValueHandler.INSTANCE);
092:
093:            static {
094:                ComponentProperties properties = new ComponentProperties(
095:                        PROPERTIES.getDefaultMap());
096:
097:                properties.setBackgroundColor(null).setBorder(null).setInsets(
098:                        null);
099:            }
100:
101:            /**
102:             * Creates an empty property object.
103:             */
104:            public ComponentProperties() {
105:                super (PROPERTIES);
106:            }
107:
108:            /**
109:             * Creates a property map containing the map.
110:             *
111:             * @param map the property map
112:             */
113:            public ComponentProperties(PropertyMap map) {
114:                super (map);
115:            }
116:
117:            /**
118:             * Creates a property object that inherit values from another property object.
119:             *
120:             * @param inheritFrom the object from which to inherit property values
121:             */
122:            public ComponentProperties(ComponentProperties inheritFrom) {
123:                super (PropertyMapFactory.create(inheritFrom.getMap()));
124:            }
125:
126:            /**
127:             * Adds a super object from which property values are inherited.
128:             *
129:             * @param properties the object from which to inherit property values
130:             * @return this
131:             */
132:            public ComponentProperties addSuperObject(
133:                    ComponentProperties properties) {
134:                getMap().addSuperMap(properties.getMap());
135:
136:                return this ;
137:            }
138:
139:            /**
140:             * Removes the last added super object.
141:             *
142:             * @return this
143:             */
144:            public ComponentProperties removeSuperObject() {
145:                getMap().removeSuperMap();
146:                return this ;
147:            }
148:
149:            /**
150:             * Removes the given super object.
151:             *
152:             * @param superObject super object to remove
153:             * @return this
154:             */
155:            public ComponentProperties removeSuperObject(
156:                    ComponentProperties super Object) {
157:                getMap().removeSuperMap(super Object.getMap());
158:                return this ;
159:            }
160:
161:            /**
162:             * Sets the component border.
163:             *
164:             * @param border the component border
165:             * @return this
166:             */
167:            public ComponentProperties setBorder(Border border) {
168:                BORDER.set(getMap(), border);
169:
170:                return this ;
171:            }
172:
173:            /**
174:             * Sets the component insets inside the border.
175:             *
176:             * @param insets the component insets
177:             * @return this
178:             */
179:            public ComponentProperties setInsets(Insets insets) {
180:                INSETS.set(getMap(), insets);
181:
182:                return this ;
183:            }
184:
185:            /**
186:             * Sets the component background color.
187:             *
188:             * @param color the background color, null means no background
189:             * @return this
190:             */
191:            public ComponentProperties setBackgroundColor(Color color) {
192:                BACKGROUND_COLOR.set(getMap(), color);
193:
194:                return this ;
195:            }
196:
197:            /**
198:             * Returns the component insets inside the border.
199:             *
200:             * @return the component insets inside the border
201:             */
202:            public Insets getInsets() {
203:                return INSETS.get(getMap());
204:            }
205:
206:            /**
207:             * Returns the component border.
208:             *
209:             * @return the component border
210:             */
211:            public Border getBorder() {
212:                return BORDER.get(getMap());
213:            }
214:
215:            /**
216:             * Returns the component background color.
217:             *
218:             * @return the component background color
219:             */
220:            public Color getBackgroundColor() {
221:                return BACKGROUND_COLOR.get(getMap());
222:            }
223:
224:            /**
225:             * Returns the component text font.
226:             *
227:             * @return the component text font
228:             */
229:            public Font getFont() {
230:                return FONT.get(getMap());
231:            }
232:
233:            /**
234:             * Returns the component foreground color.
235:             *
236:             * @return the component foreground color
237:             */
238:            public Color getForegroundColor() {
239:                return FOREGROUND_COLOR.get(getMap());
240:            }
241:
242:            /**
243:             * Sets the component foreground color.
244:             *
245:             * @param foregroundColor the component foreground color
246:             * @return this
247:             */
248:            public ComponentProperties setForegroundColor(Color foregroundColor) {
249:                FOREGROUND_COLOR.set(getMap(), foregroundColor);
250:                return this ;
251:            }
252:
253:            /**
254:             * Sets the component text font.
255:             *
256:             * @param font the component text font
257:             * @return this
258:             */
259:            public ComponentProperties setFont(Font font) {
260:                FONT.set(getMap(), font);
261:                return this ;
262:            }
263:
264:            /**
265:             * Applies the property values to a component.
266:             *
267:             * @param component the component on which to apply the property values
268:             */
269:            public void applyTo(JComponent component) {
270:                applyTo(component, Direction.RIGHT);
271:            }
272:
273:            /**
274:             * Applies the property values to a component and rotates the insets in the
275:             * given direction.
276:             *
277:             * @param component       the component on which to apply the property values
278:             * @param insetsDirection insets direction
279:             */
280:            public void applyTo(JComponent component, Direction insetsDirection) {
281:                Insets insets = getInsets() == null ? null : InsetsUtil.rotate(
282:                        insetsDirection, getInsets());
283:                Border innerBorder = (insets == null) ? null : new EmptyBorder(
284:                        insets);
285:                component
286:                        .setBorder((getBorder() == null) ? innerBorder
287:                                : ((innerBorder == null) ? getBorder()
288:                                        : new CompoundBorder(getBorder(),
289:                                                innerBorder)));
290:                //component.setOpaque(getBackgroundColor() != null);
291:
292:                if (component instanceof  BaseContainer) {
293:                    BaseContainer c = (BaseContainer) component;
294:                    BaseContainerUtil.setOverridedBackground(c,
295:                            getBackgroundColor());
296:                    BaseContainerUtil.setOverridedForeground(c,
297:                            getForegroundColor());
298:                    BaseContainerUtil.setOverridedFont(c, getFont());
299:                } else {
300:                    component.setBackground(getBackgroundColor());
301:                    component.setFont(getFont());
302:                    component.setForeground(getForegroundColor());
303:                }
304:            }
305:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.