Source Code Cross Referenced for Border.java in  » Web-Framework » ThinWire » thinwire » ui » style » 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 » Web Framework » ThinWire » thinwire.ui.style 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:        #IFNDEF ALT_LICENSE
003:                                   ThinWire(R) RIA Ajax Framework
004:                         Copyright (C) 2003-2007 Custom Credit Systems
005:
006:          This library is free software; you can redistribute it and/or modify it under
007:          the terms of the GNU Lesser General Public License as published by the Free
008:          Software Foundation; either version 2.1 of the License, or (at your option) any
009:          later version.
010:
011:          This library is distributed in the hope that it will be useful, but WITHOUT ANY
012:          WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
013:          PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
014:
015:          You should have received a copy of the GNU Lesser General Public License along
016:          with this library; if not, write to the Free Software Foundation, Inc., 59
017:          Temple Place, Suite 330, Boston, MA 02111-1307 USA
018:
019:          Users who would rather have a commercial license, warranty or support should
020:          contact the following company who invented, built and supports the technology:
021:          
022:                        Custom Credit Systems, Richardson, TX 75081, USA.
023:           	            email: info@thinwire.com    ph: +1 (888) 644-6405
024:         	                        http://www.thinwire.com
025:        #ENDIF
026:         [ v1.2_RC2 ] 
027:         */
028:        package thinwire.ui.style;
029:
030:        import thinwire.util.ImageInfo;
031:
032:        /**
033:         * @author Joshua J. Gertzen
034:         */
035:        public class Border {
036:            public static final String PROPERTY_BORDER_COLOR = "borderColor";
037:            public static final String PROPERTY_BORDER_SIZE = "borderSize";
038:            public static final String PROPERTY_BORDER_TYPE = "borderType";
039:            public static final String PROPERTY_BORDER_IMAGE = "borderImage";
040:
041:            public enum Type {
042:                NONE, SOLID, DOUBLE, INSET, OUTSET, RIDGE, GROOVE, DASHED, DOTTED, IMAGE;
043:
044:                public String toString() {
045:                    return name().toLowerCase();
046:                }
047:            };
048:
049:            private Style parent;
050:            private Type type;
051:            private int size = -1;
052:            private Color color;
053:            private ImageInfo imageInfo = new ImageInfo(null);
054:            private Type imageType;
055:            private String stringValue;
056:
057:            Border(Style parent) {
058:                this .parent = parent;
059:                if (parent.defaultStyle != null)
060:                    copy(parent.defaultStyle.getBorder());
061:            }
062:
063:            private void clearStringValue() {
064:                this .stringValue = null;
065:                if (parent != null)
066:                    parent.stringValue = null;
067:            }
068:
069:            public String toString() {
070:                if (stringValue == null)
071:                    stringValue = "Border{color:" + getColor() + ",image:"
072:                            + getImage() + ",size:" + getSize() + ",type:"
073:                            + getType() + "}";
074:                return stringValue;
075:            }
076:
077:            public int hashCode() {
078:                return toString().hashCode();
079:            }
080:
081:            public boolean equals(Object o) {
082:                if (!(o instanceof  Border))
083:                    return false;
084:                if (this  == o)
085:                    return true;
086:                return this .toString().equals(o.toString());
087:            }
088:
089:            public void copy(Border border) {
090:                copy(border, false);
091:            }
092:
093:            public void copy(Border border, boolean onlyIfDefault) {
094:                if (border == null)
095:                    throw new IllegalArgumentException("border == null");
096:
097:                if (onlyIfDefault) {
098:                    Border db = parent.defaultStyle.getBorder();
099:                    if (getType().equals(db.getType()))
100:                        setType(border.getType());
101:                    if (getSize() == db.getSize())
102:                        setSize(border.getSize());
103:                    if (getColor().equals(db.getColor()))
104:                        setColor(border.getColor());
105:                    if (getImage().equals(db.getImage()))
106:                        setImage(border.getImage());
107:                } else {
108:                    setImage(border.getImage());
109:                    setSize(border.getSize());
110:                    setColor(border.getColor());
111:                    setType(border.getType());
112:                }
113:            }
114:
115:            public void setProperty(String name, Object value) {
116:                if (name.equals(Border.PROPERTY_BORDER_COLOR)) {
117:                    setColor((Color) value);
118:                } else if (name.equals(Border.PROPERTY_BORDER_TYPE)) {
119:                    setType((Border.Type) value);
120:                } else if (name.equals(Border.PROPERTY_BORDER_SIZE)) {
121:                    setSize((Integer) value);
122:                } else if (name.equals(Border.PROPERTY_BORDER_IMAGE)) {
123:                    setImage((String) value);
124:                } else {
125:                    throw new IllegalArgumentException(
126:                            "unknown style property '" + name + "'");
127:                }
128:            }
129:
130:            public Object getProperty(String name) {
131:                Object ret;
132:
133:                if (name.equals(Border.PROPERTY_BORDER_COLOR)) {
134:                    ret = getColor();
135:                } else if (name.equals(Border.PROPERTY_BORDER_TYPE)) {
136:                    ret = getType();
137:                } else if (name.equals(Border.PROPERTY_BORDER_SIZE)) {
138:                    ret = getSize();
139:                } else if (name.equals(Border.PROPERTY_BORDER_IMAGE)) {
140:                    ret = getImage();
141:                } else {
142:                    throw new IllegalArgumentException(
143:                            "unknown style property '" + name + "'");
144:                }
145:
146:                return ret;
147:            }
148:
149:            public Style getParent() {
150:                return parent;
151:            }
152:
153:            public Type getType() {
154:                if (type == null)
155:                    throw new IllegalStateException("type == null");
156:                return type;
157:            }
158:
159:            public void setType(Type type) {
160:                if (type == null && parent.defaultStyle != null) {
161:                    type = parent.defaultStyle.getBorder().getType();
162:                    if (type == Type.IMAGE)
163:                        setImage(parent.defaultStyle.getBorder().getImage());
164:                }
165:                if (type == null)
166:                    throw new IllegalArgumentException("type == null");
167:                if (type == Type.IMAGE && getImage().length() == 0)
168:                    throw new IllegalStateException(
169:                            "type == Type.IMAGE && getImage().length() == 0");
170:                Type oldType = this .type;
171:                this .clearStringValue();
172:                this .type = type;
173:                if (oldType == Type.IMAGE && type != Type.IMAGE)
174:                    setImage("");
175:                if (parent != null)
176:                    parent.firePropertyChange(this , PROPERTY_BORDER_TYPE,
177:                            oldType, this .type);
178:            }
179:
180:            public int getSize() {
181:                if (size < 0)
182:                    throw new IllegalStateException("size < 0");
183:                return size;
184:            }
185:
186:            public void setSize(int size) {
187:                if (size < 0 && parent.defaultStyle != null)
188:                    size = parent.defaultStyle.getBorder().getSize();
189:                if (size < 0 || size > 128)
190:                    throw new IllegalArgumentException("size < 0 || size > 128");
191:                int oldSize = this .size;
192:                this .clearStringValue();
193:                this .size = size;
194:                if (parent != null)
195:                    parent.firePropertyChange(this , PROPERTY_BORDER_SIZE,
196:                            oldSize, size);
197:            }
198:
199:            public Color getColor() {
200:                if (color == null)
201:                    throw new IllegalStateException("color == null");
202:                return color;
203:            }
204:
205:            public void setColor(Color color) {
206:                if (color == null && parent.defaultStyle != null)
207:                    color = parent.defaultStyle.getBorder().getColor();
208:                if (color == null)
209:                    throw new IllegalArgumentException("color == null");
210:                Color oldColor = this .color;
211:                this .clearStringValue();
212:                this .color = color;
213:                if (parent != null)
214:                    parent.firePropertyChange(this , PROPERTY_BORDER_COLOR,
215:                            oldColor, this .color);
216:            }
217:
218:            public String getImage() {
219:                return imageInfo.getName();
220:            }
221:
222:            public void setImage(String image) {
223:                if (image == null && parent.defaultStyle != null)
224:                    image = parent.defaultStyle.getBorder().getImage();
225:                if (image == null)
226:                    throw new IllegalArgumentException(
227:                            "image == null && defaultStyle.getBorder().getImage() == null");
228:                String oldImage = imageInfo.getName();
229:                this .clearStringValue();
230:                imageInfo = new ImageInfo(image);
231:                if (parent != null)
232:                    parent.firePropertyChange(this , PROPERTY_BORDER_IMAGE,
233:                            oldImage, imageInfo.getName());
234:
235:                if (imageInfo.getName().length() > 0) {
236:                    if (type != Type.IMAGE) {
237:                        imageType = type;
238:                        setType(Type.IMAGE);
239:                    }
240:                } else if (oldImage.length() > 0) {
241:                    if (getType() == Type.IMAGE) {
242:                        if (imageType == null
243:                                && parent.defaultStyle.getBorder().getType() == Type.IMAGE)
244:                            imageType = Type.SOLID;
245:                        setType(imageType);
246:                    }
247:
248:                    imageType = null;
249:                }
250:            }
251:
252:            public ImageInfo getImageInfo() {
253:                return imageInfo;
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.