Source Code Cross Referenced for RadialGradientProperty.java in  » Swing-Library » abeille-forms-designer » com » jeta » forms » store » properties » effects » 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.jeta.forms.store.properties.effects 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2004 JETA Software, Inc.  All rights reserved.
003:         * 
004:         * Redistribution and use in source and binary forms, with or without modification, 
005:         * 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 JETA Software nor the names of its contributors may 
015:         *    be used to endorse or promote products derived from this software without 
016:         *    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, THE 
020:         * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
021:         * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
022:         * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
023:         * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
024:         * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
025:         * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
026:         * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
027:         * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
028:         */
029:
030:        package com.jeta.forms.store.properties.effects;
031:
032:        import java.awt.Color;
033:        import java.io.IOException;
034:
035:        import com.jeta.forms.gui.beans.JETABean;
036:        import com.jeta.forms.gui.effects.Paintable;
037:        import com.jeta.forms.gui.effects.Painter;
038:        import com.jeta.forms.gui.effects.RadialGradientPainter;
039:        import com.jeta.forms.store.JETAObjectInput;
040:        import com.jeta.forms.store.JETAObjectOutput;
041:        import com.jeta.forms.store.properties.ColorProperty;
042:        import com.jeta.forms.store.properties.JETAProperty;
043:        import com.jeta.open.i18n.I18N;
044:
045:        /**
046:         * Property for storing settings for a radial gradient effect. See:
047:         * {@link com.jeta.forms.gui.effects.RadialGradientPainter}
048:         * 
049:         * @author Jeff Tassin
050:         */
051:        public class RadialGradientProperty extends JETAProperty implements 
052:                PaintSupport {
053:            static final long serialVersionUID = 1554397018383485167L;
054:
055:            public static final int VERSION = 1;
056:
057:            public static final int TOP_LEFT = 0;
058:            public static final int TOP_CENTER = 1;
059:            public static final int TOP_RIGHT = 2;
060:
061:            public static final int CENTER = 3;
062:
063:            public static final int BOTTOM_LEFT = 4;
064:            public static final int BOTTOM_CENTER = 5;
065:            public static final int BOTTOM_RIGHT = 6;
066:
067:            public static final int LEFT_CENTER = 7;
068:            public static final int RIGHT_CENTER = 8;
069:
070:            /**
071:             * The start color is at the center of the radial.
072:             */
073:            private ColorProperty m_start_color = new ColorProperty(Color.black);
074:
075:            /**
076:             * The end color for the gradient.
077:             */
078:            private ColorProperty m_end_color = new ColorProperty(Color.white);
079:
080:            /**
081:             * The location of the center of the gradient.
082:             */
083:            private int m_position = TOP_LEFT;
084:
085:            /**
086:             * Controls the rate of change from one color to the next
087:             */
088:            private int m_magnitude = 100;
089:
090:            /**
091:             * A cached painter object
092:             */
093:            private transient RadialGradientPainter m_painter;
094:
095:            /**
096:             * Creates an uninitialized <code>RadialGradientProperty</code> instance.
097:             */
098:            public RadialGradientProperty() {
099:
100:            }
101:
102:            /**
103:             * Creates an uninitialized <code>RadialGradientProperty</code> instance.
104:             * 
105:             * @param startColor
106:             *            the start color for the gradient
107:             */
108:            public RadialGradientProperty(ColorProperty startColor,
109:                    ColorProperty endColor, int position, int magnitude) {
110:                m_start_color = startColor;
111:                m_end_color = endColor;
112:                m_position = position;
113:                m_magnitude = magnitude;
114:            }
115:
116:            /**
117:             * PaintSupport implementation. Creates a painter that renders a radial
118:             * gradient using the attributes defined in this object.
119:             */
120:            public Painter createPainter() {
121:                if (m_painter == null)
122:                    m_painter = new RadialGradientPainter(this );
123:
124:                return m_painter;
125:            }
126:
127:            /**
128:             * Returns the color at the center of the radial.
129:             * 
130:             * @return the start color
131:             */
132:            public ColorProperty getStartColor() {
133:                return m_start_color;
134:            }
135:
136:            /**
137:             * Returns the center of the radial gradient. Valid values: TOP_LEFT,
138:             * TOP_CENTER, TOP_RIGHT, CENTER, BOTTOM_LEFT, BOTTOM_CENTER, BOTTOM_RIGHT,
139:             * LEFT_CENTER, RIGHT_CENTER
140:             */
141:            public int getPosition() {
142:                return m_position;
143:            }
144:
145:            /**
146:             * Returns the end color.
147:             * 
148:             * @return the end color
149:             */
150:            public ColorProperty getEndColor() {
151:                return m_end_color;
152:            }
153:
154:            /**
155:             * Returns the rate of change from one color to the next. 100 is the default
156:             * value.
157:             */
158:            public int getMagnitude() {
159:                return m_magnitude;
160:            }
161:
162:            /**
163:             * Sets the rate of change from one color to the next. 100 is the default
164:             * value.
165:             * 
166:             * @param mag
167:             *            the magnitude
168:             */
169:            public void setMagnitude(int mag) {
170:                m_magnitude = mag;
171:                m_painter = null;
172:            }
173:
174:            /**
175:             * Sets the position of the radial center.
176:             * 
177:             * @param position
178:             *            the location of the center of the gradient. Valid values:
179:             *            TOP_LEFT, TOP_CENTER, TOP_RIGHT, CENTER, BOTTOM_LEFT,
180:             *            BOTTOM_CENTER, BOTTOM_RIGHT, LEFT_CENTER, RIGHT_CENTER
181:             */
182:            public void setPosition(int position) {
183:                m_position = position;
184:                m_painter = null;
185:            }
186:
187:            /**
188:             * Sets the color at the center of the radial.
189:             * 
190:             * @param c
191:             *            the start color
192:             */
193:            public void setStartColor(ColorProperty c) {
194:                m_start_color = c;
195:                m_painter = null;
196:            }
197:
198:            /**
199:             * Sets the end color.
200:             * 
201:             * @param c
202:             *            the end color
203:             */
204:            public void setEndColor(ColorProperty c) {
205:                m_end_color = c;
206:                m_painter = null;
207:            }
208:
209:            /**
210:             * Sets this property to that of another property.
211:             */
212:            public void setValue(Object prop) {
213:                if (prop instanceof  RadialGradientProperty) {
214:                    RadialGradientProperty gp = (RadialGradientProperty) prop;
215:                    if (m_start_color == null)
216:                        m_start_color = new ColorProperty();
217:                    if (m_end_color == null)
218:                        m_end_color = new ColorProperty();
219:
220:                    m_start_color.setValue(gp.m_start_color);
221:                    m_end_color.setValue(gp.m_end_color);
222:                    m_position = gp.m_position;
223:                    m_magnitude = gp.m_magnitude;
224:                    m_painter = null;
225:                } else {
226:                    assert (false);
227:                }
228:            }
229:
230:            /**
231:             * Updates the bean. Gets the underlying Java bean component associated with
232:             * this property and if that component implements the Paintable interface,
233:             * sets the background painter.
234:             */
235:            public void updateBean(JETABean jbean) {
236:                RadialGradientPainter painter = (RadialGradientPainter) createPainter();
237:                if (jbean != null) {
238:                    java.awt.Component comp = jbean.getDelegate();
239:                    if (comp instanceof  Paintable) {
240:                        ((Paintable) comp).setBackgroundPainter(painter);
241:                    } else {
242:                        assert (false);
243:                    }
244:                }
245:
246:            }
247:
248:            /**
249:             * @return a string representation of this proprety
250:             */
251:            public String toString() {
252:                return I18N.getLocalizedMessage("Radial Gradient");
253:            }
254:
255:            /**
256:             * Externalizable Implementation
257:             */
258:            public void read(JETAObjectInput in) throws ClassNotFoundException,
259:                    IOException {
260:                super .read(in.getSuperClassInput());
261:                int version = in.readVersion();
262:                m_start_color = (ColorProperty) in.readObject("startcolor");
263:                m_end_color = (ColorProperty) in.readObject("endcolor");
264:                m_position = in.readInt("position");
265:                m_magnitude = in.readInt("magnitude");
266:            }
267:
268:            /**
269:             * Externalizable Implementation
270:             */
271:            public void write(JETAObjectOutput out) throws IOException {
272:                super .write(out.getSuperClassOutput(JETAProperty.class));
273:                out.writeVersion(VERSION);
274:                out.writeObject("startcolor", m_start_color);
275:                out.writeObject("endcolor", m_end_color);
276:                out.writeInt("position", m_position);
277:                out.writeInt("magnitude", m_magnitude);
278:            }
279:
280:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.