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 @ 42439

History | View | Annotate | Download (20.6 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.IconThemeHelper;
173
import org.gvsig.andami.PluginServices;
174
import org.gvsig.andami.PluginsLocator;
175
import org.gvsig.andami.preferences.AbstractPreferencePage;
176
import org.gvsig.andami.preferences.StoreException;
177
import org.gvsig.app.ApplicationLocator;
178
import org.gvsig.app.addlayer.AddLayerDialog;
179
import org.gvsig.app.gui.panels.CRSSelectPanel;
180
import org.gvsig.app.gui.panels.ColorChooserPanel;
181
import org.gvsig.app.gui.panels.crs.ISelectCrsPanel;
182
import org.gvsig.app.project.DefaultProject;
183
import org.gvsig.app.project.ProjectPreferences;
184
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
185
import org.gvsig.fmap.crs.CRSFactory;
186
import org.gvsig.fmap.mapcontext.MapContext;
187
import org.gvsig.fmap.mapcontext.MapContextLocator;
188
import org.gvsig.gui.beans.swing.JButton;
189
import org.gvsig.utils.StringUtilities;
190
import org.gvsig.utils.XMLEntity;
191
import org.gvsig.utils.swing.JComboBox;
192

    
193

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

    
205
        private static final String FACTORY_DEFAULT_PROJECTION =
206
            MapContextLocator.getMapContextManager().getDefaultCRS().getAbrev();
207

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

    
230
        private static String[] unitsNames = null;
231

    
232
        private static int FACTORY_DEFAULT_MAP_UNITS;
233
        private static int FACTORY_DEFAULT_DISTANCE_UNITS;
234
        private static int FACTORY_DEFAULT_DISTANCE_AREA;
235

    
236
        private JTextField txtZoomInFactor;
237
        private JTextField txtZoomOutFactor;
238
        protected static String id = ViewPage.class.getName();
239
        private ImageIcon icon;
240
        private JLabel lblDefaultProjection;
241
        private JButton btnChangeProjection;
242
        private String fontName;
243
        private JCheckBox chkInvisibleNewLayers;
244
        private JCheckBox chkKeepScaleOnResizing;
245
        private ColorChooserPanel jccDefaultSelectionColor;
246
        private ColorChooserPanel jccDefaultViewBackColor;
247
        private JComboBox jCmbMapUnits;
248
        private JComboBox jCmbDistanceUnits;
249
        private JComboBox jCmbDistanceArea;
250

    
251
        CRSSelectPanel jPanelProj = null;
252

    
253

    
254
        /*
255
         * Locator's background color, for when we let it be possible
256
         * private ColorChooserPanel jccDefaultMapOverViewBackColor;
257
         */
258

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

    
268
                        }
269
                }
270

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

    
281
        }
282

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

    
290
                icon = IconThemeHelper.getImageIcon("document-view-icon");
291

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

    
309
                addComponent(PluginServices.getText(this, "default_projection") + ":", lblDefaultProjection );
310

    
311
                IProjection proj = CRSFactory.getCRS(FACTORY_DEFAULT_PROJECTION);
312
                if (PluginServices.getMainFrame() != null) {
313
                        proj = AddLayerDialog.getLastProjection();
314
                }
315

    
316
                jPanelProj = CRSSelectPanel.getPanel(proj);
317
                jPanelProj.setTransPanelActive(true);
318
                jPanelProj.setBounds(11, 400, 448, 35);
319
                jPanelProj.setPreferredSize(new Dimension(448, 35));
320
                jPanelProj.addActionListener(new ActionListener() {
321
                        public void actionPerformed(ActionEvent e) {
322
                                if (jPanelProj.isOkPressed()) {
323
                                        lblDefaultProjection.setText(jPanelProj.getCurProj().getAbrev());
324
                                }
325
                        }
326
                });
327

    
328

    
329
                JPanel aux = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
330
                aux.add(btnChangeProjection);
331
                addComponent("", aux);
332

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

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

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

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

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

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

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

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

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

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

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

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

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

    
388
                initializeValues();
389
        }
390

    
391
        public void initializeValues() {
392
                ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences();
393
                PluginServices ps = PluginsLocator.getManager().getPlugin(this);
394
                XMLEntity xml = ps.getPersistentXML();
395

    
396
//                projectPreferences.setDefaultProjection(lblDefaultProjection.getText());
397
        lblDefaultProjection.setText(projectPreferences.getDefaultProjection().getAbrev());
398

    
399
                // Adding invisible new layers
400
                if (xml.contains(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME)) {
401
                        chkInvisibleNewLayers.setSelected(
402
                                xml.getBooleanProperty(ADD_NEW_LAYERS_IN_INVISIBLE_MODE_KEY_NAME));
403
                }
404

    
405
                // Keep scale on resizing
406
                if (xml.contains(KEEP_SCALE_ON_RESIZING_KEY_NAME)) {
407
                        chkKeepScaleOnResizing.setSelected(
408
                                xml.getBooleanProperty(KEEP_SCALE_ON_RESIZING_KEY_NAME));
409
                }
410

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

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

    
431
                // Default back color
432
                jccDefaultViewBackColor.setColor(DefaultViewPanel.getDefaultBackColor());
433

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

    
441
                // Default selection color
442
                jccDefaultSelectionColor.setColor(DefaultProject.getDefaultSelectionColor());
443

    
444
                String[] distanceNames=MapContext.getDistanceNames();
445
                // Map units
446
                if (DefaultProject.getDefaultMapUnits()<=distanceNames.length && distanceNames.length != jCmbMapUnits.getItemCount()){
447
                        ((DefaultComboBoxModel)jCmbMapUnits.getModel()).removeAllElements();
448
                        //                         default map units
449
                        for (int i = 0; i < distanceNames.length; i++) {
450
                                ((DefaultComboBoxModel)jCmbMapUnits.getModel()).addElement(PluginServices.getText(this,distanceNames[i]));
451
                        }
452
                        jCmbMapUnits.setSelectedIndex(DefaultProject.getDefaultMapUnits());
453
                }
454

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

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

    
476
        public String getID() {
477
                return id;
478
        }
479

    
480
        public String getTitle() {
481
                return PluginServices.getText(this, "Vista");
482
        }
483

    
484
        public JPanel getPanel() {
485
                return this;
486
        }
487

    
488
        public void storeValues() throws StoreException {
489
            String projName = lblDefaultProjection.getText();
490
            double zif=1;
491
            double zof=1;
492
            boolean invisibleNewLayers, keepScaleOnResize;
493
            Color selectionColor, viewBackColor;
494

    
495
            ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences();
496
            /*
497
             * Locator's background color, for when we let it be possible
498
             * Color mapOverViewBackColor;
499
             */
500

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

    
514
                        selectionColor = jccDefaultSelectionColor.getColor();
515
                        projectPreferences.setDefaultSelectionColor( selectionColor );
516

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

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

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

    
555

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

    
572
        }
573

    
574
        public ImageIcon getIcon() {
575
                return icon;
576
        }
577

    
578
        public boolean isValueChanged() {
579
                return super.hasChanged();
580
        }
581

    
582
        public void setChangesApplied() {
583
                setChanged(false);
584
        }
585

    
586

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