Source Code Cross Referenced for ChangeStylesPlugIn.java in  » GIS » openjump » com » vividsolutions » jump » workbench » 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 » GIS » openjump » com.vividsolutions.jump.workbench.ui.style 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003:         * for visualizing and manipulating spatial features with geometry and attributes.
004:         *
005:         * Copyright (C) 2003 Vivid Solutions
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * as published by the Free Software Foundation; either version 2
010:         * of the License, or (at your option) any later version.
011:         *
012:         * This program is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         * GNU General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU General Public License
018:         * along with this program; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
020:         *
021:         * For more information, contact:
022:         *
023:         * Vivid Solutions
024:         * Suite #1A
025:         * 2328 Government Street
026:         * Victoria BC  V8T 5G5
027:         * Canada
028:         *
029:         * (250)385-6040
030:         * www.vividsolutions.com
031:         */
032:        package com.vividsolutions.jump.workbench.ui.style;
033:
034:        import com.vividsolutions.jts.util.Assert;
035:
036:        import com.vividsolutions.jump.I18N;
037:        import com.vividsolutions.jump.workbench.WorkbenchContext;
038:        import com.vividsolutions.jump.workbench.model.Layer;
039:        import com.vividsolutions.jump.workbench.model.UndoableCommand;
040:        import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
041:        import com.vividsolutions.jump.workbench.plugin.EnableCheck;
042:        import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
043:        import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
044:        import com.vividsolutions.jump.workbench.plugin.PlugInContext;
045:        import com.vividsolutions.jump.workbench.ui.GUIUtil;
046:        import com.vividsolutions.jump.workbench.ui.MultiInputDialog;
047:        import com.vividsolutions.jump.workbench.ui.images.IconLoader;
048:        import com.vividsolutions.jump.workbench.ui.renderer.style.ColorThemingStylePanel;
049:
050:        import java.awt.BorderLayout;
051:        import java.awt.Component;
052:        import java.awt.Dimension;
053:        import java.awt.GridBagLayout;
054:
055:        import java.util.ArrayList;
056:        import java.util.Arrays;
057:        import java.util.Collection;
058:        import java.util.Iterator;
059:
060:        import javax.swing.ImageIcon;
061:        import javax.swing.JComboBox;
062:        import javax.swing.JComponent;
063:        import javax.swing.JFrame;
064:        import javax.swing.JLabel;
065:        import javax.swing.JPanel;
066:        import javax.swing.JTabbedPane;
067:
068:        public class ChangeStylesPlugIn extends AbstractPlugIn {
069:            private final static String LAST_TAB_KEY = ChangeStylesPlugIn.class
070:                    .getName()
071:                    + " - LAST TAB";
072:
073:            public ChangeStylesPlugIn() {
074:            }
075:
076:            public boolean execute(PlugInContext context) throws Exception {
077:                final Layer layer = context.getSelectedLayer(0);
078:                MultiInputDialog dialog = new MultiInputDialog(context
079:                        .getWorkbenchFrame(), I18N
080:                        .get("ui.style.ChangeStylesPlugIn.change-styles"), true);
081:                dialog.setInset(0);
082:                dialog.setSideBarImage(IconLoader.icon("Symbology.gif"));
083:                dialog
084:                        .setSideBarDescription(I18N
085:                                .get("ui.style.ChangeStylesPlugIn.you-can-use-this-dialog-to-change-the-colour-line-width"));
086:
087:                final ArrayList stylePanels = new ArrayList();
088:                RenderingStylePanel renderingStylePanel = new RenderingStylePanel(
089:                        context.getWorkbenchContext().getWorkbench()
090:                                .getBlackboard(), layer);
091:                stylePanels.add(renderingStylePanel);
092:                stylePanels.add(new ScaleStylePanel(layer, context
093:                        .getLayerViewPanel()));
094:
095:                //Only set preferred size for DecorationStylePanel or ColorThemingStylePanel;
096:                //otherwise they will grow to the height of the screen. But don't set
097:                //the preferred size of LabelStylePanel to (400, 300) -- in fact, it needs
098:                //a bit more height -- any less, and its text boxes will shrink to
099:                //zero-width. I've found that if you don't give text boxes enough height,
100:                //they simply shrink to zero-width. [Jon Aquino]
101:                DecorationStylePanel decorationStylePanel = new DecorationStylePanel(
102:                        layer, context.getWorkbenchFrame()
103:                                .getChoosableStyleClasses());
104:                decorationStylePanel.setPreferredSize(new Dimension(400, 300));
105:
106:                if (layer.getFeatureCollectionWrapper().getFeatureSchema()
107:                        .getAttributeCount() > 1) {
108:                    ColorThemingStylePanel colorThemingStylePanel = new ColorThemingStylePanel(
109:                            layer, context.getWorkbenchContext());
110:                    colorThemingStylePanel.setPreferredSize(new Dimension(400,
111:                            300));
112:                    stylePanels.add(colorThemingStylePanel);
113:                    GUIUtil.sync(renderingStylePanel.getTransparencySlider(),
114:                            colorThemingStylePanel.getTransparencySlider());
115:                    GUIUtil.sync(renderingStylePanel.getSynchronizeCheckBox(),
116:                            colorThemingStylePanel.getSynchronizeCheckBox());
117:                } else {
118:                    stylePanels.add(new DummyColorThemingStylePanel());
119:                }
120:
121:                stylePanels
122:                        .add(new LabelStylePanel(layer, context
123:                                .getLayerViewPanel(), dialog, context
124:                                .getErrorHandler()));
125:                stylePanels.add(decorationStylePanel);
126:
127:                JTabbedPane tabbedPane = new JTabbedPane();
128:
129:                for (Iterator i = stylePanels.iterator(); i.hasNext();) {
130:                    final StylePanel stylePanel = (StylePanel) i.next();
131:                    tabbedPane.add((Component) stylePanel, stylePanel
132:                            .getTitle());
133:                    dialog.addEnableChecks(stylePanel.getTitle(), Arrays
134:                            .asList(new EnableCheck[] { new EnableCheck() {
135:                                public String check(JComponent component) {
136:                                    return stylePanel.validateInput();
137:                                }
138:                            } }));
139:                }
140:
141:                dialog.addRow(tabbedPane);
142:                tabbedPane.setSelectedComponent(find(stylePanels,
143:                        (String) context.getWorkbenchContext().getWorkbench()
144:                                .getBlackboard().get(
145:                                        LAST_TAB_KEY,
146:                                        ((StylePanel) stylePanels.iterator()
147:                                                .next()).getTitle())));
148:                dialog.setVisible(true);
149:                context
150:                        .getWorkbenchContext()
151:                        .getWorkbench()
152:                        .getBlackboard()
153:                        .put(
154:                                LAST_TAB_KEY,
155:                                ((StylePanel) tabbedPane.getSelectedComponent())
156:                                        .getTitle());
157:
158:                if (dialog.wasOKPressed()) {
159:                    final Collection oldStyles = layer.cloneStyles();
160:                    layer.getLayerManager().deferFiringEvents(new Runnable() {
161:                        public void run() {
162:                            for (Iterator i = stylePanels.iterator(); i
163:                                    .hasNext();) {
164:                                StylePanel stylePanel = (StylePanel) i.next();
165:                                stylePanel.updateStyles();
166:                            }
167:                        }
168:                    });
169:
170:                    final Collection newStyles = layer.cloneStyles();
171:                    execute(new UndoableCommand(getName()) {
172:                        public void execute() {
173:                            layer.setStyles(newStyles);
174:                        }
175:
176:                        public void unexecute() {
177:                            layer.setStyles(oldStyles);
178:                        }
179:                    }, context);
180:                    return true;
181:                }
182:
183:                return false;
184:            }
185:
186:            private Component find(Collection stylePanels, String title) {
187:                for (Iterator i = stylePanels.iterator(); i.hasNext();) {
188:                    StylePanel stylePanel = (StylePanel) i.next();
189:
190:                    if (stylePanel.getTitle().equals(title)) {
191:                        return (Component) stylePanel;
192:                    }
193:                }
194:
195:                Assert.shouldNeverReachHere();
196:
197:                return null;
198:            }
199:
200:            public ImageIcon getIcon() {
201:                return IconLoader.icon("Palette.gif");
202:            }
203:
204:            public MultiEnableCheck createEnableCheck(
205:                    final WorkbenchContext workbenchContext) {
206:                EnableCheckFactory checkFactory = new EnableCheckFactory(
207:                        workbenchContext);
208:
209:                return new MultiEnableCheck()
210:                        .add(
211:                                checkFactory
212:                                        .createWindowWithLayerNamePanelMustBeActiveCheck())
213:                        // ScaledStylePanel assumes that the active window has a LayerViewPanel. [Jon Aquino 2005-08-09]
214:                        .add(
215:                                checkFactory
216:                                        .createWindowWithLayerViewPanelMustBeActiveCheck())
217:                        .add(
218:                                checkFactory
219:                                        .createExactlyNLayersMustBeSelectedCheck(1));
220:            }
221:
222:            private class DummyColorThemingStylePanel extends JPanel implements 
223:                    StylePanel {
224:                public DummyColorThemingStylePanel() {
225:                    //GridBagLayout so it gets centered. [Jon Aquino]
226:                    super (new GridBagLayout());
227:                    add(new JLabel(
228:                            I18N
229:                                    .get("ui.style.ChangeStylesPlugIn.this-layer-has-no-attributes")));
230:                }
231:
232:                public String getTitle() {
233:                    return ColorThemingStylePanel.TITLE;
234:                }
235:
236:                public void updateStyles() {
237:                }
238:
239:                public String validateInput() {
240:                    return null;
241:                }
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.