Source Code Cross Referenced for LegendGraphicStyleConfigurator.java in  » GIS » udig-1.1 » net » refractions » udig » legend » ui » 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 » udig 1.1 » net.refractions.udig.legend.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.legend.ui;
018:
019:        import java.awt.Color;
020:
021:        import net.refractions.udig.legend.internal.Messages;
022:        import net.refractions.udig.project.IBlackboard;
023:        import net.refractions.udig.project.internal.Layer;
024:        import net.refractions.udig.project.internal.StyleBlackboard;
025:        import net.refractions.udig.project.ui.internal.dialogs.ColorEditor;
026:        import net.refractions.udig.style.IStyleConfigurator;
027:
028:        import org.eclipse.swt.SWT;
029:        import org.eclipse.swt.custom.ScrolledComposite;
030:        import org.eclipse.swt.events.ModifyEvent;
031:        import org.eclipse.swt.events.ModifyListener;
032:        import org.eclipse.swt.events.SelectionEvent;
033:        import org.eclipse.swt.events.SelectionListener;
034:        import org.eclipse.swt.graphics.Point;
035:        import org.eclipse.swt.graphics.RGB;
036:        import org.eclipse.swt.layout.GridData;
037:        import org.eclipse.swt.layout.GridLayout;
038:        import org.eclipse.swt.widgets.Composite;
039:        import org.eclipse.swt.widgets.Label;
040:        import org.eclipse.swt.widgets.Text;
041:
042:        public class LegendGraphicStyleConfigurator extends IStyleConfigurator
043:                implements  SelectionListener, ModifyListener {
044:
045:            private Text verticalMargin;
046:            private Text horizontalMargin;
047:            private Text verticalSpacing;
048:            private Text horizontalSpacing;
049:            private Text indentSize;
050:            private ColorEditor fontColour;
051:            private ColorEditor backgroundColour;
052:
053:            /*
054:             *         verticalMargin = 3; 
055:                horizontalMargin = 2; 
056:                verticalSpacing = 5; 
057:                horizontalSpacing = 3; 
058:                indentSize = 10;
059:                imageHeight = 16;
060:                imageWidth = 16;
061:                maxWidth = -1;
062:                maxHeight = -1;
063:                       
064:                foregroundColour = Color.BLACK;
065:                backgroundColour = Color.WHITE;
066:                
067:                location = new Point(30, 10);
068:             */
069:
070:            public void createControl(Composite parent) {
071:                IBlackboard blackboard = getStyleBlackboard();
072:                LegendStyle style = null;
073:                if (blackboard != null) {
074:                    style = (LegendStyle) blackboard.get(LegendStyleContent.ID);
075:                }
076:
077:                if (style == null) {
078:                    style = LegendStyleContent.createDefault();
079:                    if (blackboard != null) {
080:                        blackboard.put(LegendStyleContent.ID, style);
081:                        ((StyleBlackboard) blackboard)
082:                                .setSelected(new String[] { LegendStyleContent.ID });
083:                    }
084:                }
085:
086:                ScrolledComposite scrollComposite = new ScrolledComposite(
087:                        parent, SWT.H_SCROLL | SWT.V_SCROLL);
088:                Composite composite = new Composite(scrollComposite, SWT.BORDER);
089:
090:                GridLayout layout = new GridLayout(2, true);
091:                composite.setLayout(layout);
092:
093:                GridData layoutData = null;
094:
095:                Label verticalMarginLabel = new Label(composite, SWT.NONE);
096:                verticalMarginLabel
097:                        .setText(Messages.LegendGraphicStyleConfigurator_vertical_margin);
098:                verticalMarginLabel.setLayoutData(layoutData);
099:                verticalMargin = new Text(composite, SWT.BORDER);
100:                verticalMargin.setLayoutData(layoutData);
101:
102:                Label horizontalMarginLabel = new Label(composite, SWT.NONE);
103:                horizontalMarginLabel.setLayoutData(layoutData);
104:                horizontalMarginLabel
105:                        .setText(Messages.LegendGraphicStyleConfigurator_horizontal_margin);
106:                horizontalMargin = new Text(composite, SWT.BORDER);
107:                horizontalMargin.setLayoutData(layoutData);
108:
109:                Label verticalSpacingLabel = new Label(composite, SWT.NONE);
110:                verticalSpacingLabel.setLayoutData(layoutData);
111:                verticalSpacingLabel
112:                        .setText(Messages.LegendGraphicStyleConfigurator_vertical_spacing);
113:                verticalSpacing = new Text(composite, SWT.BORDER);
114:                verticalSpacing.setLayoutData(layoutData);
115:
116:                Label horizontalSpacingLabel = new Label(composite, SWT.NONE);
117:                horizontalSpacingLabel.setLayoutData(layoutData);
118:                horizontalSpacingLabel
119:                        .setText(Messages.LegendGraphicStyleConfigurator_horizontal_spacing);
120:                horizontalSpacing = new Text(composite, SWT.BORDER);
121:                horizontalSpacing.setLayoutData(layoutData);
122:
123:                Label indentSizeLabel = new Label(composite, SWT.NONE);
124:                indentSizeLabel.setLayoutData(layoutData);
125:                indentSizeLabel
126:                        .setText(Messages.LegendGraphicStyleConfigurator_indent_size);
127:                indentSize = new Text(composite, SWT.BORDER);
128:                indentSize.setLayoutData(layoutData);
129:
130:                Label fontColourLabel = new Label(composite, SWT.NONE);
131:                fontColourLabel.setLayoutData(layoutData);
132:                fontColourLabel
133:                        .setText(Messages.LegendGraphicStyleConfigurator_font_colour);
134:                fontColour = new ColorEditor(composite);
135:
136:                Label backgroundColourLabel = new Label(composite, SWT.NONE);
137:                backgroundColourLabel.setLayoutData(layoutData);
138:                backgroundColourLabel
139:                        .setText(Messages.LegendGraphicStyleConfigurator_background_colour);
140:                backgroundColour = new ColorEditor(composite);
141:
142:                composite.layout();
143:                Point size = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
144:                composite.setSize(size);
145:                scrollComposite.setContent(composite);
146:
147:                verticalMargin.setText(Integer.toString(style.verticalMargin));
148:                horizontalMargin.setText(Integer
149:                        .toString(style.horizontalMargin));
150:                verticalSpacing
151:                        .setText(Integer.toString(style.verticalSpacing));
152:                horizontalSpacing.setText(Integer
153:                        .toString(style.horizontalSpacing));
154:                indentSize.setText(Integer.toString(style.indentSize));
155:                fontColour.setColorValue(new RGB(style.foregroundColour
156:                        .getRed(), style.foregroundColour.getGreen(),
157:                        style.foregroundColour.getBlue()));
158:                backgroundColour.setColorValue(new RGB(style.backgroundColour
159:                        .getRed(), style.backgroundColour.getGreen(),
160:                        style.backgroundColour.getBlue()));
161:
162:                verticalMargin.addModifyListener(this );
163:                horizontalMargin.addModifyListener(this );
164:                verticalSpacing.addModifyListener(this );
165:                horizontalSpacing.addModifyListener(this );
166:                indentSize.addModifyListener(this );
167:                backgroundColour.addSelectionListener(this );
168:                fontColour.addSelectionListener(this );
169:            }
170:
171:            @Override
172:            public boolean canStyle(Layer aLayer) {
173:                return aLayer.hasResource(LegendGraphic.class);
174:            }
175:
176:            @Override
177:            protected void refresh() {
178:                System.out.println("refresh"); //$NON-NLS-1$ //TODO erase this line
179:                IBlackboard blackboard = getStyleBlackboard();
180:                LegendStyle style = (LegendStyle) blackboard
181:                        .get(LegendStyleContent.ID);
182:
183:                if (style == null) {
184:                    style = LegendStyleContent.createDefault();
185:                    blackboard.put(LegendStyleContent.ID, style);
186:                    ((StyleBlackboard) blackboard)
187:                            .setSelected(new String[] { LegendStyleContent.ID });
188:                }
189:            }
190:
191:            private void updateBlackboard() {
192:                IBlackboard blackboard = getStyleBlackboard();
193:                LegendStyle style = (LegendStyle) blackboard
194:                        .get(LegendStyleContent.ID);
195:
196:                if (style == null) {
197:                    style = LegendStyleContent.createDefault();
198:                    blackboard.put(LegendStyleContent.ID, style);
199:                    ((StyleBlackboard) blackboard)
200:                            .setSelected(new String[] { LegendStyleContent.ID });
201:                }
202:
203:                RGB bg = backgroundColour.getColorValue();
204:                style.backgroundColour = new Color(bg.red, bg.green, bg.blue);
205:
206:                RGB fg = fontColour.getColorValue();
207:                style.foregroundColour = new Color(fg.red, fg.green, fg.blue);
208:
209:                style.horizontalMargin = Integer.parseInt(horizontalMargin
210:                        .getText());
211:                style.horizontalSpacing = Integer.parseInt(horizontalSpacing
212:                        .getText());
213:                style.indentSize = Integer.parseInt(indentSize.getText());
214:                style.verticalMargin = Integer.parseInt(verticalMargin
215:                        .getText());
216:                style.verticalSpacing = Integer.parseInt(verticalSpacing
217:                        .getText());
218:            }
219:
220:            public void widgetSelected(SelectionEvent e) {
221:                updateBlackboard();
222:            }
223:
224:            public void widgetDefaultSelected(SelectionEvent e) {
225:                updateBlackboard();
226:            }
227:
228:            public void modifyText(ModifyEvent e) {
229:                updateBlackboard();
230:            }
231:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.