svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / AppSymbolPreferences.java @ 40558
History | View | Annotate | Download (7.34 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 3
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/* gvSIG. Geographic Information System of the Valencian Government
|
25 |
*
|
26 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
27 |
* of the Valencian Government (CIT)
|
28 |
*
|
29 |
* This program is free software; you can redistribute it and/or
|
30 |
* modify it under the terms of the GNU General Public License
|
31 |
* as published by the Free Software Foundation; either version 2
|
32 |
* of the License, or (at your option) any later version.
|
33 |
*
|
34 |
* This program is distributed in the hope that it will be useful,
|
35 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
36 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
37 |
* GNU General Public License for more details.
|
38 |
*
|
39 |
* You should have received a copy of the GNU General Public License
|
40 |
* along with this program; if not, write to the Free Software
|
41 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
42 |
* MA 02110-1301, USA.
|
43 |
*
|
44 |
*/
|
45 |
|
46 |
/*
|
47 |
* AUTHORS (In addition to CIT):
|
48 |
* 2009 {} {{Task}}
|
49 |
*/
|
50 |
package org.gvsig.app.gui.preferencespage; |
51 |
|
52 |
import java.awt.Color; |
53 |
import java.awt.Font; |
54 |
import java.io.File; |
55 |
|
56 |
import org.gvsig.andami.PluginServices; |
57 |
import org.gvsig.fmap.mapcontext.rendering.symbols.CartographicSupport; |
58 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolPreferences; |
59 |
import org.gvsig.tools.dynobject.DynObject; |
60 |
|
61 |
/**
|
62 |
* Default {@link SymbolPreferences} implementation based on object attributes.
|
63 |
*
|
64 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team
|
65 |
*/
|
66 |
public class AppSymbolPreferences implements SymbolPreferences { |
67 |
private static final String SYMBOL_COLOR = "defaultSymbolColor"; |
68 |
private static final String SYMBOL_FILL_COLOR = "defaultSymbolFillColor"; |
69 |
private static final String SYMBOL_FILL_COLOR_ALEATORY = "defaultSymbolFillColorAleatory"; |
70 |
private static final String SYMBOL_FONT = "defaultSymbolFont"; |
71 |
private static final String SYMBOL_LIBRARY_PATH = "symbolLibraryPath"; |
72 |
|
73 |
private DynObject values = null; |
74 |
|
75 |
private String symbolFileExtension = ".gvssym"; |
76 |
private Color defaultSymbolColor; |
77 |
private Color defaultSymbolFillColor; |
78 |
private boolean defaultSymbolFillColorAleatory; |
79 |
private Font defaultSymbolFont; |
80 |
private String symbolLibraryPath; |
81 |
|
82 |
/**
|
83 |
* The unit that will be used when creating new symbols with Cartographic
|
84 |
* support.
|
85 |
*/
|
86 |
private int defaultCartographicSupportMeasureUnit = -1; |
87 |
|
88 |
/**
|
89 |
* The reference system that will be used when creating new symbols with
|
90 |
* Cartographic support.
|
91 |
*/
|
92 |
private int defaultCartographicSupportReferenceSystem = CartographicSupport.WORLD; |
93 |
|
94 |
public AppSymbolPreferences() {
|
95 |
values = PluginServices.getPluginServices(this).getPluginProperties();
|
96 |
initDefaults(); |
97 |
} |
98 |
|
99 |
private void initDefaults() { |
100 |
resetDefaultSymbolColor(); |
101 |
resetDefaultSymbolFillColor(); |
102 |
resetDefaultSymbolFillColorAleatory(); |
103 |
resetSymbolLibraryPath(); |
104 |
resetDefaultSymbolFont(); |
105 |
|
106 |
if(getDefaultSymbolFont() == null) |
107 |
setDefaultSymbolFont(defaultSymbolFont); |
108 |
if(getDefaultSymbolColor() == null) |
109 |
setDefaultSymbolColor(defaultSymbolColor); |
110 |
if(getDefaultSymbolFillColor() == null) |
111 |
setDefaultSymbolFillColor(defaultSymbolFillColor); |
112 |
if(getSymbolLibraryPath() == null) |
113 |
setSymbolLibraryPath(symbolLibraryPath); |
114 |
setSymbolFileExtension(symbolFileExtension); |
115 |
setDefaultCartographicSupportMeasureUnit(defaultCartographicSupportMeasureUnit); |
116 |
setDefaultCartographicSupportReferenceSystem(defaultCartographicSupportReferenceSystem); |
117 |
} |
118 |
|
119 |
public String getSymbolFileExtension() { |
120 |
return symbolFileExtension;
|
121 |
} |
122 |
|
123 |
public void setSymbolFileExtension(String symbolFileExtension) { |
124 |
this.symbolFileExtension = symbolFileExtension;
|
125 |
} |
126 |
|
127 |
public String getSymbolLibraryPath() { |
128 |
return (String)values.getDynValue(SYMBOL_LIBRARY_PATH); |
129 |
} |
130 |
|
131 |
public void setSymbolLibraryPath(String symbolLibraryPath) { |
132 |
values.setDynValue(SYMBOL_LIBRARY_PATH, symbolLibraryPath); |
133 |
PluginServices.getPluginServices(this).savePluginProperties();
|
134 |
} |
135 |
|
136 |
public Color getDefaultSymbolColor() { |
137 |
return (Color)values.getDynValue(SYMBOL_COLOR); |
138 |
} |
139 |
|
140 |
public void setDefaultSymbolColor(Color symbolColor) { |
141 |
values.setDynValue(SYMBOL_COLOR, symbolColor); |
142 |
PluginServices.getPluginServices(this).savePluginProperties();
|
143 |
} |
144 |
|
145 |
public Color getDefaultSymbolFillColor() { |
146 |
return (Color)values.getDynValue(SYMBOL_FILL_COLOR); |
147 |
} |
148 |
|
149 |
public void setDefaultSymbolFillColor(Color symbolFillColor) { |
150 |
values.setDynValue(SYMBOL_FILL_COLOR, symbolFillColor); |
151 |
PluginServices.getPluginServices(this).savePluginProperties();
|
152 |
} |
153 |
|
154 |
public boolean isDefaultSymbolFillColorAleatory() { |
155 |
if(values.getDynValue(SYMBOL_FILL_COLOR_ALEATORY) == null) { |
156 |
setDefaultSymbolFillColorAleatory(defaultSymbolFillColorAleatory); |
157 |
} |
158 |
return (Boolean)values.getDynValue(SYMBOL_FILL_COLOR_ALEATORY); |
159 |
} |
160 |
|
161 |
public void setDefaultSymbolFillColorAleatory(boolean defaultSymbolFillColorAleatory) { |
162 |
values.setDynValue(SYMBOL_FILL_COLOR_ALEATORY, defaultSymbolFillColorAleatory); |
163 |
PluginServices.getPluginServices(this).savePluginProperties();
|
164 |
} |
165 |
|
166 |
public Font getDefaultSymbolFont() { |
167 |
return (Font)values.getDynValue(SYMBOL_FONT); |
168 |
} |
169 |
|
170 |
public void setDefaultSymbolFont(Font defaultSymbolFont) { |
171 |
values.setDynValue(SYMBOL_FONT, defaultSymbolFont); |
172 |
PluginServices.getPluginServices(this).savePluginProperties();
|
173 |
} |
174 |
|
175 |
|
176 |
public int getDefaultCartographicSupportMeasureUnit() { |
177 |
return defaultCartographicSupportMeasureUnit;
|
178 |
} |
179 |
|
180 |
public void setDefaultCartographicSupportMeasureUnit( |
181 |
int defaultCartographicSupportMeasureUnit) {
|
182 |
this.defaultCartographicSupportMeasureUnit =
|
183 |
defaultCartographicSupportMeasureUnit; |
184 |
} |
185 |
|
186 |
public int getDefaultCartographicSupportReferenceSystem() { |
187 |
return defaultCartographicSupportReferenceSystem;
|
188 |
} |
189 |
|
190 |
public void setDefaultCartographicSupportReferenceSystem( |
191 |
int defaultCartographicSupportReferenceSystem) {
|
192 |
this.defaultCartographicSupportReferenceSystem =
|
193 |
defaultCartographicSupportReferenceSystem; |
194 |
} |
195 |
|
196 |
public void resetDefaultSymbolColor() { |
197 |
defaultSymbolColor = Color.GRAY;
|
198 |
} |
199 |
|
200 |
public void resetDefaultSymbolFillColor() { |
201 |
defaultSymbolFillColor = new Color(60, 235, 235); |
202 |
} |
203 |
|
204 |
public void resetDefaultSymbolFillColorAleatory() { |
205 |
defaultSymbolFillColorAleatory = true;
|
206 |
} |
207 |
|
208 |
public void resetDefaultSymbolFont() { |
209 |
defaultSymbolFont = new Font("Serif", Font.PLAIN, 8); |
210 |
} |
211 |
|
212 |
public void resetSymbolLibraryPath() { |
213 |
|
214 |
symbolLibraryPath = PluginServices.getPluginServices(this).getPluginHomeFolder().getAbsolutePath()
|
215 |
+ File.separator + "Symbols"; |
216 |
|
217 |
} |
218 |
} |