Source Code Cross Referenced for PaintAssignmentView.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:        import java.awt.Dimension;
023:        import java.util.HashMap;
024:
025:        import com.jeta.forms.components.panel.FormPanel;
026:        import com.jeta.forms.gui.form.FormAccessor;
027:        import com.jeta.forms.gui.form.GridView;
028:        import com.jeta.forms.store.properties.ImageProperty;
029:        import com.jeta.forms.store.properties.JETAProperty;
030:        import com.jeta.forms.store.properties.effects.GradientProperty;
031:        import com.jeta.forms.store.properties.effects.PaintProperty;
032:        import com.jeta.forms.store.properties.effects.RadialGradientProperty;
033:        import com.jeta.forms.store.properties.effects.SolidProperty;
034:        import com.jeta.forms.store.properties.effects.TextureProperty;
035:        import com.jeta.open.gui.framework.JETAController;
036:        import com.jeta.open.gui.framework.JETAPanel;
037:        import com.jeta.open.rules.JETARule;
038:        import com.jeta.open.rules.RuleResult;
039:        import com.jeta.swingbuilder.gui.images.ImagePropertiesValidator;
040:        import com.jeta.swingbuilder.gui.utils.FormDesignerUtils;
041:        import com.jgoodies.forms.layout.CellConstraints;
042:
043:        /**
044:         * Displays the fill effects view. Currently we support solid, gradient, and
045:         * texture fills for panels and cells.
046:         * 
047:         * @author Jeff Tassin
048:         */
049:        public class PaintAssignmentView extends JETAPanel {
050:            /**
051:             * The fillProperties form.
052:             */
053:            private FormPanel m_view;
054:
055:            /**
056:             * The current fill type view: Solid, Gradient, Texture
057:             */
058:            private PaintViewProxy m_current_view;
059:
060:            /**
061:             * A map of PaintViews keyed on their class. m_views<Class,PaintView>
062:             */
063:            private HashMap m_views = new HashMap();
064:
065:            /**
066:             * The preview panel
067:             */
068:            private GridView m_preview;
069:
070:            /**
071:             * ctor
072:             */
073:            public PaintAssignmentView() {
074:                this (null);
075:            }
076:
077:            /**
078:             * ctor
079:             */
080:            public PaintAssignmentView(PaintProperty fp) {
081:                setLayout(new BorderLayout());
082:                m_view = new FormPanel(
083:                        "com/jeta/swingbuilder/gui/effects/paintProperties.frm");
084:                add(m_view, BorderLayout.CENTER);
085:                setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10,
086:                        10, 10));
087:
088:                setController(new PaintAssignmentController(this ));
089:
090:                m_preview = (GridView) m_view
091:                        .getComponentByName(PaintNames.ID_PREVIEW_PANEL);
092:                if (fp == null || fp.getPaintDelegate() == null) {
093:                    loadView(NoFillView.class);
094:                } else {
095:                    JETAProperty pp = fp.getPaintDelegate();
096:                    if (pp instanceof  TextureProperty) {
097:                        loadView(TextureView.class);
098:                    } else if (pp instanceof  GradientProperty) {
099:                        loadView(GradientView.class);
100:                    } else if (pp instanceof  RadialGradientProperty) {
101:                        loadView(RadialView.class);
102:                    } else if (pp instanceof  SolidProperty) {
103:                        loadView(SolidView.class);
104:                    } else if (pp instanceof  ImageProperty) {
105:                        loadView(ImageFillView.class);
106:                    } else {
107:                        loadView(NoFillView.class);
108:                    }
109:                    m_current_view.setPaintProperty(fp);
110:                }
111:            }
112:
113:            /**
114:             * @return the preferred size for this panel
115:             */
116:            public Dimension getPreferredSize() {
117:                return FormDesignerUtils.getWindowDimension(this , 350, 200);
118:            }
119:
120:            /**
121:             * @return the property for this view
122:             */
123:            public PaintProperty getPaintProperty() {
124:                return m_current_view.getPaintProperty();
125:            }
126:
127:            /**
128:             * Loads the GradientView into this view
129:             */
130:            void loadView(Class viewClass) {
131:                JETAController controller = getController();
132:
133:                try {
134:                    controller.enableEvents(false);
135:                    FormAccessor form_access = m_view
136:                            .getFormAccessor(PaintNames.ID_SETTINGS_PANEL);
137:                    form_access.removeBean(PaintNames.ID_MAIN_VIEW);
138:
139:                    /*
140:                     * if ( m_current_view != null ) { FormPanel.removeFromParent(
141:                     * (java.awt.Component)m_current_view.getView() ); }
142:                     */
143:
144:                    PaintViewProxy fillview = (PaintViewProxy) m_views
145:                            .get(viewClass);
146:                    if (fillview == null) {
147:                        if (viewClass == GradientView.class) {
148:                            fillview = new PaintViewProxy(new GradientView(
149:                                    m_preview), null);
150:                            m_view.setSelected(
151:                                    PaintNames.ID_LINEAR_GRADIENT_FILL, true);
152:
153:                        } else if (viewClass == TextureView.class) {
154:                            fillview = new PaintViewProxy(new TextureView(
155:                                    m_preview), new ImagePropertiesValidator());
156:                            m_view
157:                                    .setSelected(PaintNames.ID_TEXTURE_FILL,
158:                                            true);
159:                        } else if (viewClass == SolidView.class) {
160:                            fillview = new PaintViewProxy(new SolidView(
161:                                    m_preview), null);
162:                            m_view.setSelected(PaintNames.ID_SOLID_FILL, true);
163:                        } else if (viewClass == RadialView.class) {
164:                            fillview = new PaintViewProxy(new RadialView(
165:                                    m_preview), null);
166:                            m_view.setSelected(
167:                                    PaintNames.ID_RADIAL_GRADIENT_FILL, true);
168:                        } else if (viewClass == ImageFillView.class) {
169:                            fillview = new PaintViewProxy(new ImageFillView(
170:                                    m_preview), null);
171:                            m_view.setSelected(PaintNames.ID_IMAGE_FILL, true);
172:                        } else {
173:                            fillview = new PaintViewProxy(new NoFillView(
174:                                    m_preview), null);
175:                            m_view.setSelected(PaintNames.ID_NO_FILL, true);
176:                        }
177:                        m_views.put(viewClass, fillview);
178:                    }
179:
180:                    m_current_view = fillview;
181:                    java.awt.Component comp = (java.awt.Component) fillview
182:                            .getView();
183:                    comp.setName(PaintNames.ID_MAIN_VIEW);
184:                    form_access.addBean(comp, new CellConstraints(2, 2));
185:                    m_view.revalidate();
186:
187:                    revalidate();
188:                    repaint();
189:                } catch (Exception e) {
190:                    e.printStackTrace();
191:                } finally {
192:                    controller.enableEvents(true);
193:                }
194:
195:            }
196:
197:            /**
198:             * This class associates a nested paint view with its validator.
199:             * 
200:             */
201:            private static class PaintViewProxy implements  PaintView, JETARule {
202:                private PaintView m_view;
203:                private JETARule m_validator;
204:
205:                /**
206:                 * ctor
207:                 */
208:                public PaintViewProxy(PaintView view, JETARule viewValidator) {
209:                    m_view = view;
210:                    m_validator = viewValidator;
211:                }
212:
213:                public PaintView getView() {
214:                    return m_view;
215:                }
216:
217:                /**
218:                 * PaintView implementation
219:                 */
220:                public PaintProperty getPaintProperty() {
221:                    return m_view.getPaintProperty();
222:                }
223:
224:                /**
225:                 * PaintView implementation
226:                 */
227:                public void setPaintProperty(PaintProperty pp) {
228:                    m_view.setPaintProperty(pp);
229:                }
230:
231:                /**
232:                 * JETARule implementation
233:                 */
234:                public RuleResult check(Object[] params) {
235:                    if (m_validator == null)
236:                        return RuleResult.SUCCESS;
237:                    else {
238:                        params = new Object[] { m_view };
239:                        return m_validator.check(params);
240:                    }
241:                }
242:            }
243:
244:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.