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


001:        /* uDig - User Friendly Desktop Internet GIS client
002:         * http://udig.refractions.net
003:         * (C) 2004, Refractions Research Inc.
004:         *
005:         * This library is free software; you can redistribute it and/or
006:         * modify it under the terms of the GNU Lesser General Public
007:         * License as published by the Free Software Foundation;
008:         * version 2.1 of the License.
009:         *
010:         * This library is distributed in the hope that it will be useful,
011:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         * Lesser General Public License for more details.
014:         */
015:        package net.refractions.udig.tools.edit.preferences;
016:
017:        import java.awt.Color;
018:
019:        import net.refractions.udig.project.internal.ProjectPlugin;
020:        import net.refractions.udig.tools.edit.EditPlugin;
021:        import net.refractions.udig.tools.edit.support.SnapBehaviour;
022:
023:        import org.eclipse.jface.preference.IPreferenceStore;
024:        import org.eclipse.jface.preference.PreferenceConverter;
025:        import org.eclipse.swt.graphics.RGB;
026:
027:        /**
028:         * Provides help for obtaining values that are preferences or will be.
029:         * 
030:         * @author jones
031:         * @since 1.1.0
032:         */
033:        public class PreferenceUtil {
034:
035:            protected static PreferenceUtil instance = new PreferenceUtil();
036:
037:            protected PreferenceUtil() {
038:                //singleton class
039:                // only tests should override this.
040:            }
041:
042:            public static PreferenceUtil instance() {
043:                return instance;
044:            }
045:
046:            IPreferenceStore store = EditPlugin.getDefault()
047:                    .getPreferenceStore();
048:
049:            /**
050:             * Returns the radius of a vertex 
051:             *
052:             * @return
053:             */
054:            public int getVertexRadius() {
055:                return store.getInt(PreferenceConstants.P_VERTEX_SIZE);
056:            }
057:
058:            /**
059:             * Returns the color used to draw the outline of geoms on the EditBlackboard.
060:             *
061:             * @return Returns the color used to draw the outline of geoms on the EditBlackboard.
062:             */
063:            public Color getDrawGeomsLine() {
064:                return getDrawSelectionFillColor();
065:            }
066:
067:            /**
068:             * Returns the color used to draw the boxes around vertices.
069:             *
070:             * @return the color used to draw the boxes around vertices.
071:             */
072:            public Color getDrawVertexLineColor() {
073:                String preferenceID = PreferenceConstants.P_VERTEX_OUTLINE_COLOR;
074:                return getColor(store, preferenceID);
075:            }
076:
077:            private Color getColor(IPreferenceStore store2, String preferenceID) {
078:                RGB rgb = PreferenceConverter.getColor(store2, preferenceID);
079:                Color color = new Color(rgb.red, rgb.green, rgb.blue);
080:                return color;
081:            }
082:
083:            /**
084:             * Returns the color used to fill selected vertices.
085:             *
086:             * @return the color used to fill selected vertices.
087:             */
088:            public Color getDrawSelectionFillColor() {
089:                return getColor(
090:                        ProjectPlugin.getPlugin().getPreferenceStore(),
091:                        net.refractions.udig.project.preferences.PreferenceConstants.P_SELECTION_COLOR);
092:            }
093:
094:            /**
095:             * Sets the radius used for post-snapping.
096:             *
097:             * @param newRadius
098:             */
099:            public void setSnappingRadius(int newRadius) {
100:                store.setValue(PreferenceConstants.P_SNAP_RADIUS, newRadius);
101:            }
102:
103:            /**
104:             * Gets the radius used for post-snapping.
105:             *  @return the radius used for post-snapping
106:             */
107:            public int getSnappingRadius() {
108:                return store.getInt(PreferenceConstants.P_SNAP_RADIUS);
109:            }
110:
111:            /**
112:             * Returns the color used to draw the shape to show the PostSnapping area.
113:             *
114:             * @return Returns the color used to draw the shape to show the PostSnapping area.
115:             */
116:            public Color getFeedbackColor() {
117:                return getColor(store, PreferenceConstants.P_SNAP_CIRCLE_COLOR);
118:            }
119:
120:            /**
121:             * Returns the color used to draw the selection area.
122:             * 
123:             * @return the color used to draw the selection area.
124:             */
125:            public Color getSelectionColor() {
126:                return getColor(
127:                        ProjectPlugin.getPlugin().getPreferenceStore(),
128:                        net.refractions.udig.project.preferences.PreferenceConstants.P_SELECTION_COLOR);
129:            }
130:
131:            Color drawGeomsFill = new Color(144, 255, 144, 100);
132:
133:            /**
134:             * Returns the color used to fill the geoms on the EditBlackboard.
135:             *
136:             * @return Returns the color used to fill the geoms on the EditBlackboard.
137:             */
138:            public Color getDrawGeomsFill() {
139:                return drawGeomsFill;
140:            }
141:
142:            /**
143:             * Returns the color used to fill the non-selected vertices.
144:             *
145:             * @return Returns the color used to fill the non-selected vertices.
146:             */
147:            public Color getDrawVertexFillColor() {
148:                return drawGeomsFill;
149:            }
150:
151:            /**
152:             * Returns the current preference for snap behaviour.
153:             *
154:             * @return the current preference for snap behaviour.
155:             */
156:            public SnapBehaviour getSnapBehaviour() {
157:                String preference = store
158:                        .getString(PreferenceConstants.P_SNAP_BEHAVIOUR);
159:                if (preference.equals(SnapBehaviour.OFF.toString()))
160:                    return SnapBehaviour.OFF;
161:                if (preference.equals(SnapBehaviour.SELECTED.toString()))
162:                    return SnapBehaviour.SELECTED;
163:                if (preference.equals(SnapBehaviour.CURRENT_LAYER.toString()))
164:                    return SnapBehaviour.CURRENT_LAYER;
165:                if (preference.equals(SnapBehaviour.ALL_LAYERS.toString()))
166:                    return SnapBehaviour.ALL_LAYERS;
167:                if (preference.equals(SnapBehaviour.GRID.toString()))
168:                    return SnapBehaviour.GRID;
169:
170:                return SnapBehaviour.OFF;
171:            }
172:
173:            public void setSnapBehaviour(SnapBehaviour behaviour) {
174:                store.putValue(PreferenceConstants.P_SNAP_BEHAVIOUR, behaviour
175:                        .toString());
176:            }
177:
178:            /**
179:             * Returns true if selected features should be hidden upon selection.  This can be quite expensive.
180:             *
181:             * @return
182:             */
183:            public boolean hideSelectedLayers() {
184:                return store
185:                        .getBoolean(PreferenceConstants.P_HIDE_SELECTED_FEATURES);
186:            }
187:
188:            public boolean isAdvancedEditingActive() {
189:                return store.getBoolean(PreferenceConstants.P_ADVANCED_ACTIVE);
190:            }
191:
192:            public void setAdvancedEditingActive(boolean b) {
193:                store.setValue(PreferenceConstants.P_ADVANCED_ACTIVE, b);
194:            }
195:
196:            public short getMessageDisplayDelay() {
197:                return 2000;
198:            }
199:
200:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.