Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / gui / preferencespage / ViewPage.java @ 40558

History | View | Annotate | Download (20.4 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
/* CVS MESSAGES:
25
*
26
* $Id: ViewPage.java 38875 2012-09-10 13:22:58Z jldominguez $
27
* $Log$
28
* Revision 1.27  2007-09-17 09:22:10  jaume
29
* view draw frame rate now customizable
30
*
31
* Revision 1.26  2007/05/09 16:08:14  jaume
32
* *** empty log message ***
33
*
34
* Revision 1.25  2007/03/06 16:35:02  caballero
35
* Exceptions
36
*
37
* Revision 1.24  2007/02/20 15:52:32  caballero
38
* *** empty log message ***
39
*
40
* Revision 1.23  2007/01/25 11:04:07  caballero
41
* comprobar que el factor no es cero
42
*
43
* Revision 1.22  2006/12/20 14:41:12  caballero
44
* Remodelado Layout
45
*
46
* Revision 1.21  2006/11/08 10:57:55  jaume
47
* remove unecessary imports
48
*
49
* Revision 1.20  2006/10/25 08:34:06  jmvivo
50
* LLamado al PluginServices.getText para las unidades de medida del los combo
51
*
52
* Revision 1.19  2006/10/04 07:23:31  jaume
53
* refactored ambiguous methods and field names and added some more features for preference pages
54
*
55
* Revision 1.18  2006/10/03 09:52:38  jaume
56
* restores to meters
57
*
58
* Revision 1.17  2006/10/03 09:19:12  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.16  2006/10/03 07:26:08  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.15  2006/10/02 15:30:29  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.14  2006/10/02 13:52:34  jaume
68
* organize impots
69
*
70
* Revision 1.13  2006/10/02 13:38:23  jaume
71
* *** empty log message ***
72
*
73
* Revision 1.12  2006/10/02 11:49:23  jaume
74
* *** empty log message ***
75
*
76
* Revision 1.11  2006/09/28 12:04:21  jaume
77
* default selection color now configurable
78
*
79
* Revision 1.10  2006/09/25 10:17:15  caballero
80
* Projection
81
*
82
* Revision 1.9  2006/09/15 10:41:30  caballero
83
* extensibilidad de documentos
84
*
85
* Revision 1.8  2006/09/14 15:43:48  jaume
86
* *** empty log message ***
87
*
88
* Revision 1.7  2006/09/14 15:42:38  jaume
89
* *** empty log message ***
90
*
91
* Revision 1.6  2006/09/14 06:57:18  jaume
92
* *** empty log message ***
93
*
94
* Revision 1.5  2006/09/12 15:56:50  jaume
95
* Default Projection now customizable
96
*
97
* Revision 1.4  2006/08/29 07:21:08  cesar
98
* Rename com.iver.cit.gvsig.fmap.Fmap class to com.iver.cit.gvsig.fmap.MapContext
99
*
100
* Revision 1.3  2006/08/22 12:30:59  jaume
101
* *** empty log message ***
102
*
103
* Revision 1.2  2006/08/22 07:36:04  jaume
104
* *** empty log message ***
105
*
106
* Revision 1.1  2006/08/04 11:41:05  caballero
107
* poder especificar el zoom a aplicar en las vistas
108
*
109
* Revision 1.3  2006/07/31 10:02:31  jaume
110
* *** empty log message ***
111
*
112
* Revision 1.2  2006/06/13 07:43:08  fjp
113
* Ajustes sobre los cuadros de dialogos de preferencias
114
*
115
* Revision 1.1  2006/06/12 16:04:28  caballero
116
* Preferencias
117
*
118
* Revision 1.11  2006/06/06 10:26:31  jaume
119
* *** empty log message ***
120
*
121
* Revision 1.10  2006/06/05 17:07:17  jaume
122
* *** empty log message ***
123
*
124
* Revision 1.9  2006/06/05 17:00:44  jaume
125
* *** empty log message ***
126
*
127
* Revision 1.8  2006/06/05 16:57:59  jaume
128
* *** empty log message ***
129
*
130
* Revision 1.7  2006/06/05 14:45:06  jaume
131
* *** empty log message ***
132
*
133
* Revision 1.6  2006/06/05 11:00:09  jaume
134
* *** empty log message ***
135
*
136
* Revision 1.5  2006/06/05 10:39:02  jaume
137
* *** empty log message ***
138
*
139
* Revision 1.4  2006/06/05 10:13:40  jaume
140
* *** empty log message ***
141
*
142
* Revision 1.3  2006/06/05 10:06:08  jaume
143
* *** empty log message ***
144
*
145
* Revision 1.2  2006/06/05 09:51:56  jaume
146
* *** empty log message ***
147
*
148
* Revision 1.1  2006/06/02 10:50:18  jaume
149
* *** empty log message ***
150
*
151
*
152
*/
153
package org.gvsig.app.gui.preferencespage;
154

    
155
import java.awt.Color;
156
import java.awt.Dimension;
157
import java.awt.FlowLayout;
158
import java.awt.event.ActionEvent;
159
import java.awt.event.ActionListener;
160
import java.util.Enumeration;
161

    
162
import javax.swing.DefaultComboBoxModel;
163
import javax.swing.ImageIcon;
164
import javax.swing.JCheckBox;
165
import javax.swing.JLabel;
166
import javax.swing.JPanel;
167
import javax.swing.JTextField;
168
import javax.swing.UIManager;
169
import javax.swing.plaf.FontUIResource;
170

    
171
import org.cresques.cts.IProjection;
172
import org.gvsig.andami.PluginServices;
173
import org.gvsig.andami.preferences.AbstractPreferencePage;
174
import org.gvsig.andami.preferences.StoreException;
175
import org.gvsig.app.addlayer.AddLayerDialog;
176
import org.gvsig.app.gui.panels.CRSSelectPanel;
177
import org.gvsig.app.gui.panels.ColorChooserPanel;
178
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
179
import org.gvsig.app.project.DefaultProject;
180
import org.gvsig.app.project.ProjectPreferences;
181
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
182
import org.gvsig.fmap.crs.CRSFactory;
183
import org.gvsig.fmap.mapcontext.MapContext;
184
import org.gvsig.fmap.mapcontext.MapContextLocator;
185
import org.gvsig.utils.StringUtilities;
186
import org.gvsig.utils.XMLEntity;
187
import org.gvsig.utils.swing.JComboBox;
188
import org.gvsig.gui.beans.swing.JButton;
189

    
190

    
191
/**
192
 *  View document configuration page.
193
 *  <b><b>
194
 *  Here the user can establish what settings wants to use by default regarding to
195
 *  the document View.
196
 *
197
 *
198
 * @author jaume dominguez faus - jaume.dominguez@iver.es
199
 */
200
public class ViewPage extends AbstractPreferencePage {
201

    
202
        public static final String DEFAULT_PROJECTION_KEY_NAME = "DefaultProjection";
203
        
204
        private static final String FACTORY_DEFAULT_PROJECTION =
205
            MapContextLocator.getMapContextManager().getDefaultCRS().getAbrev();
206
        
207
        private static final String ZOOM_IN_FACTOR_KEY_NAME = "ZoomInFactor";
208
        private static final String ZOOM_OUT_FACTOR_KEY_NAME = "ZoomOutFactor";
209
        public static final String ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME = "NewLayersInInvisibleMode";
210
        private static final String KEEP_SCALE_ON_RESIZING_KEY_NAME = "KeepScaleOnResizing";
211
        private static final String DEFAULT_SELECTION_COLOR_KEY_NAME = "DefaultSelectionColor";
212
        private static final String DEFAULT_VIEW_BACK_COLOR_KEY_NAME = "DefaultViewBackColor";
213
        private static final String DEFAULT_DISTANCE_AREA_KEY_NAME = "DefaultDistanceArea";
214
        private static final String DEFAULT_DISTANCE_UNITS_KEY_NAME = "DefaultDistanceUnits";
215
        private static final String DEFAULT_MAP_UNITS_KEY_NAME = "DefaultMapUnits";
216
        /*
217
         * Locator's background color, for when we let it be possible
218
         * private static final String DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME = "DefaultMapOverViewBackColor";
219
         */
220
        private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0;
221
        private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5;
222
        private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW;
223
        private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE;
224
        /*
225
         * Locator's background color, for when we let it be possible
226
         * private static final Color FACTORY_DEFAULT_MAP_OVERVIEW_BACK_COLOR = Color.WHITE;
227
         */
228

    
229
        private static String[] unitsNames = null;
230

    
231
        private static int FACTORY_DEFAULT_MAP_UNITS;
232
        private static int FACTORY_DEFAULT_DISTANCE_UNITS;
233
        private static int FACTORY_DEFAULT_DISTANCE_AREA;
234
        
235
        private JTextField txtZoomInFactor;
236
        private JTextField txtZoomOutFactor;
237
        protected static String id = ViewPage.class.getName();
238
        private ImageIcon icon;
239
        private JLabel lblDefaultProjection;
240
        private JButton btnChangeProjection;
241
        private String fontName;
242
        private JCheckBox chkInvisibleNewLayers;
243
        private JCheckBox chkKeepScaleOnResizing;
244
        private ColorChooserPanel jccDefaultSelectionColor;
245
        private ColorChooserPanel jccDefaultViewBackColor;
246
        private JComboBox jCmbMapUnits;
247
        private JComboBox jCmbDistanceUnits;
248
        private JComboBox jCmbDistanceArea;
249
        
250
        CRSSelectPanel jPanelProj = null;
251
        
252
        
253
        /*
254
         * Locator's background color, for when we let it be possible
255
         * private ColorChooserPanel jccDefaultMapOverViewBackColor;
256
         */
257

    
258
        {
259
                Enumeration keys = UIManager.getDefaults().keys();
260
                while (keys.hasMoreElements()) {
261
                        Object key = keys.nextElement();
262
                        Object value = UIManager.get (key);
263
                        if (value instanceof FontUIResource) {
264
                                FontUIResource fur = (FontUIResource) value;
265
                                fontName = fur.getFontName();
266

    
267
                        }
268
                }
269

    
270
                String[] unitNames = MapContext.getDistanceNames();
271
                for (int i = 0; i < unitNames.length; i++) {
272
                        if (unitNames[i].equals("Metros")) {
273
                                FACTORY_DEFAULT_DISTANCE_UNITS = i;
274
                                FACTORY_DEFAULT_DISTANCE_AREA = i;
275
                                FACTORY_DEFAULT_MAP_UNITS = i;
276
                                break;
277
                        }
278
                }
279

    
280
        }
281

    
282
        /**
283
         * Creates a new panel containing View preferences settings.
284
         *
285
         */
286
        public ViewPage() {
287
                super();
288

    
289
                icon = PluginServices.getIconTheme().get("vista-icono");
290

    
291
                // default projection
292
                lblDefaultProjection = new JLabel();
293
                lblDefaultProjection.setFont(new java.awt.Font(
294
                        fontName, java.awt.Font.BOLD, 11));
295
                btnChangeProjection = new JButton(PluginServices.getText(this, "change"));
296
                btnChangeProjection.addActionListener(new ActionListener() {
297
                        public void actionPerformed(ActionEvent e) {
298
                                ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel(
299
                                                CRSFactory.getCRS(lblDefaultProjection.getText()), false);
300
                                PluginServices.getMDIManager().addWindow(panel);
301
                        if (panel.isOkPressed()) {
302
                                IProjection proj = panel.getProjection();
303
                                lblDefaultProjection.setText(proj.getAbrev());
304
                        }
305
                        }
306
                });
307

    
308
                addComponent(PluginServices.getText(this, "default_projection") + ":", lblDefaultProjection );
309
                
310
                IProjection proj = CRSFactory.getCRS(FACTORY_DEFAULT_PROJECTION);
311
                if (PluginServices.getMainFrame() != null) {
312
                        proj = AddLayerDialog.getLastProjection();
313
                }
314

    
315
                jPanelProj = CRSSelectPanel.getPanel(proj);
316
                jPanelProj.setTransPanelActive(true);
317
                jPanelProj.setBounds(11, 400, 448, 35);
318
                jPanelProj.setPreferredSize(new Dimension(448, 35));
319
                jPanelProj.addActionListener(new ActionListener() {
320
                        public void actionPerformed(ActionEvent e) {
321
                                if (jPanelProj.isOkPressed()) {
322
                                        lblDefaultProjection.setText(jPanelProj.getCurProj().getAbrev());
323
                                }
324
                        }
325
                });
326
                
327
                
328
                JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
329
                aux.add(btnChangeProjection);
330
                addComponent("", aux);
331

    
332
                // just a separator
333
                addComponent(new JLabel(" "));
334

    
335
                // Adding Invisible New Layers
336
                chkInvisibleNewLayers = new JCheckBox(
337
                                PluginServices.getText(this, "options.view.invisible_new_layers"));
338

    
339
                addComponent("", chkInvisibleNewLayers);
340
                chkKeepScaleOnResizing = new JCheckBox(
341
                                PluginServices.getText(this, "options.view.keep_scale_on_resizing"));
342
                chkKeepScaleOnResizing.setEnabled(false);
343
                addComponent("", chkKeepScaleOnResizing);
344

    
345
                // just a separator
346
                addComponent(new JLabel(" "));
347

    
348
                // zoom in factor
349
                addComponent(PluginServices.getText(this, "zoom_in_factor") + ":",
350
                        txtZoomInFactor = new JTextField("", 15));
351
                // zoom out factor
352
                addComponent(PluginServices.getText(this, "zoom_out_factor") + ":",
353
                        txtZoomOutFactor = new JTextField("", 15));
354

    
355
                // just a separator
356
                addComponent(new JLabel(" "));
357

    
358
                // default back color chooser
359
                addComponent(PluginServices.getText(this, "options.view.default_view_back_color"),
360
                                jccDefaultViewBackColor = new ColorChooserPanel());
361

    
362
                /*
363
                 * Locator's background color, for when we let it be possible
364
                 * // default back color chooser
365
                 * addComponent(PluginServices.getText(this, "options.view.default_map_overview_back_color"), jccDefaultMapOverViewBackColor = new ColorChooserPanel());
366
                 */
367

    
368
                // default selection color chooser
369
                addComponent(PluginServices.getText(this, "options.view.default_selection_color"),
370
                                jccDefaultSelectionColor = new ColorChooserPanel());
371

    
372
                // just a separator
373
                addComponent(new JLabel(" "));
374

    
375
                // default map units
376
                addComponent(PluginServices.getText(this, "map_units"),
377
                                jCmbMapUnits = new JComboBox());
378

    
379
                // default distance units
380
                addComponent(PluginServices.getText(this, "distance_units"),
381
                                jCmbDistanceUnits = new JComboBox());
382

    
383
                // default distance area
384
                addComponent(PluginServices.getText(this, "distance_area"),
385
                                jCmbDistanceArea = new JComboBox());
386

    
387
                initializeValues();
388
        }
389

    
390
        public void initializeValues() {
391
                PluginServices ps = PluginServices.getPluginServices(this);
392
                XMLEntity xml = ps.getPersistentXML();
393

    
394
                // Default Projection
395
                if (xml.contains(DEFAULT_PROJECTION_KEY_NAME)) {
396
                        lblDefaultProjection.setText(
397
                                xml.getStringProperty(DEFAULT_PROJECTION_KEY_NAME));
398
                } else {
399
                        lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION);
400
                }
401
                DefaultProject.setDefaultProjection( CRSFactory.getCRS(lblDefaultProjection.getText()));
402

    
403
                // Adding invisible new layers
404
                if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)) {
405
                        chkInvisibleNewLayers.setSelected(
406
                                xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME));
407
                }
408

    
409
                // Keep scale on resizing
410
                if (xml.contains(KEEP_SCALE_ON_RESIZING_KEY_NAME)) {
411
                        chkKeepScaleOnResizing.setSelected(
412
                                xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME));
413
                }
414

    
415
                // Zoom-in factor
416
                if (xml.contains(ZOOM_IN_FACTOR_KEY_NAME)) {
417
                        double zoomInFactor = xml.getDoubleProperty(ZOOM_IN_FACTOR_KEY_NAME);
418
                        txtZoomInFactor.setText(String.valueOf( zoomInFactor ));
419
                } else {
420
                        txtZoomInFactor.setText(
421
                                String.valueOf( MapContext.ZOOMINFACTOR ));
422
                }
423
                MapContext.ZOOMINFACTOR = Double.parseDouble(txtZoomInFactor.getText());
424

    
425
                // Zoom-out factor
426
                if (xml.contains(ZOOM_OUT_FACTOR_KEY_NAME)) {
427
                        double zoomOutFactor = xml.getDoubleProperty(ZOOM_OUT_FACTOR_KEY_NAME);
428
                        txtZoomOutFactor.setText(String.valueOf( zoomOutFactor ));
429
                } else {
430
                        txtZoomOutFactor.setText(
431
                                String.valueOf( MapContext.ZOOMOUTFACTOR ));
432
                }
433
                MapContext.ZOOMOUTFACTOR = Double.parseDouble(txtZoomOutFactor.getText());;
434

    
435
                // Default back color
436
                jccDefaultViewBackColor.setColor(DefaultViewPanel.getDefaultBackColor());
437
                jccDefaultViewBackColor.setAlpha(255);
438
                /*
439
                 * Locator's background color, for when we let it be possible
440
                 * // Default map overview back color
441
                 * jccDefaultMapOverViewBackColor.setColor(Project.getDefaultMapOverViewBackColor());
442
                 * jccDefaultMapOverViewBackColor.setAlpha(255);
443
                 */
444

    
445
                // Default selection color
446
                jccDefaultSelectionColor.setColor(DefaultProject.getDefaultSelectionColor());
447
                jccDefaultSelectionColor.setAlpha(255);
448
                String[] distanceNames=MapContext.getDistanceNames();
449
                // Map units
450
                if (DefaultProject.getDefaultMapUnits()<=distanceNames.length && distanceNames.length != jCmbMapUnits.getItemCount()){
451
                        ((DefaultComboBoxModel)jCmbMapUnits.getModel()).removeAllElements();
452
                        //                         default map units
453
                        for (int i = 0; i < distanceNames.length; i++) {
454
                                ((DefaultComboBoxModel)jCmbMapUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i]));
455
                        }
456
                        jCmbMapUnits.setSelectedIndex(DefaultProject.getDefaultMapUnits());
457
                }
458

    
459
                // Distance units
460
                if (DefaultProject.getDefaultDistanceUnits()<=distanceNames.length&& distanceNames.length != jCmbDistanceUnits.getItemCount()){
461
                        ((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).removeAllElements();
462
                        // default distance units
463
                        for (int i = 0; i < distanceNames.length; i++) {
464
                                ((DefaultComboBoxModel)jCmbDistanceUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i]));
465
                        }
466
                        jCmbDistanceUnits.setSelectedIndex(DefaultProject.getDefaultDistanceUnits());
467
                }
468
                String[] names=MapContext.getAreaNames();
469

    
470
                // Distance area
471
                if (DefaultProject.getDefaultDistanceArea()<=names.length && names.length != jCmbDistanceArea.getItemCount()){
472
                        ((DefaultComboBoxModel)jCmbDistanceArea.getModel()).removeAllElements();
473
                        for (int i = 0; i < names.length; i++) {
474
                                ((DefaultComboBoxModel)jCmbDistanceArea.getModel()).addElement(PluginServices.getText(this,names[i])+MapContext.getOfLinear(i));
475
                        }
476
                        jCmbDistanceArea.setSelectedIndex(DefaultProject.getDefaultDistanceArea());
477
                }
478
        }
479

    
480
        public String getID() {
481
                return id;
482
        }
483

    
484
        public String getTitle() {
485
                return PluginServices.getText(this, "Vista");
486
        }
487

    
488
        public JPanel getPanel() {
489
                return this;
490
        }
491

    
492
        public void storeValues() throws StoreException {
493
                String projName = lblDefaultProjection.getText();
494
                double zif=1;
495
                double zof=1;
496
                boolean invisibleNewLayers, keepScaleOnResize;
497
                Color selectionColor, viewBackColor;
498
                /*
499
                 * Locator's background color, for when we let it be possible
500
                 * Color mapOverViewBackColor;
501
                 */
502

    
503
                try {
504
//                        try {
505
                                zif=Double.parseDouble(txtZoomInFactor.getText());
506
                                zof=Double.parseDouble(txtZoomOutFactor.getText());
507
                                if (zif==0 || zof==0) {
508
                                        throw new NumberFormatException();
509
                                }
510
//                        }catch (NumberFormatException e) {
511
//                                //JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
512
//                                throw new StoreException(PluginServices.getText(this,"numero_incorrecto")+" = "+ txtZoomInFactor.getText()+ ", "+txtZoomOutFactor.getText());
513
//                        }
514
                        DefaultProject.setDefaultProjection( CRSFactory.getCRS(projName));
515

    
516
                        selectionColor = jccDefaultSelectionColor.getColor();
517
                        DefaultProject.setDefaultSelectionColor( selectionColor );
518

    
519
                        viewBackColor = jccDefaultViewBackColor.getColor();
520
                        DefaultViewPanel.setDefaultBackColor( viewBackColor );
521
                        /*
522
                         * Locator's background color, for when we let it be possible
523
                         * mapOverViewBackColor = jccDefaultMapOverViewBackColor.getColor();
524
                         * View.setDefaultMapOverViewBackColor( mapOverViewBackColor );
525
                         */
526

    
527
                        DefaultProject.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex());
528
                        DefaultProject.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex());
529
                        DefaultProject.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex());
530
                        invisibleNewLayers = chkInvisibleNewLayers.isSelected();
531
                        keepScaleOnResize = chkKeepScaleOnResizing.isSelected();
532
                } catch (Exception e) {
533
                        throw new StoreException(PluginServices.getText(this,"factor_zoom_incorrecto"));
534
                }
535
                MapContext.ZOOMINFACTOR=zif;
536
                MapContext.ZOOMOUTFACTOR=zof;
537
                // MapControl.setScalingOnResize(!keepScaleOnResize);
538

    
539
                PluginServices ps = PluginServices.getPluginServices(this);
540
                XMLEntity xml = ps.getPersistentXML();
541
                xml.putProperty(DEFAULT_PROJECTION_KEY_NAME, projName);
542
                xml.putProperty(ZOOM_IN_FACTOR_KEY_NAME, zif);
543
                xml.putProperty(ZOOM_OUT_FACTOR_KEY_NAME, zof);
544
                xml.putProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME, invisibleNewLayers);
545
                xml.putProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME, keepScaleOnResize);
546
                xml.putProperty(DEFAULT_VIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(viewBackColor));
547
                /*
548
                 * Locator's background color, for when we let it be possible
549
                 * xml.putProperty(DEFAULT_MAP_OVERVIEW_BACK_COLOR_KEY_NAME, StringUtilities.color2String(mapOverViewBackColor));
550
                 */
551
                xml.putProperty(DEFAULT_SELECTION_COLOR_KEY_NAME, StringUtilities.color2String(selectionColor));
552
                xml.putProperty(DEFAULT_MAP_UNITS_KEY_NAME, jCmbMapUnits.getSelectedIndex());
553
                xml.putProperty(DEFAULT_DISTANCE_UNITS_KEY_NAME, jCmbDistanceUnits.getSelectedIndex());
554
                xml.putProperty(DEFAULT_DISTANCE_AREA_KEY_NAME, jCmbDistanceArea.getSelectedIndex());
555
        }
556

    
557

    
558
        public void initializeDefaults() {
559
                lblDefaultProjection.setText(FACTORY_DEFAULT_PROJECTION);
560
                txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
561
                txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
562
                chkInvisibleNewLayers.setSelected(false);
563
                chkKeepScaleOnResizing.setSelected(false);
564
                jccDefaultViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR);
565
                /*
566
                 * Locator's background color, for when we let it be possible
567
                 * jccDefaultMapOverViewBackColor.setColor(FACTORY_DEFAULT_VIEW_BACK_COLOR);
568
                 */
569
                jccDefaultSelectionColor.setColor(FACTORY_DEFAULT_SELECTION_COLOR);
570
                jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS);
571
                jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS);
572
                jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA);
573

    
574
        }
575

    
576
        public ImageIcon getIcon() {
577
                return icon;
578
        }
579

    
580
        public boolean isValueChanged() {
581
                return super.hasChanged();
582
        }
583

    
584
        public void setChangesApplied() {
585
                setChanged(false);
586
        }
587

    
588

    
589
//        private String[] getUnitsNames() {
590
//                if (unitsNames == null) {
591
//                        String[] names=MapContext.getDistanceNames();
592
//                        unitsNames = new String[names.length];
593
//                        for (int i=0;i<names.length;i++) {
594
//                                unitsNames[i]=PluginServices.getText(this, names[i]);
595
//                        }
596
//                }
597
//                return unitsNames;
598
//        }
599
}