Source Code Cross Referenced for AbstractSimpleConfigurator.java in  » GIS » udig-1.1 » net » refractions » udig » style » sld » 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.style.sld 
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.style.sld;
018:
019:        import net.refractions.udig.project.internal.Layer;
020:        import net.refractions.udig.style.IStyleConfigurator;
021:
022:        import org.eclipse.jface.dialogs.Dialog;
023:        import org.eclipse.swt.SWT;
024:        import org.eclipse.swt.events.ModifyEvent;
025:        import org.eclipse.swt.events.SelectionEvent;
026:        import org.eclipse.swt.graphics.FontMetrics;
027:        import org.eclipse.swt.graphics.GC;
028:        import org.eclipse.swt.layout.RowData;
029:        import org.eclipse.swt.layout.RowLayout;
030:        import org.eclipse.swt.widgets.Composite;
031:        import org.eclipse.swt.widgets.Event;
032:        import org.eclipse.swt.widgets.Label;
033:        import org.geotools.styling.Style;
034:        import org.geotools.styling.StyleBuilder;
035:
036:        /**
037:         * This is here to save me some typing and ensure that the simple raster and 
038:         * feature configurators look similar.
039:         * @author mleslie
040:         * @since 0.6.0
041:         */
042:        public abstract class AbstractSimpleConfigurator extends
043:                IStyleConfigurator {
044:            /** <code>build</code> field */
045:            protected StyleBuilder build = new StyleBuilder();
046:
047:            /**
048:             * Construct <code>AbstractSimpleConfigurator</code>.
049:             *
050:             */
051:            public AbstractSimpleConfigurator() {
052:                super ();
053:            }
054:
055:            @Override
056:            public abstract boolean canStyle(Layer aLayer);
057:
058:            @Override
059:            protected abstract void refresh();
060:
061:            @Override
062:            public abstract void createControl(Composite parent);
063:
064:            /**
065:             * TODO summary sentence for synchronize ...
066:             * 
067:             */
068:            public abstract void synchronize();
069:
070:            /**
071:             * TODO summary sentence for setLayout ...
072:             * 
073:             * @param parent
074:             */
075:            protected void setLayout(Composite parent) {
076:                RowLayout layout = new RowLayout();
077:                layout.pack = false;
078:                layout.wrap = true;
079:                layout.type = SWT.HORIZONTAL;
080:                layout.fill = true;
081:                layout.marginLeft = 0;
082:                layout.marginRight = 0;
083:                layout.marginTop = 0;
084:                layout.marginBottom = 0;
085:                layout.spacing = 0;
086:                parent.setLayout(layout);
087:            }
088:
089:            /**
090:             * Retrieves the style object from the style blackboard.
091:             * 
092:             * @return Style
093:             */
094:            protected Style getStyle() {
095:                Layer layer = getLayer();
096:                assert (canStyle(layer));
097:                // TODO: Ensure framework does not show me when I can't handle this
098:                // layer
099:                // TODO: Stop commenting in the first person, as though I am the 
100:                // class.  It's creepy.
101:                Style style = (Style) getStyleBlackboard().get(SLDContent.ID);
102:
103:                // if no style information, create default
104:                if (style == null) {
105:                    // TODO: Why do "I" have to do this, can't the framework deal?
106:                    // (It could if I advertise that I deal with SLDContentID type?)
107:                    style = SLDContent.createDefaultStyle();
108:                    getStyleBlackboard().put(SLDContent.ID, style);
109:                    // XXX: This may throw out an event and cause some debugging grief?
110:                }
111:                return style;
112:            }
113:
114:            /**
115:             * Construct a subpart labeled with the provided tag.
116:             * <p>
117:             * Creates a composite with a grid layout of the specifed columns,
118:             * and a label with text from label.
119:             * </p>
120:             * @param parent
121:             * @param label
122:             * @return Composite with one label 
123:             */
124:            public static Composite subpart(Composite parent, String label) {
125:                Composite subpart = new Composite(parent, SWT.NONE);
126:                RowLayout across = new RowLayout();
127:                across.type = SWT.HORIZONTAL;
128:                across.wrap = true;
129:                across.pack = true;
130:                across.fill = true;
131:                across.marginBottom = 1;
132:                across.marginRight = 2;
133:
134:                subpart.setLayout(across);
135:
136:                Label labell = new Label(subpart, SWT.RIGHT);
137:                labell.setText(label);
138:
139:                RowData data = new RowData();
140:                data.width = 40;
141:                //check to see if width is not enough space
142:                GC gc = new GC(parent.getParent());
143:                gc.setFont(parent.getParent().getFont());
144:                FontMetrics fontMetrics = gc.getFontMetrics();
145:                gc.dispose();
146:                int labelWidth = Dialog.convertWidthInCharsToPixels(
147:                        fontMetrics, labell.getText().length() + 1);
148:                if (labelWidth > data.width) {
149:                    data.width = labelWidth;
150:                }
151:                // TODO: adjust the methods that call this one to keep a consistent
152:                // width (otherwise they're misaligned)
153:                data.height = 10;
154:                labell.setLayoutData(data);
155:
156:                return subpart;
157:            }
158:
159:            /**
160:             * Morph a text ModifyEvent into a SelectionEvent as best we can.
161:             * <p>
162:             * This may be a bad abuse of the event system, it appears to be in
163:             * use because we are too lazy to specify a new event type for style
164:             * modification.
165:             * </p>
166:             * <p>
167:             * However this does seem to be in keeping with the purpose of SelectionEvent
168:             * it already isolates out code from TypedEvents by providing a summary of what
169:             * changed in which widet.
170:             * </p>
171:             * @param e
172:             * @return A SelectionEvent based on the provided modify event
173:             */
174:            public static SelectionEvent selectionEvent(final ModifyEvent e) {
175:                Event event = new Event();
176:                event.widget = e.widget;
177:                event.data = e.data;
178:                event.display = e.display;
179:                event.time = e.time;
180:                return new SelectionEvent(event) {
181:                    /** <code>serialVersionUID</code> field */
182:                    private static final long serialVersionUID = 6544345585295778029L;
183:
184:                    @Override
185:                    public Object getSource() {
186:                        return e.getSource();
187:                    }
188:                };
189:            };
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.