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