svn-gvsig-desktop / tags / v2_0_0_Build_2061 / applications / appgvSIG / src / org / gvsig / app / gui / preferencespage / ViewPage.java @ 39431
History | View | Annotate | Download (20.6 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 39431 2012-12-14 12:26:45Z jldominguez $
|
45 |
* $Log$
|
46 |
* Revision 1.27 2007-09-17 09:22:10 jaume
|
47 |
* view draw frame rate now customizable
|
48 |
*
|
49 |
* Revision 1.26 2007/05/09 16:08:14 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.25 2007/03/06 16:35:02 caballero
|
53 |
* Exceptions
|
54 |
*
|
55 |
* Revision 1.24 2007/02/20 15:52:32 caballero
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.23 2007/01/25 11:04:07 caballero
|
59 |
* comprobar que el factor no es cero
|
60 |
*
|
61 |
* Revision 1.22 2006/12/20 14:41:12 caballero
|
62 |
* Remodelado Layout
|
63 |
*
|
64 |
* Revision 1.21 2006/11/08 10:57:55 jaume
|
65 |
* remove unecessary imports
|
66 |
*
|
67 |
* Revision 1.20 2006/10/25 08:34:06 jmvivo
|
68 |
* LLamado al PluginServices.getText para las unidades de medida del los combo
|
69 |
*
|
70 |
* Revision 1.19 2006/10/04 07:23:31 jaume
|
71 |
* refactored ambiguous methods and field names and added some more features for preference pages
|
72 |
*
|
73 |
* Revision 1.18 2006/10/03 09:52:38 jaume
|
74 |
* restores to meters
|
75 |
*
|
76 |
* Revision 1.17 2006/10/03 09:19:12 jaume
|
77 |
* *** empty log message ***
|
78 |
*
|
79 |
* Revision 1.16 2006/10/03 07:26:08 jaume
|
80 |
* *** empty log message ***
|
81 |
*
|
82 |
* Revision 1.15 2006/10/02 15:30:29 jaume
|
83 |
* *** empty log message ***
|
84 |
*
|
85 |
* Revision 1.14 2006/10/02 13:52:34 jaume
|
86 |
* organize impots
|
87 |
*
|
88 |
* Revision 1.13 2006/10/02 13:38:23 jaume
|
89 |
* *** empty log message ***
|
90 |
*
|
91 |
* Revision 1.12 2006/10/02 11:49:23 jaume
|
92 |
* *** empty log message ***
|
93 |
*
|
94 |
* Revision 1.11 2006/09/28 12:04:21 jaume
|
95 |
* default selection color now configurable
|
96 |
*
|
97 |
* Revision 1.10 2006/09/25 10:17:15 caballero
|
98 |
* Projection
|
99 |
*
|
100 |
* Revision 1.9 2006/09/15 10:41:30 caballero
|
101 |
* extensibilidad de documentos
|
102 |
*
|
103 |
* Revision 1.8 2006/09/14 15:43:48 jaume
|
104 |
* *** empty log message ***
|
105 |
*
|
106 |
* Revision 1.7 2006/09/14 15:42:38 jaume
|
107 |
* *** empty log message ***
|
108 |
*
|
109 |
* Revision 1.6 2006/09/14 06:57:18 jaume
|
110 |
* *** empty log message ***
|
111 |
*
|
112 |
* Revision 1.5 2006/09/12 15:56:50 jaume
|
113 |
* Default Projection now customizable
|
114 |
*
|
115 |
* Revision 1.4 2006/08/29 07:21:08 cesar
|
116 |
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
|
117 |
*
|
118 |
* Revision 1.3 2006/08/22 12:30:59 jaume
|
119 |
* *** empty log message ***
|
120 |
*
|
121 |
* Revision 1.2 2006/08/22 07:36:04 jaume
|
122 |
* *** empty log message ***
|
123 |
*
|
124 |
* Revision 1.1 2006/08/04 11:41:05 caballero
|
125 |
* poder especificar el zoom a aplicar en las vistas
|
126 |
*
|
127 |
* Revision 1.3 2006/07/31 10:02:31 jaume
|
128 |
* *** empty log message ***
|
129 |
*
|
130 |
* Revision 1.2 2006/06/13 07:43:08 fjp
|
131 |
* Ajustes sobre los cuadros de dialogos de preferencias
|
132 |
*
|
133 |
* Revision 1.1 2006/06/12 16:04:28 caballero
|
134 |
* Preferencias
|
135 |
*
|
136 |
* Revision 1.11 2006/06/06 10:26:31 jaume
|
137 |
* *** empty log message ***
|
138 |
*
|
139 |
* Revision 1.10 2006/06/05 17:07:17 jaume
|
140 |
* *** empty log message ***
|
141 |
*
|
142 |
* Revision 1.9 2006/06/05 17:00:44 jaume
|
143 |
* *** empty log message ***
|
144 |
*
|
145 |
* Revision 1.8 2006/06/05 16:57:59 jaume
|
146 |
* *** empty log message ***
|
147 |
*
|
148 |
* Revision 1.7 2006/06/05 14:45:06 jaume
|
149 |
* *** empty log message ***
|
150 |
*
|
151 |
* Revision 1.6 2006/06/05 11:00:09 jaume
|
152 |
* *** empty log message ***
|
153 |
*
|
154 |
* Revision 1.5 2006/06/05 10:39:02 jaume
|
155 |
* *** empty log message ***
|
156 |
*
|
157 |
* Revision 1.4 2006/06/05 10:13:40 jaume
|
158 |
* *** empty log message ***
|
159 |
*
|
160 |
* Revision 1.3 2006/06/05 10:06:08 jaume
|
161 |
* *** empty log message ***
|
162 |
*
|
163 |
* Revision 1.2 2006/06/05 09:51:56 jaume
|
164 |
* *** empty log message ***
|
165 |
*
|
166 |
* Revision 1.1 2006/06/02 10:50:18 jaume
|
167 |
* *** empty log message ***
|
168 |
*
|
169 |
*
|
170 |
*/
|
171 |
package org.gvsig.app.gui.preferencespage; |
172 |
|
173 |
import java.awt.Color; |
174 |
import java.awt.Dimension; |
175 |
import java.awt.FlowLayout; |
176 |
import java.awt.event.ActionEvent; |
177 |
import java.awt.event.ActionListener; |
178 |
import java.util.Enumeration; |
179 |
|
180 |
import javax.swing.DefaultComboBoxModel; |
181 |
import javax.swing.ImageIcon; |
182 |
import javax.swing.JCheckBox; |
183 |
import javax.swing.JLabel; |
184 |
import javax.swing.JPanel; |
185 |
import javax.swing.JTextField; |
186 |
import javax.swing.UIManager; |
187 |
import javax.swing.plaf.FontUIResource; |
188 |
|
189 |
import org.cresques.cts.IProjection; |
190 |
import org.gvsig.andami.PluginServices; |
191 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
192 |
import org.gvsig.andami.preferences.StoreException; |
193 |
import org.gvsig.app.addlayer.AddLayerDialog; |
194 |
import org.gvsig.app.gui.panels.CRSSelectPanel; |
195 |
import org.gvsig.app.gui.panels.ColorChooserPanel; |
196 |
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
197 |
import org.gvsig.app.project.DefaultProject; |
198 |
import org.gvsig.app.project.ProjectPreferences; |
199 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
200 |
import org.gvsig.fmap.crs.CRSFactory; |
201 |
import org.gvsig.fmap.mapcontext.MapContext; |
202 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
203 |
import org.gvsig.utils.StringUtilities; |
204 |
import org.gvsig.utils.XMLEntity; |
205 |
import org.gvsig.utils.swing.JComboBox; |
206 |
import org.gvsig.gui.beans.swing.JButton; |
207 |
|
208 |
|
209 |
/**
|
210 |
* View document configuration page.
|
211 |
* <b><b>
|
212 |
* Here the user can establish what settings wants to use by default regarding to
|
213 |
* the document View.
|
214 |
*
|
215 |
*
|
216 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
217 |
*/
|
218 |
public class ViewPage extends AbstractPreferencePage { |
219 |
|
220 |
public static final String DEFAULT_PROJECTION_KEY_NAME = "DefaultProjection"; |
221 |
|
222 |
private static final String FACTORY_DEFAULT_PROJECTION = |
223 |
MapContextLocator.getMapContextManager().getDefaultCRS().getAbrev(); |
224 |
|
225 |
private static final String ZOOM_IN_FACTOR_KEY_NAME = "ZoomInFactor"; |
226 |
private static final String ZOOM_OUT_FACTOR_KEY_NAME = "ZoomOutFactor"; |
227 |
public static final String ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME = "NewLayersInInvisibleMode"; |
228 |
private static final String KEEP_SCALE_ON_RESIZING_KEY_NAME = "KeepScaleOnResizing"; |
229 |
private static final String DEFAULT_SELECTION_COLOR_KEY_NAME = "DefaultSelectionColor"; |
230 |
private static final String DEFAULT_VIEW_BACK_COLOR_KEY_NAME = "DefaultViewBackColor"; |
231 |
private static final String DEFAULT_DISTANCE_AREA_KEY_NAME = "DefaultDistanceArea"; |
232 |
private static final String DEFAULT_DISTANCE_UNITS_KEY_NAME = "DefaultDistanceUnits"; |
233 |
private static final String DEFAULT_MAP_UNITS_KEY_NAME = "DefaultMapUnits"; |
234 |
/*
|
235 |
* Locator's background color, for when we let it be possible
|
236 |
* private static final String DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME = "DefaultMapOverViewBackColor";
|
237 |
*/
|
238 |
private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0; |
239 |
private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5; |
240 |
private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW; |
241 |
private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE; |
242 |
/*
|
243 |
* Locator's background color, for when we let it be possible
|
244 |
* private static final Color FACTORY_DEFAULT_MAP_OVERVIEW_BACK_COLOR = Color.WHITE;
|
245 |
*/
|
246 |
|
247 |
private static String[] unitsNames = null; |
248 |
|
249 |
private static int FACTORY_DEFAULT_MAP_UNITS; |
250 |
private static int FACTORY_DEFAULT_DISTANCE_UNITS; |
251 |
private static int FACTORY_DEFAULT_DISTANCE_AREA; |
252 |
|
253 |
private JTextField txtZoomInFactor; |
254 |
private JTextField txtZoomOutFactor; |
255 |
protected static String id = ViewPage.class.getName(); |
256 |
private ImageIcon icon; |
257 |
private JLabel lblDefaultProjection; |
258 |
private JButton btnChangeProjection; |
259 |
private String fontName; |
260 |
private JCheckBox chkInvisibleNewLayers; |
261 |
private JCheckBox chkKeepScaleOnResizing; |
262 |
private ColorChooserPanel jccDefaultSelectionColor;
|
263 |
private ColorChooserPanel jccDefaultViewBackColor;
|
264 |
private JComboBox jCmbMapUnits; |
265 |
private JComboBox jCmbDistanceUnits; |
266 |
private JComboBox jCmbDistanceArea; |
267 |
|
268 |
CRSSelectPanel jPanelProj = null;
|
269 |
|
270 |
|
271 |
/*
|
272 |
* Locator's background color, for when we let it be possible
|
273 |
* private ColorChooserPanel jccDefaultMapOverViewBackColor;
|
274 |
*/
|
275 |
|
276 |
{ |
277 |
Enumeration keys = UIManager.getDefaults().keys(); |
278 |
while (keys.hasMoreElements()) {
|
279 |
Object key = keys.nextElement();
|
280 |
Object value = UIManager.get (key); |
281 |
if (value instanceof FontUIResource) { |
282 |
FontUIResource fur = (FontUIResource) value; |
283 |
fontName = fur.getFontName(); |
284 |
|
285 |
} |
286 |
} |
287 |
|
288 |
String[] unitNames = MapContext.getDistanceNames(); |
289 |
for (int i = 0; i < unitNames.length; i++) { |
290 |
if (unitNames[i].equals("Metros")) { |
291 |
FACTORY_DEFAULT_DISTANCE_UNITS = i; |
292 |
FACTORY_DEFAULT_DISTANCE_AREA = i; |
293 |
FACTORY_DEFAULT_MAP_UNITS = i; |
294 |
break;
|
295 |
} |
296 |
} |
297 |
|
298 |
} |
299 |
|
300 |
/**
|
301 |
* Creates a new panel containing View preferences settings.
|
302 |
*
|
303 |
*/
|
304 |
public ViewPage() {
|
305 |
super();
|
306 |
|
307 |
icon = PluginServices.getIconTheme().get("vista-icono");
|
308 |
|
309 |
// default projection
|
310 |
lblDefaultProjection = new JLabel(); |
311 |
lblDefaultProjection.setFont(new java.awt.Font(
|
312 |
fontName, java.awt.Font.BOLD, 11));
|
313 |
btnChangeProjection = new JButton(PluginServices.getText(this, "change")); |
314 |
btnChangeProjection.addActionListener(new ActionListener() { |
315 |
public void actionPerformed(ActionEvent e) { |
316 |
ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
317 |
CRSFactory.getCRS(lblDefaultProjection.getText()), false);
|
318 |
PluginServices.getMDIManager().addWindow(panel); |
319 |
if (panel.isOkPressed()) {
|
320 |
IProjection proj = panel.getProjection(); |
321 |
lblDefaultProjection.setText(proj.getAbrev()); |
322 |
} |
323 |
} |
324 |
}); |
325 |
|
326 |
addComponent(PluginServices.getText(this, "default_projection") + ":", lblDefaultProjection ); |
327 |
|
328 |
IProjection proj = CRSFactory.getCRS(FACTORY_DEFAULT_PROJECTION); |
329 |
if (PluginServices.getMainFrame() != null) { |
330 |
proj = AddLayerDialog.getLastProjection(); |
331 |
} |
332 |
|
333 |
jPanelProj = CRSSelectPanel.getPanel(proj); |
334 |
jPanelProj.setTransPanelActive(true);
|
335 |
jPanelProj.setBounds(11, 400, 448, 35); |
336 |
jPanelProj.setPreferredSize(new Dimension(448, 35)); |
337 |
jPanelProj.addActionListener(new ActionListener() { |
338 |
public void actionPerformed(ActionEvent e) { |
339 |
if (jPanelProj.isOkPressed()) {
|
340 |
lblDefaultProjection.setText(jPanelProj.getCurProj().getAbrev()); |
341 |
} |
342 |
} |
343 |
}); |
344 |
|
345 |
|
346 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
347 |
aux.add(btnChangeProjection); |
348 |
addComponent("", aux);
|
349 |
|
350 |
// just a separator
|
351 |
addComponent(new JLabel(" ")); |
352 |
|
353 |
// Adding Invisible New Layers
|
354 |
chkInvisibleNewLayers = new JCheckBox( |
355 |
PluginServices.getText(this, "options.view.invisible_new_layers")); |
356 |
|
357 |
addComponent("", chkInvisibleNewLayers);
|
358 |
chkKeepScaleOnResizing = new JCheckBox( |
359 |
PluginServices.getText(this, "options.view.keep_scale_on_resizing")); |
360 |
chkKeepScaleOnResizing.setEnabled(false);
|
361 |
addComponent("", chkKeepScaleOnResizing);
|
362 |
|
363 |
// just a separator
|
364 |
addComponent(new JLabel(" ")); |
365 |
|
366 |
// zoom in factor
|
367 |
addComponent(PluginServices.getText(this, "zoom_in_factor") + ":", |
368 |
txtZoomInFactor = new JTextField("", 15)); |
369 |
// zoom out factor
|
370 |
addComponent(PluginServices.getText(this, "zoom_out_factor") + ":", |
371 |
txtZoomOutFactor = new JTextField("", 15)); |
372 |
|
373 |
// just a separator
|
374 |
addComponent(new JLabel(" ")); |
375 |
|
376 |
// default back color chooser
|
377 |
addComponent(PluginServices.getText(this, "options.view.default_view_back_color"), |
378 |
jccDefaultViewBackColor = new ColorChooserPanel());
|
379 |
|
380 |
/*
|
381 |
* Locator's background color, for when we let it be possible
|
382 |
* // default back color chooser
|
383 |
* addComponent(PluginServices.getText(this, "options.view.default_map_overview_back_color"), jccDefaultMapOverViewBackColor = new ColorChooserPanel());
|
384 |
*/
|
385 |
|
386 |
// default selection color chooser
|
387 |
addComponent(PluginServices.getText(this, "options.view.default_selection_color"), |
388 |
jccDefaultSelectionColor = new ColorChooserPanel());
|
389 |
|
390 |
// just a separator
|
391 |
addComponent(new JLabel(" ")); |
392 |
|
393 |
// default map units
|
394 |
addComponent(PluginServices.getText(this, "map_units"), |
395 |
jCmbMapUnits = new JComboBox()); |
396 |
|
397 |
// default distance units
|
398 |
addComponent(PluginServices.getText(this, "distance_units"), |
399 |
jCmbDistanceUnits = new JComboBox()); |
400 |
|
401 |
// default distance area
|
402 |
addComponent(PluginServices.getText(this, "distance_area"), |
403 |
jCmbDistanceArea = new JComboBox()); |
404 |
|
405 |
initializeValues(); |
406 |
} |
407 |
|
408 |
public void initializeValues() { |
409 |
PluginServices ps = PluginServices.getPluginServices(this);
|
410 |
XMLEntity xml = ps.getPersistentXML(); |
411 |
|
412 |
// Default Projection
|
413 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
|
414 |
lblDefaultProjection.setText( |
415 |
xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME)); |
416 |
} else {
|
417 |
lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION); |
418 |
} |
419 |
DefaultProject.setDefaultProjection( CRSFactory.getCRS(lblDefaultProjection.getText())); |
420 |
|
421 |
// Adding invisible new layers
|
422 |
if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)) {
|
423 |
chkInvisibleNewLayers.setSelected( |
424 |
xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)); |
425 |
} |
426 |
|
427 |
// Keep scale on resizing
|
428 |
if (xml.contains(KEEP_SCALE_ON_RESIZING_KEY_NAME)) {
|
429 |
chkKeepScaleOnResizing.setSelected( |
430 |
xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME)); |
431 |
} |
432 |
|
433 |
// Zoom-in factor
|
434 |
if (xml.contains(ZOOM_IN_FACTOR_KEY_NAME)) {
|
435 |
double zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR_KEY_NAME);
|
436 |
txtZoomInFactor.setText(String.valueOf( zoomInFactor ));
|
437 |
} else {
|
438 |
txtZoomInFactor.setText( |
439 |
String.valueOf( MapContext.ZOOMINFACTOR ));
|
440 |
} |
441 |
MapContext.ZOOMINFACTOR = Double.parseDouble(txtZoomInFactor.getText());
|
442 |
|
443 |
// Zoom-out factor
|
444 |
if (xml.contains(ZOOM_OUT_FACTOR_KEY_NAME)) {
|
445 |
double zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR_KEY_NAME);
|
446 |
txtZoomOutFactor.setText(String.valueOf( zoomOutFactor ));
|
447 |
} else {
|
448 |
txtZoomOutFactor.setText( |
449 |
String.valueOf( MapContext.ZOOMOUTFACTOR ));
|
450 |
} |
451 |
MapContext.ZOOMOUTFACTOR = Double.parseDouble(txtZoomOutFactor.getText());;
|
452 |
|
453 |
// Default back color
|
454 |
jccDefaultViewBackColor.setColor(DefaultViewPanel.getDefaultBackColor()); |
455 |
jccDefaultViewBackColor.setAlpha(255);
|
456 |
/*
|
457 |
* Locator's background color, for when we let it be possible
|
458 |
* // Default map overview back color
|
459 |
* jccDefaultMapOverViewBackColor.setColor(Project.getDefaultMapOverViewBackColor());
|
460 |
* jccDefaultMapOverViewBackColor.setAlpha(255);
|
461 |
*/
|
462 |
|
463 |
// Default selection color
|
464 |
jccDefaultSelectionColor.setColor(DefaultProject.getDefaultSelectionColor()); |
465 |
jccDefaultSelectionColor.setAlpha(255);
|
466 |
String[] distanceNames=MapContext.getDistanceNames(); |
467 |
// Map units
|
468 |
if (DefaultProject.getDefaultMapUnits()<=distanceNames.length && distanceNames.length != jCmbMapUnits.getItemCount()){
|
469 |
((DefaultComboBoxModel)jCmbMapUnits.getModel()).removeAllElements();
|
470 |
// default map units
|
471 |
for (int i = 0; i < distanceNames.length; i++) { |
472 |
((DefaultComboBoxModel)jCmbMapUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i])); |
473 |
} |
474 |
jCmbMapUnits.setSelectedIndex(DefaultProject.getDefaultMapUnits()); |
475 |
} |
476 |
|
477 |
// Distance units
|
478 |
if (DefaultProject.getDefaultDistanceUnits()<=distanceNames.length&& distanceNames.length != jCmbDistanceUnits.getItemCount()){
|
479 |
((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).removeAllElements();
|
480 |
// default distance units
|
481 |
for (int i = 0; i < distanceNames.length; i++) { |
482 |
((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i])); |
483 |
} |
484 |
jCmbDistanceUnits.setSelectedIndex(DefaultProject.getDefaultDistanceUnits()); |
485 |
} |
486 |
String[] names=MapContext.getAreaNames(); |
487 |
|
488 |
// Distance area
|
489 |
if (DefaultProject.getDefaultDistanceArea()<=names.length && names.length != jCmbDistanceArea.getItemCount()){
|
490 |
((DefaultComboBoxModel)jCmbDistanceArea.getModel()).removeAllElements();
|
491 |
for (int i = 0; i < names.length; i++) { |
492 |
((DefaultComboBoxModel)jCmbDistanceArea.getModel()).addElement(PluginServices.getText(this,names[i])+MapContext.getOfLinear(i)); |
493 |
} |
494 |
jCmbDistanceArea.setSelectedIndex(DefaultProject.getDefaultDistanceArea()); |
495 |
} |
496 |
} |
497 |
|
498 |
public String getID() { |
499 |
return id;
|
500 |
} |
501 |
|
502 |
public String getTitle() { |
503 |
return PluginServices.getText(this, "Vista"); |
504 |
} |
505 |
|
506 |
public JPanel getPanel() { |
507 |
return this; |
508 |
} |
509 |
|
510 |
public void storeValues() throws StoreException { |
511 |
String projName = lblDefaultProjection.getText();
|
512 |
double zif=1; |
513 |
double zof=1; |
514 |
boolean invisibleNewLayers, keepScaleOnResize;
|
515 |
Color selectionColor, viewBackColor;
|
516 |
/*
|
517 |
* Locator's background color, for when we let it be possible
|
518 |
* Color mapOverViewBackColor;
|
519 |
*/
|
520 |
|
521 |
try {
|
522 |
// try {
|
523 |
zif=Double.parseDouble(txtZoomInFactor.getText());
|
524 |
zof=Double.parseDouble(txtZoomOutFactor.getText());
|
525 |
if (zif==0 || zof==0) { |
526 |
throw new NumberFormatException(); |
527 |
} |
528 |
// }catch (NumberFormatException e) {
|
529 |
// //JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
|
530 |
// throw new StoreException(PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
|
531 |
// }
|
532 |
DefaultProject.setDefaultProjection( CRSFactory.getCRS(projName)); |
533 |
|
534 |
selectionColor = jccDefaultSelectionColor.getColor(); |
535 |
DefaultProject.setDefaultSelectionColor( selectionColor ); |
536 |
|
537 |
viewBackColor = jccDefaultViewBackColor.getColor(); |
538 |
DefaultViewPanel.setDefaultBackColor( viewBackColor ); |
539 |
/*
|
540 |
* Locator's background color, for when we let it be possible
|
541 |
* mapOverViewBackColor = jccDefaultMapOverViewBackColor.getColor();
|
542 |
* View.setDefaultMapOverViewBackColor( mapOverViewBackColor );
|
543 |
*/
|
544 |
|
545 |
DefaultProject.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex()); |
546 |
DefaultProject.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex()); |
547 |
DefaultProject.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex()); |
548 |
invisibleNewLayers = chkInvisibleNewLayers.isSelected(); |
549 |
keepScaleOnResize = chkKeepScaleOnResizing.isSelected(); |
550 |
} catch (Exception e) { |
551 |
throw new StoreException(PluginServices.getText(this,"factor_zoom_incorrecto")); |
552 |
} |
553 |
MapContext.ZOOMINFACTOR=zif; |
554 |
MapContext.ZOOMOUTFACTOR=zof; |
555 |
// MapControl.setScalingOnResize(!keepScaleOnResize);
|
556 |
|
557 |
PluginServices ps = PluginServices.getPluginServices(this);
|
558 |
XMLEntity xml = ps.getPersistentXML(); |
559 |
xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, projName); |
560 |
xml.putProperty(ZOOM_IN_FACTOR_KEY_NAME, zif); |
561 |
xml.putProperty(ZOOM_OUT_FACTOR_KEY_NAME, zof); |
562 |
xml.putProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME, invisibleNewLayers); |
563 |
xml.putProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME, keepScaleOnResize); |
564 |
xml.putProperty(DEFAULT_VIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(viewBackColor)); |
565 |
/*
|
566 |
* Locator's background color, for when we let it be possible
|
567 |
* xml.putProperty(DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(mapOverViewBackColor));
|
568 |
*/
|
569 |
xml.putProperty(DEFAULT_SELECTION_COLOR_KEY_NAME, StringUtilities.color2String(selectionColor)); |
570 |
xml.putProperty(DEFAULT_MAP_UNITS_KEY_NAME, jCmbMapUnits.getSelectedIndex()); |
571 |
xml.putProperty(DEFAULT_DISTANCE_UNITS_KEY_NAME, jCmbDistanceUnits.getSelectedIndex()); |
572 |
xml.putProperty(DEFAULT_DISTANCE_AREA_KEY_NAME, jCmbDistanceArea.getSelectedIndex()); |
573 |
} |
574 |
|
575 |
|
576 |
public void initializeDefaults() { |
577 |
lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION); |
578 |
txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
|
579 |
txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
|
580 |
chkInvisibleNewLayers.setSelected(false);
|
581 |
chkKeepScaleOnResizing.setSelected(false);
|
582 |
jccDefaultViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR); |
583 |
/*
|
584 |
* Locator's background color, for when we let it be possible
|
585 |
* jccDefaultMapOverViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR);
|
586 |
*/
|
587 |
jccDefaultSelectionColor.setColor(FACTORY_DEFAULT_SELECTION_COLOR); |
588 |
jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS); |
589 |
jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS); |
590 |
jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA); |
591 |
|
592 |
} |
593 |
|
594 |
public ImageIcon getIcon() { |
595 |
return icon;
|
596 |
} |
597 |
|
598 |
public boolean isValueChanged() { |
599 |
return super.hasChanged(); |
600 |
} |
601 |
|
602 |
public void setChangesApplied() { |
603 |
setChanged(false);
|
604 |
} |
605 |
|
606 |
|
607 |
// private String[] getUnitsNames() {
|
608 |
// if (unitsNames == null) {
|
609 |
// String[] names=MapContext.getDistanceNames();
|
610 |
// unitsNames = new String[names.length];
|
611 |
// for (int i=0;i<names.length;i++) {
|
612 |
// unitsNames[i]=PluginServices.getText(this, names[i]);
|
613 |
// }
|
614 |
// }
|
615 |
// return unitsNames;
|
616 |
// }
|
617 |
} |