root / branches / v10 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / preferencespage / ViewPage.java @ 20816
History | View | Annotate | Download (18.9 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
|
42 |
/* CVS MESSAGES:
|
43 |
*
|
44 |
* $Id: ViewPage.java 20816 2008-05-21 09:04:07Z vcaballero $
|
45 |
* $Log$
|
46 |
* Revision 1.4.4.9 2007-02-16 10:30:36 caballero
|
47 |
* factor 0 incorrecto
|
48 |
*
|
49 |
* Revision 1.4.4.8 2006/11/22 01:45:47 luisw2
|
50 |
* Recuperados cambios de la RC2 que normalizan la gesti?n de CRSs
|
51 |
*
|
52 |
* Revision 1.4.4.7 2006/11/15 00:08:09 jjdelcerro
|
53 |
* *** empty log message ***
|
54 |
*
|
55 |
* Revision 1.21 2006/11/08 10:57:55 jaume
|
56 |
* remove unecessary imports
|
57 |
*
|
58 |
* Revision 1.20 2006/10/25 08:34:06 jmvivo
|
59 |
* LLamado al PluginServices.getText para las unidades de medida del los combo
|
60 |
*
|
61 |
* Revision 1.19 2006/10/04 07:23:31 jaume
|
62 |
* refactored ambiguous methods and field names and added some more features for preference pages
|
63 |
*
|
64 |
* Revision 1.18 2006/10/03 09:52:38 jaume
|
65 |
* restores to meters
|
66 |
*
|
67 |
* Revision 1.17 2006/10/03 09:19:12 jaume
|
68 |
* *** empty log message ***
|
69 |
*
|
70 |
* Revision 1.16 2006/10/03 07:26:08 jaume
|
71 |
* *** empty log message ***
|
72 |
*
|
73 |
* Revision 1.15 2006/10/02 15:30:29 jaume
|
74 |
* *** empty log message ***
|
75 |
*
|
76 |
* Revision 1.14 2006/10/02 13:52:34 jaume
|
77 |
* organize impots
|
78 |
*
|
79 |
* Revision 1.13 2006/10/02 13:38:23 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.12 2006/10/02 11:49:23 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.11 2006/09/28 12:04:21 jaume
|
86 |
* default selection color now configurable
|
87 |
*
|
88 |
* Revision 1.10 2006/09/25 10:17:15 caballero
|
89 |
* Projection
|
90 |
*
|
91 |
* Revision 1.9 2006/09/15 10:41:30 caballero
|
92 |
* extensibilidad de documentos
|
93 |
*
|
94 |
* Revision 1.8 2006/09/14 15:43:48 jaume
|
95 |
* *** empty log message ***
|
96 |
*
|
97 |
* Revision 1.7 2006/09/14 15:42:38 jaume
|
98 |
* *** empty log message ***
|
99 |
*
|
100 |
* Revision 1.6 2006/09/14 06:57:18 jaume
|
101 |
* *** empty log message ***
|
102 |
*
|
103 |
* Revision 1.5 2006/09/12 15:56:50 jaume
|
104 |
* Default Projection now customizable
|
105 |
*
|
106 |
* Revision 1.4 2006/08/29 07:21:08 cesar
|
107 |
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
|
108 |
*
|
109 |
* Revision 1.3 2006/08/22 12:30:59 jaume
|
110 |
* *** empty log message ***
|
111 |
*
|
112 |
* Revision 1.2 2006/08/22 07:36:04 jaume
|
113 |
* *** empty log message ***
|
114 |
*
|
115 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
116 |
* poder especificar el zoom a aplicar en las vistas
|
117 |
*
|
118 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
119 |
* *** empty log message ***
|
120 |
*
|
121 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
122 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
123 |
*
|
124 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
125 |
* Preferencias
|
126 |
*
|
127 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
128 |
* *** empty log message ***
|
129 |
*
|
130 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
131 |
* *** empty log message ***
|
132 |
*
|
133 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
134 |
* *** empty log message ***
|
135 |
*
|
136 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
137 |
* *** empty log message ***
|
138 |
*
|
139 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
140 |
* *** empty log message ***
|
141 |
*
|
142 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
143 |
* *** empty log message ***
|
144 |
*
|
145 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
146 |
* *** empty log message ***
|
147 |
*
|
148 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
149 |
* *** empty log message ***
|
150 |
*
|
151 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
152 |
* *** empty log message ***
|
153 |
*
|
154 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
155 |
* *** empty log message ***
|
156 |
*
|
157 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
158 |
* *** empty log message ***
|
159 |
*
|
160 |
*
|
161 |
*/
|
162 |
package com.iver.cit.gvsig.gui.preferencespage; |
163 |
|
164 |
import java.awt.Color; |
165 |
import java.util.Enumeration; |
166 |
|
167 |
import javax.swing.ImageIcon; |
168 |
import javax.swing.JCheckBox; |
169 |
import javax.swing.JLabel; |
170 |
import javax.swing.JPanel; |
171 |
import javax.swing.JTextField; |
172 |
import javax.swing.UIManager; |
173 |
import javax.swing.plaf.FontUIResource; |
174 |
|
175 |
import com.iver.andami.PluginServices; |
176 |
import com.iver.andami.preferences.AbstractPreferencePage; |
177 |
import com.iver.andami.preferences.StoreException; |
178 |
import com.iver.cit.gvsig.fmap.MapContext; |
179 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
180 |
import com.iver.cit.gvsig.gui.layout.Attributes; |
181 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
182 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
183 |
import com.iver.cit.gvsig.project.Project; |
184 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
185 |
import com.iver.utiles.StringUtilities; |
186 |
import com.iver.utiles.XMLEntity; |
187 |
import com.iver.utiles.swing.JComboBox; |
188 |
/**
|
189 |
* View document configuration page.
|
190 |
* <b><b>
|
191 |
* Here the user can establish what settings wants to use by default regarding to
|
192 |
* the document View.
|
193 |
*
|
194 |
*
|
195 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
196 |
*/
|
197 |
public class ViewPage extends AbstractPreferencePage { |
198 |
|
199 |
private static final String DEFAULT_PROJECTION_KEY_NAME = "DefaultProjection"; |
200 |
private static final String FACTORY_DEFAULT_PROJECTION = "EPSG:23030"; |
201 |
private static final String ZOOM_IN_FACTOR_KEY_NAME = "ZoomInFactor"; |
202 |
private static final String ZOOM_OUT_FACTOR_KEY_NAME = "ZoomOutFactor"; |
203 |
private static final String ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME = "NewLayersInInvisibleMode"; |
204 |
private static final String KEEP_SCALE_ON_RESIZING_KEY_NAME = "KeepScaleOnResizing"; |
205 |
private static final String DEFAULT_SELECTION_COLOR_KEY_NAME = "DefaultSelectionColor"; |
206 |
private static final String DEFAULT_VIEW_BACK_COLOR_KEY_NAME = "DefaultViewBackColor"; |
207 |
private static final String DEFAULT_DISTANCE_UNITS_KEY_NAME = "DefaultDistanceUnits"; |
208 |
private static final String DEFAULT_DISTANCE_AREA_KEY_NAME = "DefaultDistanceArea"; |
209 |
private static final String DEFAULT_MAP_UNITS_KEY_NAME = "DefaultMapUnits"; |
210 |
/*
|
211 |
* Locator's background color, for when we let it be possible
|
212 |
* private static final String DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME = "DefaultMapOverViewBackColor";
|
213 |
*/
|
214 |
private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0; |
215 |
private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5; |
216 |
private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW; |
217 |
private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE; |
218 |
/*
|
219 |
* Locator's background color, for when we let it be possible
|
220 |
* private static final Color FACTORY_DEFAULT_MAP_OVERVIEW_BACK_COLOR = Color.WHITE;
|
221 |
*/
|
222 |
|
223 |
private static String[] unitsNames = null; |
224 |
|
225 |
private static int FACTORY_DEFAULT_MAP_UNITS; |
226 |
private static int FACTORY_DEFAULT_DISTANCE_UNITS; |
227 |
private static int FACTORY_DEFAULT_DISTANCE_AREA; |
228 |
|
229 |
private JTextField txtZoomInFactor; |
230 |
private JTextField txtZoomOutFactor; |
231 |
protected String id; |
232 |
private ImageIcon icon; |
233 |
//private JLabel lblDefaultProjection;
|
234 |
//private JButton btnChangeProjection;
|
235 |
private String fontName; |
236 |
private JCheckBox chkInvisibleNewLayers; |
237 |
private JCheckBox chkKeepScaleOnResizing; |
238 |
private ColorChooserPanel jccDefaultSelectionColor;
|
239 |
private ColorChooserPanel jccDefaultViewBackColor;
|
240 |
private JComboBox jCmbMapUnits; |
241 |
private JComboBox jCmbDistanceUnits; |
242 |
private JComboBox jCmbDistanceArea; |
243 |
|
244 |
private boolean panelStarted = false; |
245 |
private boolean panelInitialized = false; |
246 |
|
247 |
private CRSSelectPanel jPanelProj = null; |
248 |
|
249 |
/*
|
250 |
* Locator's background color, for when we let it be possible
|
251 |
* private ColorChooserPanel jccDefaultMapOverViewBackColor;
|
252 |
*/
|
253 |
|
254 |
{ |
255 |
Enumeration keys = UIManager.getDefaults().keys(); |
256 |
while (keys.hasMoreElements()) {
|
257 |
Object key = keys.nextElement();
|
258 |
Object value = UIManager.get (key); |
259 |
if (value instanceof FontUIResource) { |
260 |
FontUIResource fur = (FontUIResource) value; |
261 |
fontName = fur.getFontName(); |
262 |
|
263 |
} |
264 |
} |
265 |
|
266 |
String[] unitNames = Attributes.NAMES; |
267 |
for (int i = 0; i < unitNames.length; i++) { |
268 |
if (unitNames[i].equals(PluginServices.getText(this, "Metros"))) { |
269 |
FACTORY_DEFAULT_DISTANCE_UNITS = i; |
270 |
FACTORY_DEFAULT_DISTANCE_AREA = i; |
271 |
FACTORY_DEFAULT_MAP_UNITS = i; |
272 |
|
273 |
break;
|
274 |
} |
275 |
} |
276 |
|
277 |
} |
278 |
|
279 |
/**
|
280 |
* Creates a new panel containing View preferences settings.
|
281 |
*
|
282 |
*/
|
283 |
public ViewPage() {
|
284 |
super();
|
285 |
id = this.getClass().getName();
|
286 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/Vista.png")); |
287 |
} |
288 |
|
289 |
/**
|
290 |
* This method jPanelProj
|
291 |
*
|
292 |
* @return javax.swing.JPanel
|
293 |
*/
|
294 |
private CRSSelectPanel getJPanelProj() {
|
295 |
if (jPanelProj == null) { |
296 |
jPanelProj = CRSSelectPanel.getPanel(Project.getDefaultProjection()); |
297 |
jPanelProj.setPreferredSize(new java.awt.Dimension(330,35)); |
298 |
jPanelProj.addActionListener(new java.awt.event.ActionListener() {
|
299 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
300 |
if (jPanelProj.isOkPressed()) {
|
301 |
Project.setDefaultProjection(jPanelProj.getCurProj()); |
302 |
} |
303 |
} |
304 |
}); |
305 |
|
306 |
} |
307 |
return jPanelProj;
|
308 |
} |
309 |
public void initializeValues() { |
310 |
if (!panelStarted) getPanel();
|
311 |
|
312 |
PluginServices ps = PluginServices.getPluginServices(this);
|
313 |
XMLEntity xml = ps.getPersistentXML(); |
314 |
|
315 |
// Default Projection
|
316 |
String projCode = null; |
317 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
|
318 |
projCode = xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME); |
319 |
} else {
|
320 |
projCode = FACTORY_DEFAULT_PROJECTION; |
321 |
} |
322 |
Project.setDefaultProjection(CRSFactory.getCRS(projCode)); |
323 |
|
324 |
// Adding invisible new layers
|
325 |
if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)) {
|
326 |
chkInvisibleNewLayers.setSelected( |
327 |
xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)); |
328 |
} |
329 |
|
330 |
// Keep scale on resizing
|
331 |
if (xml.contains(KEEP_SCALE_ON_RESIZING_KEY_NAME)) {
|
332 |
chkKeepScaleOnResizing.setSelected( |
333 |
xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME)); |
334 |
} |
335 |
|
336 |
// Zoom-in factor
|
337 |
if (xml.contains(ZOOM_IN_FACTOR_KEY_NAME)) {
|
338 |
double zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR_KEY_NAME);
|
339 |
txtZoomInFactor.setText(String.valueOf( zoomInFactor ));
|
340 |
} else {
|
341 |
txtZoomInFactor.setText( |
342 |
String.valueOf( MapContext.ZOOMINFACTOR ));
|
343 |
} |
344 |
MapContext.ZOOMINFACTOR = Double.parseDouble(txtZoomInFactor.getText());
|
345 |
|
346 |
// Zoom-out factor
|
347 |
if (xml.contains(ZOOM_OUT_FACTOR_KEY_NAME)) {
|
348 |
double zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR_KEY_NAME);
|
349 |
txtZoomOutFactor.setText(String.valueOf( zoomOutFactor ));
|
350 |
} else {
|
351 |
txtZoomOutFactor.setText( |
352 |
String.valueOf( MapContext.ZOOMOUTFACTOR ));
|
353 |
} |
354 |
MapContext.ZOOMOUTFACTOR = Double.parseDouble(txtZoomOutFactor.getText());;
|
355 |
|
356 |
// Default back color
|
357 |
jccDefaultViewBackColor.setColor(View.getDefaultBackColor());
|
358 |
jccDefaultViewBackColor.setAlpha(255);
|
359 |
/*
|
360 |
* Locator's background color, for when we let it be possible
|
361 |
* // Default map overview back color
|
362 |
* jccDefaultMapOverViewBackColor.setColor(Project.getDefaultMapOverViewBackColor());
|
363 |
* jccDefaultMapOverViewBackColor.setAlpha(255);
|
364 |
*/
|
365 |
|
366 |
// Default selection color
|
367 |
jccDefaultSelectionColor.setColor(Project.getDefaultSelectionColor()); |
368 |
jccDefaultSelectionColor.setAlpha(255);
|
369 |
|
370 |
// Map units
|
371 |
jCmbMapUnits.setSelectedIndex(Project.getDefaultMapUnits()); |
372 |
|
373 |
// Distance units
|
374 |
jCmbDistanceUnits.setSelectedIndex(Project.getDefaultDistanceUnits()); |
375 |
|
376 |
String[] names=MapContext.getAreaNames(); |
377 |
for (int i = 0; i < names.length; i++) { |
378 |
names[i]=PluginServices.getText(this,names[i])+MapContext.getOfLinear(i);
|
379 |
} |
380 |
// Distance area
|
381 |
jCmbDistanceArea = new JComboBox(names); |
382 |
jCmbDistanceArea.setSelectedIndex(Project.getDefaultDistanceUnits()); |
383 |
|
384 |
} |
385 |
|
386 |
public String getID() { |
387 |
return id;
|
388 |
} |
389 |
|
390 |
public String getTitle() { |
391 |
return PluginServices.getText(this, "Vista"); |
392 |
} |
393 |
|
394 |
public JPanel getPanel() { |
395 |
if (panelStarted) return this; |
396 |
panelStarted = true;
|
397 |
// default projection
|
398 |
addComponent(getJPanelProj()); |
399 |
/* lblDefaultProjection = new JLabel();
|
400 |
lblDefaultProjection.setFont(new java.awt.Font(
|
401 |
fontName, java.awt.Font.BOLD, 11));
|
402 |
btnChangeProjection = new JButton(PluginServices.getText(this, "change"));
|
403 |
btnChangeProjection.addActionListener(new ActionListener() {
|
404 |
public void actionPerformed(ActionEvent e) {
|
405 |
CSSelectionDialog csSelect = new CSSelectionDialog();
|
406 |
csSelect.setProjection( CRSFactory.getCRS(
|
407 |
lblDefaultProjection.getText()));
|
408 |
PluginServices.getMDIManager().addWindow(csSelect);
|
409 |
|
410 |
if (csSelect.isOkPressed()) {
|
411 |
IProjection proj = csSelect.getProjection();
|
412 |
lblDefaultProjection.setText(proj.getAbrev());
|
413 |
}
|
414 |
}
|
415 |
});
|
416 |
|
417 |
addComponent(PluginServices.getText(this, "default_projection") + ":", lblDefaultProjection );
|
418 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
|
419 |
aux.add(btnChangeProjection);
|
420 |
addComponent("", aux);*/
|
421 |
|
422 |
// just a separator
|
423 |
addComponent(new JLabel(" ")); |
424 |
|
425 |
// Adding Invisible New Layers
|
426 |
chkInvisibleNewLayers = new JCheckBox( |
427 |
PluginServices.getText(this, "options.view.invisible_new_layers")); |
428 |
|
429 |
addComponent("", chkInvisibleNewLayers);
|
430 |
chkKeepScaleOnResizing = new JCheckBox( |
431 |
PluginServices.getText(this, "options.view.keep_scale_on_resizing")); |
432 |
chkKeepScaleOnResizing.setEnabled(false);
|
433 |
addComponent("", chkKeepScaleOnResizing);
|
434 |
|
435 |
// just a separator
|
436 |
addComponent(new JLabel(" ")); |
437 |
|
438 |
// zoom in factor
|
439 |
addComponent(PluginServices.getText(this, "zoom_in_factor") + ":", |
440 |
txtZoomInFactor = new JTextField("", 15)); |
441 |
// zoom out factor
|
442 |
addComponent(PluginServices.getText(this, "zoom_out_factor") + ":", |
443 |
txtZoomOutFactor = new JTextField("", 15)); |
444 |
|
445 |
// just a separator
|
446 |
addComponent(new JLabel(" ")); |
447 |
|
448 |
// default back color chooser
|
449 |
addComponent(PluginServices.getText(this, "options.view.default_view_back_color"), |
450 |
jccDefaultViewBackColor = new ColorChooserPanel());
|
451 |
|
452 |
/*
|
453 |
* Locator's background color, for when we let it be possible
|
454 |
* // default back color chooser
|
455 |
* addComponent(PluginServices.getText(this, "options.view.default_map_overview_back_color"), jccDefaultMapOverViewBackColor = new ColorChooserPanel());
|
456 |
*/
|
457 |
|
458 |
// default selection color chooser
|
459 |
addComponent(PluginServices.getText(this, "options.view.default_selection_color"), |
460 |
jccDefaultSelectionColor = new ColorChooserPanel());
|
461 |
|
462 |
// just a separator
|
463 |
addComponent(new JLabel(" ")); |
464 |
|
465 |
// default map units
|
466 |
addComponent(PluginServices.getText(this, "map_units"), |
467 |
jCmbMapUnits = new JComboBox(getUnitsNames())); |
468 |
|
469 |
// default distance units
|
470 |
addComponent(PluginServices.getText(this, "distance_units"), |
471 |
jCmbDistanceUnits = new JComboBox(getUnitsNames())); |
472 |
|
473 |
String[] names=MapContext.getAreaNames(); |
474 |
for (int i = 0; i < names.length; i++) { |
475 |
names[i]=PluginServices.getText(this,names[i])+MapContext.getOfLinear(i);
|
476 |
} |
477 |
// default distance units
|
478 |
addComponent(PluginServices.getText(this, "unidades_area"), |
479 |
jCmbDistanceArea = new JComboBox(names)); |
480 |
|
481 |
initializeValues(); |
482 |
return this; |
483 |
} |
484 |
|
485 |
public void storeValues() throws StoreException { |
486 |
//String projName = lblDefaultProjection.getText();
|
487 |
double zif;
|
488 |
double zof;
|
489 |
boolean invisibleNewLayers, keepScaleOnResize;
|
490 |
Color selectionColor, viewBackColor;
|
491 |
/*
|
492 |
* Locator's background color, for when we let it be possible
|
493 |
* Color mapOverViewBackColor;
|
494 |
*/
|
495 |
|
496 |
try {
|
497 |
zif=Double.parseDouble(txtZoomInFactor.getText());
|
498 |
zof=Double.parseDouble(txtZoomOutFactor.getText());
|
499 |
if (zif==0 || zof==0) { |
500 |
throw new NumberFormatException(); |
501 |
} |
502 |
//Project.setDefaultProjection( CRSFactory.getCRS(projName));
|
503 |
|
504 |
selectionColor = jccDefaultSelectionColor.getColor(); |
505 |
Project.setDefaultSelectionColor( selectionColor ); |
506 |
|
507 |
viewBackColor = jccDefaultViewBackColor.getColor(); |
508 |
View.setDefaultBackColor( viewBackColor );
|
509 |
/*
|
510 |
* Locator's background color, for when we let it be possible
|
511 |
* mapOverViewBackColor = jccDefaultMapOverViewBackColor.getColor();
|
512 |
* View.setDefaultMapOverViewBackColor( mapOverViewBackColor );
|
513 |
*/
|
514 |
|
515 |
Project.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex()); |
516 |
Project.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex()); |
517 |
Project.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex()); |
518 |
invisibleNewLayers = chkInvisibleNewLayers.isSelected(); |
519 |
keepScaleOnResize = chkKeepScaleOnResizing.isSelected(); |
520 |
} catch (Exception e) { |
521 |
throw new StoreException(PluginServices.getText(this,"factor_zoom_incorrecto")); |
522 |
} |
523 |
MapContext.ZOOMINFACTOR=zif; |
524 |
MapContext.ZOOMOUTFACTOR=zof; |
525 |
// MapControl.setScalingOnResize(!keepScaleOnResize);
|
526 |
|
527 |
PluginServices ps = PluginServices.getPluginServices(this);
|
528 |
XMLEntity xml = ps.getPersistentXML(); |
529 |
xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, |
530 |
Project.getDefaultProjection().getAbrev()); |
531 |
xml.putProperty(ZOOM_IN_FACTOR_KEY_NAME, zif); |
532 |
xml.putProperty(ZOOM_OUT_FACTOR_KEY_NAME, zof); |
533 |
xml.putProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME, invisibleNewLayers); |
534 |
xml.putProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME, keepScaleOnResize); |
535 |
xml.putProperty(DEFAULT_VIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(viewBackColor)); |
536 |
/*
|
537 |
* Locator's background color, for when we let it be possible
|
538 |
* xml.putProperty(DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(mapOverViewBackColor));
|
539 |
*/
|
540 |
xml.putProperty(DEFAULT_SELECTION_COLOR_KEY_NAME, StringUtilities.color2String(selectionColor)); |
541 |
xml.putProperty(DEFAULT_MAP_UNITS_KEY_NAME, jCmbMapUnits.getSelectedIndex()); |
542 |
xml.putProperty(DEFAULT_DISTANCE_UNITS_KEY_NAME, jCmbDistanceUnits.getSelectedIndex()); |
543 |
xml.putProperty(DEFAULT_DISTANCE_AREA_KEY_NAME, jCmbDistanceArea.getSelectedIndex()); |
544 |
} |
545 |
|
546 |
|
547 |
public void initializeDefaults() { |
548 |
//lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION);
|
549 |
txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
|
550 |
txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
|
551 |
chkInvisibleNewLayers.setSelected(false);
|
552 |
chkKeepScaleOnResizing.setSelected(false);
|
553 |
jccDefaultViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR); |
554 |
/*
|
555 |
* Locator's background color, for when we let it be possible
|
556 |
* jccDefaultMapOverViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR);
|
557 |
*/
|
558 |
jccDefaultSelectionColor.setColor(FACTORY_DEFAULT_SELECTION_COLOR); |
559 |
jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS); |
560 |
jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS); |
561 |
jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA); |
562 |
|
563 |
} |
564 |
|
565 |
public ImageIcon getIcon() { |
566 |
return icon;
|
567 |
} |
568 |
|
569 |
public boolean isValueChanged() { |
570 |
return super.hasChanged(); |
571 |
} |
572 |
|
573 |
public void setChangesApplied() { |
574 |
setChanged(false);
|
575 |
} |
576 |
|
577 |
|
578 |
private String[] getUnitsNames() { |
579 |
if (unitsNames == null) { |
580 |
unitsNames = new String[Attributes.NAMES.length]; |
581 |
for (int i=0;i<Attributes.NAMES.length;i++) { |
582 |
unitsNames[i]=PluginServices.getText(this, Attributes.NAMES[i]); |
583 |
} |
584 |
} |
585 |
return unitsNames;
|
586 |
} |
587 |
} |