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


001:        /*
002:         * Copyright (C) 2005 Jeff Tassin
003:         *
004:         * This library is free software; you can redistribute it and/or
005:         * modify it under the terms of the GNU Lesser General Public
006:         * License as published by the Free Software Foundation; either
007:         * version 2.1 of the License, or (at your option) any later version.
008:         *
009:         * This library is distributed in the hope that it will be useful,
010:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
011:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:         * Lesser General Public License for more details.
013:         *
014:         * You should have received a copy of the GNU Lesser General Public
015:         * License along with this library; if not, write to the Free Software
016:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:         */
018:
019:        package com.jeta.swingbuilder.gui.effects;
020:
021:        import java.awt.BorderLayout;
022:
023:        import javax.swing.JSpinner;
024:        import javax.swing.SpinnerNumberModel;
025:
026:        import com.jeta.forms.components.colors.ColorSelector;
027:        import com.jeta.forms.components.panel.FormPanel;
028:        import com.jeta.forms.gui.effects.LinearGradientPainter;
029:        import com.jeta.forms.gui.effects.Painter;
030:        import com.jeta.forms.gui.form.GridView;
031:        import com.jeta.forms.store.properties.effects.GradientProperty;
032:        import com.jeta.forms.store.properties.effects.PaintProperty;
033:        import com.jeta.open.gui.framework.JETAController;
034:        import com.jeta.open.gui.framework.JETAPanel;
035:
036:        /**
037:         * @author Jeff Tassin
038:         */
039:        public class GradientView extends JETAPanel implements  PaintView {
040:            /**
041:             * The fillProperties form.
042:             */
043:            private FormPanel m_view;
044:
045:            /**
046:             * The preview for the gradient settings
047:             */
048:            private GridView m_preview;
049:
050:            /**
051:             * Responsible for rendering the gradient in the parent view
052:             */
053:            private LinearGradientPainter m_painter = new LinearGradientPainter();
054:
055:            private GradientProperty m_gp = new GradientProperty();
056:
057:            /**
058:             * ctor
059:             */
060:            public GradientView(GridView preview) {
061:                this (preview, null);
062:            }
063:
064:            /**
065:             * ctor
066:             */
067:            public GradientView(GridView preview, PaintProperty gp) {
068:                m_preview = preview;
069:                setLayout(new BorderLayout());
070:                m_view = new FormPanel(
071:                        "com/jeta/swingbuilder/gui/effects/gradientProperties.frm");
072:
073:                add(m_view, BorderLayout.CENTER);
074:                setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10,
075:                        10, 10));
076:
077:                JSpinner sp = (JSpinner) m_view
078:                        .getSpinner(GradientNames.ID_MAGNITUDE_SPINNER);
079:                sp.setModel(new SpinnerNumberModel(1, 1, 1000, 1));
080:                sp.setValue(new Integer(100));
081:
082:                if (gp != null) {
083:                    initialize((GradientProperty) gp.getPaintDelegate());
084:                }
085:                setController(new GradientViewController(this ));
086:            }
087:
088:            /**
089:             * Initializes the view
090:             */
091:            private void initialize(GradientProperty gp) {
092:                JETAController controller = getController();
093:                try {
094:                    controller.enableEvents(false);
095:                    ColorSelector view = (ColorSelector) m_view
096:                            .getComponentByName(GradientNames.ID_START_COLOR_SELECTOR);
097:                    view.setColorProperty(gp.getStartColor());
098:                    view = (ColorSelector) m_view
099:                            .getComponentByName(GradientNames.ID_END_COLOR_SELECTOR);
100:                    view.setColorProperty(gp.getEndColor());
101:                    setDirection(gp.getDirection());
102:                    setMagnitude(gp.getMagnitude());
103:                } finally {
104:                    controller.enableEvents(true);
105:                }
106:            }
107:
108:            /**
109:             * @return the selection gradient direction (e.g.
110:             *         GradientProperty.HORIZONTAL, VERTICAL, ... )
111:             */
112:            public int getDirection() {
113:                String sval = (String) m_view
114:                        .getSelectedItem(GradientNames.ID_DIRECTION_COMBO);
115:                if ("TOP_BOTTOM".equals(sval))
116:                    return GradientProperty.TOP_BOTTOM;
117:                else if ("BOTTOM_TOP".equals(sval))
118:                    return GradientProperty.BOTTOM_TOP;
119:                else if ("LEFT_RIGHT".equals(sval))
120:                    return GradientProperty.LEFT_RIGHT;
121:                else if ("RIGHT_LEFT".equals(sval))
122:                    return GradientProperty.RIGHT_LEFT;
123:                else if ("UP_RIGHT".equals(sval))
124:                    return GradientProperty.UP_RIGHT;
125:                else if ("UP_LEFT".equals(sval))
126:                    return GradientProperty.UP_LEFT;
127:                else if ("DOWN_RIGHT".equals(sval))
128:                    return GradientProperty.DOWN_RIGHT;
129:                else if ("DOWN_LEFT".equals(sval))
130:                    return GradientProperty.DOWN_LEFT;
131:                else
132:                    return GradientProperty.TOP_BOTTOM;
133:            }
134:
135:            public float getMagnitude() {
136:                SpinnerNumberModel spm = (SpinnerNumberModel) m_view
137:                        .getSpinner(GradientNames.ID_MAGNITUDE_SPINNER)
138:                        .getModel();
139:                Integer ival = (Integer) spm.getValue();
140:                float mag = ((float) ival.intValue()) / 100.0f;
141:                return mag;
142:            }
143:
144:            public void setMagnitude(float mag) {
145:                SpinnerNumberModel spm = (SpinnerNumberModel) m_view
146:                        .getSpinner(GradientNames.ID_MAGNITUDE_SPINNER)
147:                        .getModel();
148:                spm.setValue(new Integer((int) (mag * 100.0f)));
149:            }
150:
151:            /**
152:             * @return a painter object for this the properties in this view
153:             */
154:            public Painter getPainter() {
155:                m_painter.setGradientProperty(getGradientProperty());
156:                return m_painter;
157:            }
158:
159:            /**
160:             * @return the
161:             */
162:            public GradientProperty getGradientProperty() {
163:                ColorSelector view = (ColorSelector) m_view
164:                        .getComponentByName(GradientNames.ID_START_COLOR_SELECTOR);
165:                GradientProperty gp = new GradientProperty();
166:                gp.setStartColor(view.getColorProperty());
167:                view = (ColorSelector) m_view
168:                        .getComponentByName(GradientNames.ID_END_COLOR_SELECTOR);
169:                gp.setEndColor(view.getColorProperty());
170:                gp.setDirection(getDirection());
171:                gp.setMagnitude(getMagnitude());
172:                return gp;
173:            }
174:
175:            /**
176:             * @return the
177:             */
178:            public PaintProperty getPaintProperty() {
179:                return new PaintProperty(getGradientProperty());
180:            }
181:
182:            /**
183:             * Sets the property for the view
184:             */
185:            public void setPaintProperty(PaintProperty pp) {
186:                if (pp.getPaintDelegate() instanceof  GradientProperty) {
187:                    GradientProperty gp = (GradientProperty) pp
188:                            .getPaintDelegate();
189:                    m_gp.setValue(gp);
190:                    initialize(m_gp);
191:                    updatePreview();
192:                }
193:            }
194:
195:            /**
196:             * Sets the gradient direction in the direction combo
197:             */
198:            public void setDirection(int dir) {
199:                if (dir == GradientProperty.TOP_BOTTOM)
200:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
201:                            "TOP_BOTTOM");
202:                else if (dir == GradientProperty.BOTTOM_TOP)
203:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
204:                            "BOTTOM_TOP");
205:                else if (dir == GradientProperty.LEFT_RIGHT)
206:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
207:                            "LEFT_RIGHT");
208:                else if (dir == GradientProperty.RIGHT_LEFT)
209:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
210:                            "RIGHT_LEFT");
211:                else if (dir == GradientProperty.UP_RIGHT)
212:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
213:                            "UP_RIGHT");
214:                else if (dir == GradientProperty.UP_LEFT)
215:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
216:                            "UP_LEFT");
217:                else if (dir == GradientProperty.DOWN_RIGHT)
218:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
219:                            "DOWN_RIGHT");
220:                else if (dir == GradientProperty.DOWN_LEFT)
221:                    m_view.setSelectedItem(GradientNames.ID_DIRECTION_COMBO,
222:                            "DOWN_LEFT");
223:            }
224:
225:            /**
226:             * Updates the preview view
227:             */
228:            public void updatePreview() {
229:                m_preview.setBackgroundPainter(getPainter());
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.