Revision 43100 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/ProjectPreferences.java
ProjectPreferences.java | ||
---|---|---|
69 | 69 |
|
70 | 70 |
private int defaultDistanceArea = -1; |
71 | 71 |
|
72 |
private final PluginServices plugin; |
|
73 |
private final DynObject pluginPreferences; |
|
74 |
|
|
72 | 75 |
public ProjectPreferences() { |
76 |
this.plugin = PluginsLocator.getManager().getPlugin(this); |
|
77 |
this.pluginPreferences = plugin.getPluginProperties(); |
|
73 | 78 |
} |
74 | 79 |
|
75 | 80 |
/** |
... | ... | |
80 | 85 |
public void setDefaultProjection(IProjection defaultProjection) { |
81 | 86 |
this.defaultProjection = defaultProjection; |
82 | 87 |
if (defaultProjection != null) { |
83 |
PluginServices plugin = PluginServices.getPluginServices("org.gvsig.app"); |
|
84 | 88 |
XMLEntity xml = plugin.getPersistentXML(); |
85 | 89 |
xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, defaultProjection.getAbrev()); |
86 | 90 |
} |
... | ... | |
94 | 98 |
|
95 | 99 |
public IProjection getDefaultProjection() { |
96 | 100 |
if (this.defaultProjection == null) { |
97 |
PluginServices plugin = PluginServices.getPluginServices("org.gvsig.app"); |
|
98 | 101 |
XMLEntity xml = plugin.getPersistentXML(); |
99 | 102 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) { |
100 | 103 |
String projCode = xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME); |
... | ... | |
127 | 130 |
*/ |
128 | 131 |
public void setDefaultSelectionColor(Color color) { |
129 | 132 |
defaultSelectionColor = color; |
130 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
131 |
XMLEntity xml = ps.getPersistentXML(); |
|
133 |
XMLEntity xml = plugin.getPersistentXML(); |
|
132 | 134 |
xml.putProperty("DefaultSelectionColor", StringUtilities.color2String(color)); |
133 | 135 |
} |
134 | 136 |
|
... | ... | |
139 | 141 |
* @return java.awt.Color |
140 | 142 |
*/ |
141 | 143 |
public Color getDefaultSelectionColor() { |
142 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
143 |
XMLEntity xml = ps.getPersistentXML(); |
|
144 |
XMLEntity xml = plugin.getPersistentXML(); |
|
144 | 145 |
if (xml.contains("DefaultSelectionColor")) { |
145 | 146 |
defaultSelectionColor = StringUtilities.string2Color(xml |
146 | 147 |
.getStringProperty("DefaultSelectionColor")); |
... | ... | |
159 | 160 |
|
160 | 161 |
public void setDefaultViewBackColor(Color color) { |
161 | 162 |
defaultViewBackColor = color; |
162 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
163 |
XMLEntity xml = ps.getPersistentXML(); |
|
163 |
XMLEntity xml = plugin.getPersistentXML(); |
|
164 | 164 |
xml.putProperty("DefaultViewBackColor", StringUtilities.color2String(color)); |
165 | 165 |
} |
166 | 166 |
|
167 | 167 |
public Color getDefaultOverviewBackColor() { |
168 |
XMLEntity xml = PluginServices.getPluginServices("org.gvsig.app") |
|
169 |
.getPersistentXML(); |
|
168 |
XMLEntity xml = plugin.getPersistentXML(); |
|
170 | 169 |
if (xml.contains("defaultOverviewBackColor")) { |
171 | 170 |
defaultOverviewBackColor = StringUtilities.string2Color(xml |
172 | 171 |
.getStringProperty("defaultOverviewBackColor")); |
... | ... | |
187 | 186 |
*/ |
188 | 187 |
public int getDefaultMapUnits() { |
189 | 188 |
if (defaultMapUnits == -1) { |
190 |
XMLEntity xml = PluginServices.getPluginServices( |
|
191 |
"org.gvsig.app").getPersistentXML(); |
|
189 |
XMLEntity xml = plugin.getPersistentXML(); |
|
192 | 190 |
if (xml.contains("DefaultMapUnits")) { |
193 | 191 |
defaultMapUnits = xml.getIntProperty("DefaultMapUnits"); |
194 | 192 |
} else { |
... | ... | |
217 | 215 |
*/ |
218 | 216 |
public int getDefaultDistanceUnits() { |
219 | 217 |
if (defaultDistanceUnits == -1) { |
220 |
XMLEntity xml = PluginServices.getPluginServices( |
|
221 |
"org.gvsig.app").getPersistentXML(); |
|
218 |
XMLEntity xml = plugin.getPersistentXML(); |
|
222 | 219 |
if (xml.contains("DefaultDistanceUnits")) { |
223 | 220 |
defaultDistanceUnits = xml |
224 | 221 |
.getIntProperty("DefaultDistanceUnits"); |
... | ... | |
248 | 245 |
*/ |
249 | 246 |
public int getDefaultDistanceArea() { |
250 | 247 |
if (defaultDistanceArea == -1) { |
251 |
XMLEntity xml = PluginServices.getPluginServices( |
|
252 |
"org.gvsig.app").getPersistentXML(); |
|
248 |
XMLEntity xml = plugin.getPersistentXML(); |
|
253 | 249 |
if (xml.contains("DefaultDistanceArea")) { |
254 | 250 |
defaultDistanceArea = xml |
255 | 251 |
.getIntProperty("DefaultDistanceArea"); |
... | ... | |
278 | 274 |
*/ |
279 | 275 |
public void setDefaultMapUnits(int mapUnits) { |
280 | 276 |
defaultMapUnits = mapUnits; |
281 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
282 |
XMLEntity xml = ps.getPersistentXML(); |
|
277 |
XMLEntity xml = plugin.getPersistentXML(); |
|
283 | 278 |
xml.putProperty("DefaultMapUnits", mapUnits); |
284 | 279 |
} |
285 | 280 |
|
... | ... | |
290 | 285 |
*/ |
291 | 286 |
public void setDefaultDistanceUnits(int distanceUnits) { |
292 | 287 |
defaultDistanceUnits = distanceUnits; |
293 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
294 |
XMLEntity xml = ps.getPersistentXML(); |
|
288 |
XMLEntity xml = plugin.getPersistentXML(); |
|
295 | 289 |
xml.putProperty("DefaultDistanceUnits", distanceUnits); |
296 | 290 |
} |
297 | 291 |
|
... | ... | |
302 | 296 |
*/ |
303 | 297 |
public void setDefaultDistanceArea(int distanceArea) { |
304 | 298 |
defaultDistanceArea = distanceArea; |
305 |
PluginServices ps = PluginServices.getPluginServices(this); |
|
306 |
XMLEntity xml = ps.getPersistentXML(); |
|
299 |
XMLEntity xml = plugin.getPersistentXML(); |
|
307 | 300 |
xml.putProperty("DefaultDistanceArea", distanceArea); |
308 | 301 |
} |
309 | 302 |
|
310 | 303 |
public boolean getAddNewLayersInInvisibleMode() { |
311 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
312 |
DynObject props = plugin.getPluginProperties(); |
|
313 |
XMLEntity xml = plugin.getPersistentXML(); |
|
314 |
|
|
315 |
Boolean addNewLayersInInvisibleMode = (Boolean) props.getDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE); |
|
304 |
Boolean addNewLayersInInvisibleMode = (Boolean) this.pluginPreferences.getDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE); |
|
316 | 305 |
if (addNewLayersInInvisibleMode == null) { |
306 |
XMLEntity xml = plugin.getPersistentXML(); |
|
317 | 307 |
if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE)) { |
318 | 308 |
addNewLayersInInvisibleMode = xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE); |
319 | 309 |
} else { |
320 | 310 |
addNewLayersInInvisibleMode = false; |
321 | 311 |
} |
322 |
props.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
|
|
312 |
this.pluginPreferences.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode);
|
|
323 | 313 |
} |
324 | 314 |
return BooleanUtils.isTrue(addNewLayersInInvisibleMode); |
325 | 315 |
} |
326 | 316 |
|
327 | 317 |
public void setAddNewLayersInInvisibleMode(boolean addNewLayersInInvisibleMode) { |
328 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
329 |
DynObject props = plugin.getPluginProperties(); |
|
330 |
props.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode); |
|
318 |
this.pluginPreferences.setDynValue(ADD_NEW_LAYERS_IN_INVISIBLE_MODE, addNewLayersInInvisibleMode); |
|
331 | 319 |
} |
332 | 320 |
|
333 |
|
|
334 | 321 |
public boolean getOpenWithANewMaximizedView() { |
335 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
336 |
DynObject props = plugin.getPluginProperties(); |
|
337 |
XMLEntity xml = plugin.getPersistentXML(); |
|
338 |
|
|
339 |
Boolean openWithANewMaximizedView = (Boolean) props.getDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW); |
|
322 |
Boolean openWithANewMaximizedView = (Boolean) this.pluginPreferences.getDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW); |
|
340 | 323 |
if (openWithANewMaximizedView == null) { |
324 |
XMLEntity xml = plugin.getPersistentXML(); |
|
341 | 325 |
if (xml.contains(OPEN_WITH_A_NEW_MAXIMIZED_VIEW)) { |
342 | 326 |
openWithANewMaximizedView = xml.getBooleanProperty(OPEN_WITH_A_NEW_MAXIMIZED_VIEW); |
343 | 327 |
} else { |
344 | 328 |
openWithANewMaximizedView = true; |
345 | 329 |
} |
346 |
props.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
|
|
330 |
this.pluginPreferences.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView);
|
|
347 | 331 |
} |
348 | 332 |
return BooleanUtils.isTrue(openWithANewMaximizedView); |
349 | 333 |
} |
350 | 334 |
|
351 | 335 |
public void setOpenWithANewMaximizedView(boolean openWithANewMaximizedView) { |
352 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
353 |
DynObject props = plugin.getPluginProperties(); |
|
354 |
props.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView); |
|
336 |
this.pluginPreferences.setDynValue(OPEN_WITH_A_NEW_MAXIMIZED_VIEW, openWithANewMaximizedView); |
|
355 | 337 |
} |
356 | 338 |
|
357 |
|
|
358 | 339 |
public boolean getKeepScaleOnResizing() { |
359 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
360 |
DynObject props = plugin.getPluginProperties(); |
|
361 |
XMLEntity xml = plugin.getPersistentXML(); |
|
362 |
|
|
363 |
Boolean keepScaleOnResizing = (Boolean) props.getDynValue(KEEP_SCALE_ON_RESIZING); |
|
340 |
Boolean keepScaleOnResizing = (Boolean) this.pluginPreferences.getDynValue(KEEP_SCALE_ON_RESIZING); |
|
364 | 341 |
if (keepScaleOnResizing == null) { |
342 |
XMLEntity xml = plugin.getPersistentXML(); |
|
365 | 343 |
if (xml.contains(KEEP_SCALE_ON_RESIZING)) { |
366 | 344 |
keepScaleOnResizing = xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING); |
367 | 345 |
} else { |
368 | 346 |
keepScaleOnResizing = false; |
369 | 347 |
} |
370 |
props.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
|
|
348 |
this.pluginPreferences.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing);
|
|
371 | 349 |
} |
372 | 350 |
return BooleanUtils.isTrue(keepScaleOnResizing); |
373 | 351 |
} |
374 | 352 |
|
375 | 353 |
public void setKeepScaleOnResizing(boolean keepScaleOnResizing) { |
376 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
377 |
DynObject props = plugin.getPluginProperties(); |
|
378 |
props.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing); |
|
354 |
this.pluginPreferences.setDynValue(KEEP_SCALE_ON_RESIZING, keepScaleOnResizing); |
|
379 | 355 |
} |
380 | 356 |
|
381 | 357 |
public double getZoomInFactor() { |
382 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
383 |
DynObject props = plugin.getPluginProperties(); |
|
384 |
XMLEntity xml = plugin.getPersistentXML(); |
|
385 |
|
|
386 |
Double zoomInFactor = (Double) props.getDynValue(ZOOM_IN_FACTOR); |
|
358 |
Double zoomInFactor = (Double) this.pluginPreferences.getDynValue(ZOOM_IN_FACTOR); |
|
387 | 359 |
if (zoomInFactor == null) { |
360 |
XMLEntity xml = plugin.getPersistentXML(); |
|
388 | 361 |
if (xml.contains(ZOOM_IN_FACTOR)) { |
389 | 362 |
zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR); |
390 | 363 |
} else { |
391 | 364 |
zoomInFactor = MapContext.ZOOMINFACTOR; |
392 | 365 |
} |
393 |
props.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
|
|
366 |
this.pluginPreferences.setDynValue(ZOOM_IN_FACTOR, zoomInFactor);
|
|
394 | 367 |
} |
395 | 368 |
return zoomInFactor; |
396 | 369 |
} |
397 |
|
|
370 |
|
|
398 | 371 |
public void setZoomInFactor(double zoomInFactor) { |
399 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
400 |
DynObject props = plugin.getPluginProperties(); |
|
401 |
props.setDynValue(ZOOM_IN_FACTOR, zoomInFactor); |
|
372 |
this.pluginPreferences.setDynValue(ZOOM_IN_FACTOR, zoomInFactor); |
|
402 | 373 |
} |
403 | 374 |
|
404 | 375 |
public double getZoomOutFactor() { |
405 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
406 |
DynObject props = plugin.getPluginProperties(); |
|
407 |
XMLEntity xml = plugin.getPersistentXML(); |
|
408 |
|
|
409 |
Double zoomOutFactor = (Double) props.getDynValue(ZOOM_OUT_FACTOR); |
|
376 |
Double zoomOutFactor = (Double) this.pluginPreferences.getDynValue(ZOOM_OUT_FACTOR); |
|
410 | 377 |
if (zoomOutFactor == null) { |
378 |
XMLEntity xml = plugin.getPersistentXML(); |
|
411 | 379 |
if (xml.contains(ZOOM_OUT_FACTOR)) { |
412 | 380 |
zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR); |
413 | 381 |
} else { |
414 | 382 |
zoomOutFactor = MapContext.ZOOMINFACTOR; |
415 | 383 |
} |
416 |
props.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
|
|
384 |
this.pluginPreferences.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor);
|
|
417 | 385 |
} |
418 | 386 |
return zoomOutFactor; |
419 | 387 |
} |
420 |
|
|
388 |
|
|
421 | 389 |
public void setZoomOutFactor(double zoomOutFactor) { |
422 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(this); |
|
423 |
DynObject props = plugin.getPluginProperties(); |
|
424 |
props.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor); |
|
390 |
this.pluginPreferences.setDynValue(ZOOM_OUT_FACTOR, zoomOutFactor); |
|
425 | 391 |
} |
426 | 392 |
|
393 |
public boolean getHideLegendInToCOfNonVisibleLayers() { |
|
394 |
Boolean hideLegendInToCOfNonVisibleLayers = (Boolean)this.pluginPreferences.getDynValue("hideLegendInToCOfNonVisibleLayers"); |
|
395 |
return BooleanUtils.toBooleanDefaultIfNull(hideLegendInToCOfNonVisibleLayers,true); |
|
396 |
} |
|
427 | 397 |
|
398 |
public void setHideLegendInToCOfNonVisibleLayers(boolean hideLegendInToCOfNonVisibleLayers) { |
|
399 |
this.pluginPreferences.setDynValue("hideLegendInToCOfNonVisibleLayers", hideLegendInToCOfNonVisibleLayers); |
|
400 |
} |
|
401 |
|
|
428 | 402 |
} |
Also available in: Unified diff