root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / preferencespage / ViewPage.java @ 38050
History | View | Annotate | Download (21.8 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 38050 2012-03-02 11:56:54Z fpuga $
|
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 com.iver.cit.gvsig.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.gui.beans.swing.JButton; |
191 |
|
192 |
import com.iver.andami.PluginServices; |
193 |
import com.iver.andami.preferences.AbstractPreferencePage; |
194 |
import com.iver.andami.preferences.StoreException; |
195 |
import com.iver.cit.gvsig.addlayer.AddLayerDialog; |
196 |
import com.iver.cit.gvsig.fmap.MapContext; |
197 |
import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
198 |
import com.iver.cit.gvsig.gui.panels.CRSSelectPanel; |
199 |
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel; |
200 |
import com.iver.cit.gvsig.gui.panels.crs.ISelectCrsPanel; |
201 |
import com.iver.cit.gvsig.project.Project; |
202 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
203 |
import com.iver.utiles.StringUtilities; |
204 |
import com.iver.utiles.XMLEntity; |
205 |
import com.iver.utiles.swing.JComboBox; |
206 |
|
207 |
/**
|
208 |
* <p>
|
209 |
* View document configuration page.
|
210 |
* </p>
|
211 |
* <p>
|
212 |
* Here the user can establish what settings wants to use by default regarding
|
213 |
* to the document View.
|
214 |
* </p>
|
215 |
*
|
216 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
217 |
*/
|
218 |
public class ViewPage extends AbstractPreferencePage { |
219 |
|
220 |
private static final String DEFAULT_PROJECTION_KEY_NAME = "DefaultProjection"; |
221 |
private static final String FACTORY_DEFAULT_PROJECTION = "EPSG:23030"; |
222 |
private static final String ZOOM_IN_FACTOR_KEY_NAME = "ZoomInFactor"; |
223 |
private static final String ZOOM_OUT_FACTOR_KEY_NAME = "ZoomOutFactor"; |
224 |
private static final String ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME = "NewLayersInInvisibleMode"; |
225 |
private static final String SHOW_FILE_EXTENSIONS_KEY_NAME = "ShowFileExtensions"; |
226 |
private static final String KEEP_SCALE_ON_RESIZING_KEY_NAME = "KeepScaleOnResizing"; |
227 |
public static final String OPEN_VIEW_WINDOW_MAXIMIZED = "options.view.open_view_window_maximized"; |
228 |
private static final String DEFAULT_SELECTION_COLOR_KEY_NAME = "DefaultSelectionColor"; |
229 |
private static final String DEFAULT_VIEW_BACK_COLOR_KEY_NAME = "DefaultViewBackColor"; |
230 |
private static final String DEFAULT_DISTANCE_AREA_KEY_NAME = "DefaultDistanceArea"; |
231 |
private static final String DEFAULT_DISTANCE_UNITS_KEY_NAME = "DefaultDistanceUnits"; |
232 |
private static final String DEFAULT_MAP_UNITS_KEY_NAME = "DefaultMapUnits"; |
233 |
/*
|
234 |
* Locator's background color, for when we let it be possible
|
235 |
* private static final String DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME = "DefaultMapOverViewBackColor";
|
236 |
*/
|
237 |
private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0; |
238 |
private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5; |
239 |
private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW; |
240 |
private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE; |
241 |
/*
|
242 |
* Locator's background color, for when we let it be possible
|
243 |
* private static final Color FACTORY_DEFAULT_MAP_OVERVIEW_BACK_COLOR = Color.WHITE;
|
244 |
*/
|
245 |
|
246 |
private static String[] unitsNames = null; |
247 |
|
248 |
private static int FACTORY_DEFAULT_MAP_UNITS; |
249 |
private static int FACTORY_DEFAULT_DISTANCE_UNITS; |
250 |
private static int FACTORY_DEFAULT_DISTANCE_AREA; |
251 |
|
252 |
private JTextField txtZoomInFactor; |
253 |
private JTextField txtZoomOutFactor; |
254 |
protected static String id = ViewPage.class.getName(); |
255 |
private ImageIcon icon; |
256 |
private JLabel lblDefaultProjection; |
257 |
private JButton btnChangeProjection; |
258 |
private String fontName; |
259 |
private JCheckBox chkInvisibleNewLayers; |
260 |
private JCheckBox chkKeepScaleOnResizing; |
261 |
private JCheckBox chkOpenViewWindowMaximized; |
262 |
private JCheckBox chkShowFileExtensions; |
263 |
private ColorChooserPanel jccDefaultSelectionColor;
|
264 |
private ColorChooserPanel jccDefaultViewBackColor;
|
265 |
private JComboBox jCmbMapUnits; |
266 |
private JComboBox jCmbDistanceUnits; |
267 |
private JComboBox jCmbDistanceArea; |
268 |
|
269 |
CRSSelectPanel jPanelProj = null;
|
270 |
|
271 |
|
272 |
/*
|
273 |
* Locator's background color, for when we let it be possible
|
274 |
* private ColorChooserPanel jccDefaultMapOverViewBackColor;
|
275 |
*/
|
276 |
|
277 |
{ |
278 |
Enumeration keys = UIManager.getDefaults().keys(); |
279 |
while (keys.hasMoreElements()) {
|
280 |
Object key = keys.nextElement();
|
281 |
Object value = UIManager.get (key); |
282 |
if (value instanceof FontUIResource) { |
283 |
FontUIResource fur = (FontUIResource) value; |
284 |
fontName = fur.getFontName(); |
285 |
|
286 |
} |
287 |
} |
288 |
|
289 |
String[] unitNames = MapContext.getDistanceNames(); |
290 |
for (int i = 0; i < unitNames.length; i++) { |
291 |
if (unitNames[i].equals("Metros")) { |
292 |
FACTORY_DEFAULT_DISTANCE_UNITS = i; |
293 |
FACTORY_DEFAULT_DISTANCE_AREA = i; |
294 |
FACTORY_DEFAULT_MAP_UNITS = i; |
295 |
break;
|
296 |
} |
297 |
} |
298 |
|
299 |
} |
300 |
|
301 |
/**
|
302 |
* Creates a new panel containing View preferences settings.
|
303 |
*
|
304 |
*/
|
305 |
public ViewPage() {
|
306 |
super();
|
307 |
|
308 |
icon = PluginServices.getIconTheme().get("vista-icono");
|
309 |
|
310 |
// default projection
|
311 |
lblDefaultProjection = new JLabel(); |
312 |
lblDefaultProjection.setFont(new java.awt.Font(
|
313 |
fontName, java.awt.Font.BOLD, 11));
|
314 |
btnChangeProjection = new JButton(PluginServices.getText(this, "change")); |
315 |
btnChangeProjection.addActionListener(new ActionListener() { |
316 |
public void actionPerformed(ActionEvent e) { |
317 |
ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
318 |
CRSFactory.getCRS(lblDefaultProjection.getText()), false);
|
319 |
PluginServices.getMDIManager().addWindow(panel); |
320 |
if (panel.isOkPressed()) {
|
321 |
IProjection proj = panel.getProjection(); |
322 |
lblDefaultProjection.setText(proj.getAbrev()); |
323 |
} |
324 |
} |
325 |
}); |
326 |
|
327 |
addComponent(PluginServices.getText(this, "default_projection") + ":", lblDefaultProjection ); |
328 |
|
329 |
IProjection proj = CRSFactory.getCRS("EPSG:23030");
|
330 |
if (PluginServices.getMainFrame() != null) { |
331 |
proj = AddLayerDialog.getLastProjection(); |
332 |
} |
333 |
|
334 |
jPanelProj = CRSSelectPanel.getPanel(proj); |
335 |
jPanelProj.setTransPanelActive(true);
|
336 |
jPanelProj.setBounds(11, 400, 448, 35); |
337 |
jPanelProj.setPreferredSize(new Dimension(448, 35)); |
338 |
jPanelProj.addActionListener(new ActionListener() { |
339 |
public void actionPerformed(ActionEvent e) { |
340 |
if (jPanelProj.isOkPressed()) {
|
341 |
lblDefaultProjection.setText(jPanelProj.getCurProj().getAbrev()); |
342 |
} |
343 |
} |
344 |
}); |
345 |
|
346 |
|
347 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
348 |
aux.add(btnChangeProjection); |
349 |
addComponent("", aux);
|
350 |
|
351 |
// just a separator
|
352 |
addComponent(new JLabel(" ")); |
353 |
|
354 |
// Adding Invisible New Layers
|
355 |
chkInvisibleNewLayers = new JCheckBox( |
356 |
PluginServices.getText(this, "options.view.invisible_new_layers")); |
357 |
|
358 |
addComponent("", chkInvisibleNewLayers);
|
359 |
|
360 |
chkShowFileExtensions = new JCheckBox( |
361 |
PluginServices.getText(this, "options.view.show_file_extensions")); |
362 |
addComponent("", chkShowFileExtensions);
|
363 |
|
364 |
chkKeepScaleOnResizing = new JCheckBox( |
365 |
PluginServices.getText(this, "options.view.keep_scale_on_resizing")); |
366 |
chkKeepScaleOnResizing.setEnabled(false);
|
367 |
addComponent("", chkKeepScaleOnResizing);
|
368 |
|
369 |
chkOpenViewWindowMaximized = new JCheckBox(PluginServices.getText(this, |
370 |
"options.view.open_view_window_maximized"));
|
371 |
addComponent("", chkOpenViewWindowMaximized);
|
372 |
|
373 |
// just a separator
|
374 |
addComponent(new JLabel(" ")); |
375 |
|
376 |
// zoom in factor
|
377 |
addComponent(PluginServices.getText(this, "zoom_in_factor") + ":", |
378 |
txtZoomInFactor = new JTextField("", 15)); |
379 |
// zoom out factor
|
380 |
addComponent(PluginServices.getText(this, "zoom_out_factor") + ":", |
381 |
txtZoomOutFactor = new JTextField("", 15)); |
382 |
|
383 |
// just a separator
|
384 |
addComponent(new JLabel(" ")); |
385 |
|
386 |
// default back color chooser
|
387 |
addComponent(PluginServices.getText(this, "options.view.default_view_back_color"), |
388 |
jccDefaultViewBackColor = new ColorChooserPanel());
|
389 |
|
390 |
/*
|
391 |
* Locator's background color, for when we let it be possible
|
392 |
* // default back color chooser
|
393 |
* addComponent(PluginServices.getText(this, "options.view.default_map_overview_back_color"), jccDefaultMapOverViewBackColor = new ColorChooserPanel());
|
394 |
*/
|
395 |
|
396 |
// default selection color chooser
|
397 |
addComponent(PluginServices.getText(this, "options.view.default_selection_color"), |
398 |
jccDefaultSelectionColor = new ColorChooserPanel(true)); |
399 |
|
400 |
// just a separator
|
401 |
addComponent(new JLabel(" ")); |
402 |
|
403 |
// default map units
|
404 |
addComponent(PluginServices.getText(this, "map_units"), |
405 |
jCmbMapUnits = new JComboBox()); |
406 |
|
407 |
// default distance units
|
408 |
addComponent(PluginServices.getText(this, "distance_units"), |
409 |
jCmbDistanceUnits = new JComboBox()); |
410 |
|
411 |
// default distance area
|
412 |
addComponent(PluginServices.getText(this, "distance_area"), |
413 |
jCmbDistanceArea = new JComboBox()); |
414 |
|
415 |
initializeValues(); |
416 |
} |
417 |
|
418 |
public void initializeValues() { |
419 |
PluginServices ps = PluginServices.getPluginServices(this);
|
420 |
XMLEntity xml = ps.getPersistentXML(); |
421 |
|
422 |
// Default Projection
|
423 |
if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
|
424 |
lblDefaultProjection.setText( |
425 |
xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME)); |
426 |
} else {
|
427 |
lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION); |
428 |
} |
429 |
Project.setDefaultProjection( CRSFactory.getCRS(lblDefaultProjection.getText())); |
430 |
|
431 |
// Adding invisible new layers
|
432 |
if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)) {
|
433 |
chkInvisibleNewLayers.setSelected( |
434 |
xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)); |
435 |
} |
436 |
|
437 |
// Show file extension on ToC when adding layers
|
438 |
if (xml.contains(SHOW_FILE_EXTENSIONS_KEY_NAME)) {
|
439 |
chkShowFileExtensions.setSelected( |
440 |
xml.getBooleanProperty(SHOW_FILE_EXTENSIONS_KEY_NAME)); |
441 |
} else {
|
442 |
chkShowFileExtensions.setSelected(false);
|
443 |
} |
444 |
|
445 |
// Keep scale on resizing
|
446 |
if (xml.contains(KEEP_SCALE_ON_RESIZING_KEY_NAME)) {
|
447 |
chkKeepScaleOnResizing.setSelected( |
448 |
xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME)); |
449 |
} |
450 |
|
451 |
if (xml.contains(OPEN_VIEW_WINDOW_MAXIMIZED)) {
|
452 |
chkOpenViewWindowMaximized.setSelected(xml |
453 |
.getBooleanProperty(OPEN_VIEW_WINDOW_MAXIMIZED)); |
454 |
} else {
|
455 |
chkOpenViewWindowMaximized.setSelected(true);
|
456 |
xml.putProperty(OPEN_VIEW_WINDOW_MAXIMIZED, true);
|
457 |
} |
458 |
|
459 |
// Zoom-in factor
|
460 |
if (xml.contains(ZOOM_IN_FACTOR_KEY_NAME)) {
|
461 |
double zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR_KEY_NAME);
|
462 |
txtZoomInFactor.setText(String.valueOf( zoomInFactor ));
|
463 |
} else {
|
464 |
txtZoomInFactor.setText( |
465 |
String.valueOf( MapContext.ZOOMINFACTOR ));
|
466 |
} |
467 |
MapContext.ZOOMINFACTOR = Double.parseDouble(txtZoomInFactor.getText());
|
468 |
|
469 |
// Zoom-out factor
|
470 |
if (xml.contains(ZOOM_OUT_FACTOR_KEY_NAME)) {
|
471 |
double zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR_KEY_NAME);
|
472 |
txtZoomOutFactor.setText(String.valueOf( zoomOutFactor ));
|
473 |
} else {
|
474 |
txtZoomOutFactor.setText( |
475 |
String.valueOf( MapContext.ZOOMOUTFACTOR ));
|
476 |
} |
477 |
MapContext.ZOOMOUTFACTOR = Double.parseDouble(txtZoomOutFactor.getText());;
|
478 |
|
479 |
// Default back color
|
480 |
jccDefaultViewBackColor.setColor(View.getDefaultBackColor());
|
481 |
jccDefaultViewBackColor.setAlpha(255);
|
482 |
/*
|
483 |
* Locator's background color, for when we let it be possible
|
484 |
* // Default map overview back color
|
485 |
* jccDefaultMapOverViewBackColor.setColor(Project.getDefaultMapOverViewBackColor());
|
486 |
* jccDefaultMapOverViewBackColor.setAlpha(255);
|
487 |
*/
|
488 |
|
489 |
// Default selection color
|
490 |
jccDefaultSelectionColor.setColor(Project.getDefaultSelectionColor()); |
491 |
// jccDefaultSelectionColor.setAlpha(255);
|
492 |
String[] distanceNames=MapContext.getDistanceNames(); |
493 |
// Map units
|
494 |
if (Project.getDefaultMapUnits()<=distanceNames.length && distanceNames.length != jCmbMapUnits.getItemCount()){
|
495 |
((DefaultComboBoxModel)jCmbMapUnits.getModel()).removeAllElements();
|
496 |
// default map units
|
497 |
for (int i = 0; i < distanceNames.length; i++) { |
498 |
((DefaultComboBoxModel)jCmbMapUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i])); |
499 |
} |
500 |
jCmbMapUnits.setSelectedIndex(Project.getDefaultMapUnits()); |
501 |
} |
502 |
|
503 |
// Distance units
|
504 |
if (Project.getDefaultDistanceUnits()<=distanceNames.length&& distanceNames.length != jCmbDistanceUnits.getItemCount()){
|
505 |
((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).removeAllElements();
|
506 |
// default distance units
|
507 |
for (int i = 0; i < distanceNames.length; i++) { |
508 |
((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i])); |
509 |
} |
510 |
jCmbDistanceUnits.setSelectedIndex(Project.getDefaultDistanceUnits()); |
511 |
} |
512 |
String[] names=MapContext.getAreaNames(); |
513 |
|
514 |
// Distance area
|
515 |
if (Project.getDefaultDistanceArea()<=names.length && names.length != jCmbDistanceArea.getItemCount()){
|
516 |
((DefaultComboBoxModel)jCmbDistanceArea.getModel()).removeAllElements();
|
517 |
for (int i = 0; i < names.length; i++) { |
518 |
((DefaultComboBoxModel)jCmbDistanceArea.getModel()).addElement(PluginServices.getText(this,names[i])+MapContext.getOfLinear(i)); |
519 |
} |
520 |
jCmbDistanceArea.setSelectedIndex(Project.getDefaultDistanceArea()); |
521 |
} |
522 |
|
523 |
|
524 |
} |
525 |
|
526 |
public String getID() { |
527 |
return id;
|
528 |
} |
529 |
|
530 |
public String getTitle() { |
531 |
return PluginServices.getText(this, "Vista"); |
532 |
} |
533 |
|
534 |
public JPanel getPanel() { |
535 |
return this; |
536 |
} |
537 |
|
538 |
public void storeValues() throws StoreException { |
539 |
String projName = lblDefaultProjection.getText();
|
540 |
double zif=1; |
541 |
double zof=1; |
542 |
boolean invisibleNewLayers, keepScaleOnResize, showFileExtensions;
|
543 |
Color selectionColor, viewBackColor;
|
544 |
/*
|
545 |
* Locator's background color, for when we let it be possible
|
546 |
* Color mapOverViewBackColor;
|
547 |
*/
|
548 |
|
549 |
try {
|
550 |
// try {
|
551 |
zif=Double.parseDouble(txtZoomInFactor.getText());
|
552 |
zof=Double.parseDouble(txtZoomOutFactor.getText());
|
553 |
if (zif==0 || zof==0) { |
554 |
throw new NumberFormatException(); |
555 |
} |
556 |
// }catch (NumberFormatException e) {
|
557 |
// //JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
|
558 |
// throw new StoreException(PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
|
559 |
// }
|
560 |
Project.setDefaultProjection( CRSFactory.getCRS(projName)); |
561 |
|
562 |
selectionColor = jccDefaultSelectionColor.getColor(); |
563 |
Project.setDefaultSelectionColor( selectionColor ); |
564 |
|
565 |
viewBackColor = jccDefaultViewBackColor.getColor(); |
566 |
View.setDefaultBackColor( viewBackColor );
|
567 |
/*
|
568 |
* Locator's background color, for when we let it be possible
|
569 |
* mapOverViewBackColor = jccDefaultMapOverViewBackColor.getColor();
|
570 |
* View.setDefaultMapOverViewBackColor( mapOverViewBackColor );
|
571 |
*/
|
572 |
|
573 |
Project.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex()); |
574 |
Project.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex()); |
575 |
Project.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex()); |
576 |
invisibleNewLayers = chkInvisibleNewLayers.isSelected(); |
577 |
keepScaleOnResize = chkKeepScaleOnResizing.isSelected(); |
578 |
|
579 |
showFileExtensions = chkShowFileExtensions.isSelected(); |
580 |
} catch (Exception e) { |
581 |
throw new StoreException(PluginServices.getText(this,"factor_zoom_incorrecto")); |
582 |
} |
583 |
MapContext.ZOOMINFACTOR=zif; |
584 |
MapContext.ZOOMOUTFACTOR=zof; |
585 |
// MapControl.setScalingOnResize(!keepScaleOnResize);
|
586 |
|
587 |
PluginServices ps = PluginServices.getPluginServices(this);
|
588 |
XMLEntity xml = ps.getPersistentXML(); |
589 |
xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, projName); |
590 |
xml.putProperty(ZOOM_IN_FACTOR_KEY_NAME, zif); |
591 |
xml.putProperty(ZOOM_OUT_FACTOR_KEY_NAME, zof); |
592 |
xml.putProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME, invisibleNewLayers); |
593 |
xml.putProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME, keepScaleOnResize); |
594 |
xml.putProperty(OPEN_VIEW_WINDOW_MAXIMIZED, |
595 |
chkOpenViewWindowMaximized.isSelected()); |
596 |
xml.putProperty(SHOW_FILE_EXTENSIONS_KEY_NAME, showFileExtensions); |
597 |
xml.putProperty(DEFAULT_VIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(viewBackColor)); |
598 |
/*
|
599 |
* Locator's background color, for when we let it be possible
|
600 |
* xml.putProperty(DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(mapOverViewBackColor));
|
601 |
*/
|
602 |
xml.putProperty(DEFAULT_SELECTION_COLOR_KEY_NAME, StringUtilities.color2String(selectionColor)); |
603 |
xml.putProperty(DEFAULT_MAP_UNITS_KEY_NAME, jCmbMapUnits.getSelectedIndex()); |
604 |
xml.putProperty(DEFAULT_DISTANCE_UNITS_KEY_NAME, jCmbDistanceUnits.getSelectedIndex()); |
605 |
xml.putProperty(DEFAULT_DISTANCE_AREA_KEY_NAME, jCmbDistanceArea.getSelectedIndex()); |
606 |
} |
607 |
|
608 |
|
609 |
public void initializeDefaults() { |
610 |
lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION); |
611 |
txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
|
612 |
txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
|
613 |
chkInvisibleNewLayers.setSelected(false);
|
614 |
chkKeepScaleOnResizing.setSelected(false);
|
615 |
chkOpenViewWindowMaximized.setSelected(true);
|
616 |
jccDefaultViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR); |
617 |
/*
|
618 |
* Locator's background color, for when we let it be possible
|
619 |
* jccDefaultMapOverViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR);
|
620 |
*/
|
621 |
jccDefaultSelectionColor.setColor(FACTORY_DEFAULT_SELECTION_COLOR); |
622 |
jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS); |
623 |
jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS); |
624 |
jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA); |
625 |
|
626 |
} |
627 |
|
628 |
public ImageIcon getIcon() { |
629 |
return icon;
|
630 |
} |
631 |
|
632 |
public boolean isValueChanged() { |
633 |
return super.hasChanged(); |
634 |
} |
635 |
|
636 |
public void setChangesApplied() { |
637 |
setChanged(false);
|
638 |
} |
639 |
|
640 |
|
641 |
// private String[] getUnitsNames() {
|
642 |
// if (unitsNames == null) {
|
643 |
// String[] names=MapContext.getDistanceNames();
|
644 |
// unitsNames = new String[names.length];
|
645 |
// for (int i=0;i<names.length;i++) {
|
646 |
// unitsNames[i]=PluginServices.getText(this, names[i]);
|
647 |
// }
|
648 |
// }
|
649 |
// return unitsNames;
|
650 |
// }
|
651 |
} |