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 @ 43213
History | View | Annotate | Download (17.9 KB)
1 | 40558 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40558 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | 43095 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 40435 | jjdelcerro | *
|
11 | 43095 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 40435 | jjdelcerro | *
|
16 | 43095 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 40435 | jjdelcerro | *
|
20 | 43095 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | package org.gvsig.app.gui.preferencespage; |
||
24 | |||
25 | import java.awt.Color; |
||
26 | import java.awt.event.ActionEvent; |
||
27 | import java.awt.event.ActionListener; |
||
28 | 43095 | jjdelcerro | import java.awt.event.ItemEvent; |
29 | import java.awt.event.ItemListener; |
||
30 | 40435 | jjdelcerro | |
31 | import javax.swing.DefaultComboBoxModel; |
||
32 | import javax.swing.ImageIcon; |
||
33 | 43095 | jjdelcerro | import javax.swing.JButton; |
34 | import javax.swing.JColorChooser; |
||
35 | 40435 | jjdelcerro | import javax.swing.JPanel; |
36 | 43095 | jjdelcerro | import javax.swing.JSlider; |
37 | 40435 | jjdelcerro | import javax.swing.JTextField; |
38 | 43095 | jjdelcerro | import javax.swing.SpinnerNumberModel; |
39 | import javax.swing.SwingUtilities; |
||
40 | import javax.swing.event.ChangeEvent; |
||
41 | import javax.swing.event.ChangeListener; |
||
42 | import org.apache.commons.lang3.BooleanUtils; |
||
43 | 40435 | jjdelcerro | |
44 | import org.cresques.cts.IProjection; |
||
45 | 40660 | jldominguez | import org.gvsig.andami.IconThemeHelper; |
46 | 40435 | jjdelcerro | import org.gvsig.andami.PluginServices; |
47 | 41311 | jjdelcerro | import org.gvsig.andami.PluginsLocator; |
48 | 43095 | jjdelcerro | import org.gvsig.andami.preferences.IPreference; |
49 | 40435 | jjdelcerro | import org.gvsig.andami.preferences.StoreException; |
50 | 41311 | jjdelcerro | import org.gvsig.app.ApplicationLocator; |
51 | 40435 | jjdelcerro | import org.gvsig.app.gui.panels.CRSSelectPanel; |
52 | import org.gvsig.app.gui.panels.crs.ISelectCrsPanel; |
||
53 | import org.gvsig.app.project.ProjectPreferences; |
||
54 | import org.gvsig.fmap.crs.CRSFactory; |
||
55 | import org.gvsig.fmap.mapcontext.MapContext; |
||
56 | import org.gvsig.fmap.mapcontext.MapContextLocator; |
||
57 | 43095 | jjdelcerro | import org.gvsig.i18n.Messages; |
58 | |||
59 | import org.gvsig.tools.ToolsLocator; |
||
60 | import org.gvsig.tools.dynobject.DynObject; |
||
61 | import org.gvsig.tools.i18n.I18nManager; |
||
62 | 43213 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
63 | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
||
64 | 40435 | jjdelcerro | import org.gvsig.utils.XMLEntity; |
65 | |||
66 | /**
|
||
67 | 43095 | jjdelcerro | * View document configuration page.
|
68 | 40435 | jjdelcerro | *
|
69 | 43095 | jjdelcerro | * Here the user can establish what settings wants to use by default regarding
|
70 | * to the document View.
|
||
71 | 40435 | jjdelcerro | *
|
72 | */
|
||
73 | 43095 | jjdelcerro | public class ViewPage extends ViewPageView implements ChangeListener, ItemListener, IPreference { |
74 | 43100 | jjdelcerro | //
|
75 | // The class ViewPageView can extend from AbstractPreferencePage, not JPanel,
|
||
76 | // if rereate it from the GUI builder change te class declaration to:
|
||
77 | 43095 | jjdelcerro | // public abstract class ViewPageView extends AbstractPreferencePage
|
78 | 41414 | fdiaz | |
79 | 43095 | jjdelcerro | private static final long serialVersionUID = 1204688910771374514L; |
80 | 41414 | fdiaz | |
81 | 43095 | jjdelcerro | public static String id = ViewPage.class.getName(); |
82 | 40435 | jjdelcerro | |
83 | 43095 | jjdelcerro | private static final IProjection FACTORY_DEFAULT_PROJECTION |
84 | = MapContextLocator.getMapContextManager().getDefaultCRS(); |
||
85 | 40435 | jjdelcerro | |
86 | 43095 | jjdelcerro | private static String[] unitsNames = null; |
87 | 41414 | fdiaz | |
88 | 43095 | jjdelcerro | private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0; |
89 | private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5; |
||
90 | private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW; |
||
91 | private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE; |
||
92 | private static int FACTORY_DEFAULT_MAP_UNITS; |
||
93 | private static int FACTORY_DEFAULT_DISTANCE_UNITS; |
||
94 | private static int FACTORY_DEFAULT_DISTANCE_AREA; |
||
95 | 41414 | fdiaz | |
96 | 43095 | jjdelcerro | private final ImageIcon icon; |
97 | 41414 | fdiaz | |
98 | 43095 | jjdelcerro | private ProjectionController defaultProjection = null; |
99 | private ColorChooserController defaultViewBackColor = null; |
||
100 | private ColorChooserController defaultSelectionColor = null; |
||
101 | 41414 | fdiaz | |
102 | 43095 | jjdelcerro | private boolean hasChanges = false; |
103 | 40435 | jjdelcerro | |
104 | 43095 | jjdelcerro | private static class ProjectionController implements ActionListener { |
105 | 40435 | jjdelcerro | |
106 | 43095 | jjdelcerro | private static final long serialVersionUID = -1442364274073324390L; |
107 | 40435 | jjdelcerro | |
108 | 43095 | jjdelcerro | private final JTextField txtLabel; |
109 | private final JButton btnShowDialog; |
||
110 | private IProjection proj = null; |
||
111 | private ChangeListener changeListener; |
||
112 | 40435 | jjdelcerro | |
113 | 43095 | jjdelcerro | public ProjectionController(JTextField txtLabel, JButton btnShowDialog) { |
114 | this.txtLabel = txtLabel;
|
||
115 | this.btnShowDialog = btnShowDialog;
|
||
116 | 40435 | jjdelcerro | |
117 | 43095 | jjdelcerro | this.btnShowDialog.addActionListener(this); |
118 | this.set(null); |
||
119 | } |
||
120 | 40435 | jjdelcerro | |
121 | 43095 | jjdelcerro | public void addChangeListener(ChangeListener changeListener) { |
122 | this.changeListener = changeListener;
|
||
123 | } |
||
124 | 40435 | jjdelcerro | |
125 | 43095 | jjdelcerro | public void fireChanged() { |
126 | if (this.changeListener != null) { |
||
127 | this.changeListener.stateChanged(null); |
||
128 | } |
||
129 | } |
||
130 | 40435 | jjdelcerro | |
131 | 43095 | jjdelcerro | public void set(IProjection proj) { |
132 | this.proj = proj;
|
||
133 | if (this.proj == null) { |
||
134 | this.txtLabel.setText(""); |
||
135 | } else {
|
||
136 | this.txtLabel.setText(proj.getAbrev());
|
||
137 | } |
||
138 | } |
||
139 | 41414 | fdiaz | |
140 | 43095 | jjdelcerro | public IProjection get() {
|
141 | return this.proj; |
||
142 | } |
||
143 | 40435 | jjdelcerro | |
144 | 43095 | jjdelcerro | @Override
|
145 | public void actionPerformed(ActionEvent e) { |
||
146 | ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
||
147 | CRSFactory.getCRS(this.txtLabel.getText()), false); |
||
148 | 43213 | jjdelcerro | ToolsSwingLocator.getWindowManager().showWindow( |
149 | panel.asJComponent(), |
||
150 | ToolsLocator.getI18nManager().getTranslation("selecciona_sistema_de_referencia"),
|
||
151 | WindowManager.MODE.DIALOG |
||
152 | ); |
||
153 | 43095 | jjdelcerro | if (panel.isOkPressed()) {
|
154 | this.set(panel.getProjection());
|
||
155 | this.fireChanged();
|
||
156 | } |
||
157 | } |
||
158 | 41414 | fdiaz | |
159 | 43095 | jjdelcerro | } |
160 | 41414 | fdiaz | |
161 | 43095 | jjdelcerro | private static class ColorChooserController implements ActionListener, ChangeListener { |
162 | 40435 | jjdelcerro | |
163 | 43095 | jjdelcerro | private final JTextField txtLabel; |
164 | private final JButton btnShowDialog; |
||
165 | private final JSlider sldAlpha; |
||
166 | private Color color; |
||
167 | private boolean allowNull; |
||
168 | private ChangeListener changeListener; |
||
169 | 40435 | jjdelcerro | |
170 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
171 | this.txtLabel = txtLabel;
|
||
172 | this.btnShowDialog = btnShowDialog;
|
||
173 | this.sldAlpha = sldAlpha;
|
||
174 | this.btnShowDialog.addActionListener(this); |
||
175 | if (this.sldAlpha != null) { |
||
176 | this.sldAlpha.addChangeListener(this); |
||
177 | } |
||
178 | this.allowNull = allowNull;
|
||
179 | if (!this.allowNull) { |
||
180 | this.color = Color.BLACK; |
||
181 | } |
||
182 | } |
||
183 | 40435 | jjdelcerro | |
184 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog) { |
185 | this(txtLabel, btnShowDialog, null, false); |
||
186 | } |
||
187 | 40435 | jjdelcerro | |
188 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
189 | this(txtLabel, btnShowDialog, sldAlpha, false); |
||
190 | } |
||
191 | 40435 | jjdelcerro | |
192 | 43095 | jjdelcerro | @Override
|
193 | public void stateChanged(ChangeEvent e) { |
||
194 | if (this.color == null) { |
||
195 | set(Color.BLACK);
|
||
196 | } |
||
197 | if (this.sldAlpha == null) { |
||
198 | this.color = new Color( |
||
199 | color.getRed(), |
||
200 | color.getGreen(), |
||
201 | color.getBlue() |
||
202 | ); |
||
203 | } else {
|
||
204 | this.color = new Color( |
||
205 | color.getRed(), |
||
206 | color.getGreen(), |
||
207 | color.getBlue(), |
||
208 | this.sldAlpha.getValue()
|
||
209 | ); |
||
210 | } |
||
211 | this.txtLabel.setBackground(this.color); |
||
212 | } |
||
213 | 40435 | jjdelcerro | |
214 | 43095 | jjdelcerro | public void addChangeListener(ChangeListener changeListener) { |
215 | this.changeListener = changeListener;
|
||
216 | } |
||
217 | 40435 | jjdelcerro | |
218 | 43095 | jjdelcerro | public void fireChanged() { |
219 | if (this.changeListener != null) { |
||
220 | this.changeListener.stateChanged(null); |
||
221 | } |
||
222 | } |
||
223 | 40435 | jjdelcerro | |
224 | 43095 | jjdelcerro | @Override
|
225 | public void actionPerformed(ActionEvent e) { |
||
226 | Color c = JColorChooser.showDialog( |
||
227 | SwingUtilities.windowForComponent(this.btnShowDialog), |
||
228 | Messages.getText("choose_color"),
|
||
229 | this.get()
|
||
230 | ); |
||
231 | if (c == null) { |
||
232 | return;
|
||
233 | } |
||
234 | set(c); |
||
235 | } |
||
236 | 40435 | jjdelcerro | |
237 | 43095 | jjdelcerro | private void set(Color color) { |
238 | if (color == null) { |
||
239 | if (allowNull) {
|
||
240 | this.color = null; |
||
241 | return;
|
||
242 | } |
||
243 | color = Color.BLACK;
|
||
244 | } |
||
245 | this.color = color;
|
||
246 | this.txtLabel.setBackground(this.color); |
||
247 | if (this.sldAlpha != null) { |
||
248 | this.sldAlpha.setValue(this.color.getAlpha()); |
||
249 | } |
||
250 | } |
||
251 | 40435 | jjdelcerro | |
252 | 43095 | jjdelcerro | public Color get() { |
253 | return this.color; |
||
254 | } |
||
255 | 40435 | jjdelcerro | |
256 | 43095 | jjdelcerro | } |
257 | 40435 | jjdelcerro | |
258 | 43095 | jjdelcerro | /**
|
259 | * Creates a new panel containing View preferences settings.
|
||
260 | *
|
||
261 | */
|
||
262 | public ViewPage() {
|
||
263 | super();
|
||
264 | 40435 | jjdelcerro | |
265 | 43095 | jjdelcerro | initUnitsNames(); |
266 | 40435 | jjdelcerro | |
267 | 43095 | jjdelcerro | icon = IconThemeHelper.getImageIcon("document-view-icon");
|
268 | 40435 | jjdelcerro | |
269 | 43095 | jjdelcerro | this.chkKeepScaleOnResizing.setEnabled(false); |
270 | |||
271 | this.defaultProjection = new ProjectionController( |
||
272 | this.txtDefaultProjection,
|
||
273 | this.btnChangeProjection
|
||
274 | ); |
||
275 | this.defaultProjection.addChangeListener(this); |
||
276 | 40435 | jjdelcerro | |
277 | 43095 | jjdelcerro | this.defaultSelectionColor = new ColorChooserController( |
278 | this.txtDefaultSelectionColor,
|
||
279 | this.btnDefaultSelectionColor,
|
||
280 | this.sldDefaultSelectionColor
|
||
281 | ); |
||
282 | this.defaultSelectionColor.addChangeListener(this); |
||
283 | 40435 | jjdelcerro | |
284 | 43095 | jjdelcerro | this.defaultViewBackColor = new ColorChooserController( |
285 | this.txtDefaultViewBackColor,
|
||
286 | this.btnDefaultViewBackColor
|
||
287 | ); |
||
288 | this.defaultViewBackColor.addChangeListener(this); |
||
289 | 40435 | jjdelcerro | |
290 | 43095 | jjdelcerro | this.chkInvisibleNewLayers.addChangeListener(this); |
291 | this.chkKeepScaleOnResizing.addChangeListener(this); |
||
292 | 40435 | jjdelcerro | |
293 | 43095 | jjdelcerro | this.jCmbDistanceArea.addItemListener(this); |
294 | this.jCmbDistanceUnits.addItemListener(this); |
||
295 | this.jCmbMapUnits.addItemListener(this); |
||
296 | 40435 | jjdelcerro | |
297 | 43095 | jjdelcerro | this.translateAll();
|
298 | this.initializeValues();
|
||
299 | } |
||
300 | 40435 | jjdelcerro | |
301 | 43095 | jjdelcerro | private void translateAll() { |
302 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
303 | 42439 | dmartinezizquierdo | |
304 | 43095 | jjdelcerro | this.lblDefaultProjection.setText(i18nManager.getTranslation("default_projection")); |
305 | this.chkInvisibleNewLayers.setText(i18nManager.getTranslation("options.view.invisible_new_layers")); |
||
306 | this.chkKeepScaleOnResizing.setText(i18nManager.getTranslation("options.view.keep_scale_on_resizing")); |
||
307 | this.lblZoomInFactor.setText(i18nManager.getTranslation("zoom_in_factor")); |
||
308 | this.lblZoomOutFactor.setText(i18nManager.getTranslation("zoom_out_factor")); |
||
309 | this.lblDefaultViewBackColor.setText(i18nManager.getTranslation("options.view.default_view_back_color")); |
||
310 | this.lblDefaultSelectionColor.setText(i18nManager.getTranslation("options.view.default_selection_color")); |
||
311 | this.lblMapUnits.setText(i18nManager.getTranslation("map_units")); |
||
312 | this.lblDistanceUnits.setText(i18nManager.getTranslation("distance_units")); |
||
313 | this.lblDistanceArea.setText(i18nManager.getTranslation("distance_area")); |
||
314 | 43100 | jjdelcerro | this.chkHideLegendOfNonVisibleLayers.setText(i18nManager.getTranslation("_Hide_legend_of_non_visible_layers")); |
315 | 43095 | jjdelcerro | } |
316 | 40435 | jjdelcerro | |
317 | 43095 | jjdelcerro | @Override
|
318 | public boolean isResizeable() { |
||
319 | return true; |
||
320 | } |
||
321 | 42439 | dmartinezizquierdo | |
322 | 43095 | jjdelcerro | @Override
|
323 | public void initializeValues() { |
||
324 | Double zif;
|
||
325 | Double zof;
|
||
326 | 40435 | jjdelcerro | |
327 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
328 | PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
|
||
329 | DynObject props = plugin.getPluginProperties(); |
||
330 | XMLEntity xml = plugin.getPersistentXML(); |
||
331 | 40435 | jjdelcerro | |
332 | 43095 | jjdelcerro | this.defaultProjection.set(projectPreferences.getDefaultProjection());
|
333 | 40435 | jjdelcerro | |
334 | 43100 | jjdelcerro | this.chkInvisibleNewLayers.setSelected(projectPreferences.getAddNewLayersInInvisibleMode());
|
335 | this.chkKeepScaleOnResizing.setSelected(projectPreferences.getKeepScaleOnResizing());
|
||
336 | this.chkOpenWithANewMaximizedView.setSelected(projectPreferences.getOpenWithANewMaximizedView());
|
||
337 | this.chkHideLegendOfNonVisibleLayers.setSelected(projectPreferences.getHideLegendInToCOfNonVisibleLayers());
|
||
338 | this.txtZoomInFactor.setModel(
|
||
339 | 43095 | jjdelcerro | new SpinnerNumberModel( |
340 | projectPreferences.getZoomInFactor(), //initial value
|
||
341 | 0.01, //min |
||
342 | 1000, //max |
||
343 | 0.25 //step |
||
344 | ) |
||
345 | ); |
||
346 | 43100 | jjdelcerro | this.txtZoomOutFactor.setModel(
|
347 | 43095 | jjdelcerro | new SpinnerNumberModel( |
348 | 43100 | jjdelcerro | projectPreferences.getZoomOutFactor(), //initial value
|
349 | 43095 | jjdelcerro | 0.01, //min |
350 | 1000, //max |
||
351 | 0.25 //step |
||
352 | ) |
||
353 | ); |
||
354 | MapContext.ZOOMINFACTOR = projectPreferences.getZoomInFactor(); |
||
355 | MapContext.ZOOMOUTFACTOR = projectPreferences.getZoomOutFactor(); |
||
356 | 40435 | jjdelcerro | |
357 | 43095 | jjdelcerro | this.defaultViewBackColor.set(projectPreferences.getDefaultViewBackColor());
|
358 | this.defaultSelectionColor.set(projectPreferences.getDefaultSelectionColor());
|
||
359 | 40435 | jjdelcerro | |
360 | 43095 | jjdelcerro | this.jCmbMapUnits.setModel(new DefaultComboBoxModel(unitsNames)); |
361 | this.jCmbMapUnits.setSelectedIndex(projectPreferences.getDefaultMapUnits());
|
||
362 | 41414 | fdiaz | |
363 | 43095 | jjdelcerro | this.jCmbDistanceUnits.setModel(new DefaultComboBoxModel(unitsNames)); |
364 | this.jCmbDistanceUnits.setSelectedIndex(projectPreferences.getDefaultDistanceUnits());
|
||
365 | 40435 | jjdelcerro | |
366 | 43095 | jjdelcerro | this.jCmbDistanceArea.setModel(new DefaultComboBoxModel(MapContext.getAreaNames())); |
367 | this.jCmbDistanceArea.setSelectedIndex(projectPreferences.getDefaultDistanceArea());
|
||
368 | } |
||
369 | 40435 | jjdelcerro | |
370 | 43095 | jjdelcerro | @Override
|
371 | public void stateChanged(ChangeEvent e) { |
||
372 | this.hasChanges = true; |
||
373 | } |
||
374 | 40435 | jjdelcerro | |
375 | 43095 | jjdelcerro | @Override
|
376 | public void itemStateChanged(ItemEvent e) { |
||
377 | this.hasChanges = true; |
||
378 | } |
||
379 | 40435 | jjdelcerro | |
380 | 43095 | jjdelcerro | @Override
|
381 | public String getID() { |
||
382 | return id;
|
||
383 | } |
||
384 | 40435 | jjdelcerro | |
385 | 43095 | jjdelcerro | @Override
|
386 | public String getTitle() { |
||
387 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
388 | return i18nManager.getTranslation("Vista"); |
||
389 | } |
||
390 | 40435 | jjdelcerro | |
391 | 43095 | jjdelcerro | @Override
|
392 | public JPanel getPanel() { |
||
393 | return this; |
||
394 | } |
||
395 | 40435 | jjdelcerro | |
396 | 43095 | jjdelcerro | @Override
|
397 | public void storeValues() throws StoreException { |
||
398 | 40435 | jjdelcerro | |
399 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
400 | 40435 | jjdelcerro | |
401 | 43095 | jjdelcerro | try {
|
402 | double zif = (double) txtZoomInFactor.getValue(); |
||
403 | double zof = (double) txtZoomOutFactor.getValue(); |
||
404 | if (zif == 0 || zof == 0) { |
||
405 | throw new NumberFormatException(); |
||
406 | } |
||
407 | 40435 | jjdelcerro | |
408 | 43095 | jjdelcerro | projectPreferences.setZoomInFactor(zif); |
409 | projectPreferences.setZoomOutFactor(zof); |
||
410 | MapContext.ZOOMINFACTOR = zif; |
||
411 | MapContext.ZOOMOUTFACTOR = zof; |
||
412 | 40435 | jjdelcerro | |
413 | 43095 | jjdelcerro | projectPreferences.setDefaultProjection(this.defaultProjection.get());
|
414 | projectPreferences.setDefaultSelectionColor(defaultSelectionColor.get()); |
||
415 | projectPreferences.setDefaultViewBackColor(defaultViewBackColor.get()); |
||
416 | 40435 | jjdelcerro | |
417 | 43095 | jjdelcerro | projectPreferences.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex()); |
418 | projectPreferences.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex()); |
||
419 | projectPreferences.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex()); |
||
420 | 40435 | jjdelcerro | |
421 | 43095 | jjdelcerro | projectPreferences.setAddNewLayersInInvisibleMode(chkInvisibleNewLayers.isSelected()); |
422 | projectPreferences.setKeepScaleOnResizing(chkKeepScaleOnResizing.isSelected()); |
||
423 | projectPreferences.setOpenWithANewMaximizedView(chkOpenWithANewMaximizedView.isSelected()); |
||
424 | 43100 | jjdelcerro | projectPreferences.setHideLegendInToCOfNonVisibleLayers(this.chkHideLegendOfNonVisibleLayers.isSelected());
|
425 | |||
426 | 43095 | jjdelcerro | } catch (Exception e) { |
427 | throw new StoreException(PluginServices.getText(this, "factor_zoom_incorrecto")); |
||
428 | } |
||
429 | } |
||
430 | |||
431 | @Override
|
||
432 | public void initializeDefaults() { |
||
433 | defaultProjection.set(FACTORY_DEFAULT_PROJECTION); |
||
434 | txtZoomInFactor.setModel( |
||
435 | new SpinnerNumberModel( |
||
436 | DEFAULT_ZOOM_IN_FACTOR, //initial value
|
||
437 | 1, //min |
||
438 | 1000, //max |
||
439 | 0.25 //step |
||
440 | ) |
||
441 | ); |
||
442 | txtZoomOutFactor.setModel( |
||
443 | new SpinnerNumberModel( |
||
444 | DEFAULT_ZOOM_OUT_FACTOR, //initial value
|
||
445 | 1, //min |
||
446 | 1000, //max |
||
447 | 0.25 //step |
||
448 | ) |
||
449 | ); |
||
450 | // txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
|
||
451 | // txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
|
||
452 | 43100 | jjdelcerro | this.chkInvisibleNewLayers.setSelected(false); |
453 | this.chkKeepScaleOnResizing.setSelected(false); |
||
454 | this.chkHideLegendOfNonVisibleLayers.setSelected(true); |
||
455 | this.defaultViewBackColor.set(FACTORY_DEFAULT_VIEW_BACK_COLOR);
|
||
456 | this.defaultSelectionColor.set(FACTORY_DEFAULT_SELECTION_COLOR);
|
||
457 | this.jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS);
|
||
458 | this.jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS);
|
||
459 | this.jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA);
|
||
460 | 43095 | jjdelcerro | |
461 | } |
||
462 | |||
463 | @Override
|
||
464 | public ImageIcon getIcon() { |
||
465 | return icon;
|
||
466 | } |
||
467 | |||
468 | @Override
|
||
469 | public boolean isValueChanged() { |
||
470 | return this.hasChanges; |
||
471 | } |
||
472 | |||
473 | @Override
|
||
474 | public void setChangesApplied() { |
||
475 | this.hasChanges = false; |
||
476 | } |
||
477 | |||
478 | private void initUnitsNames() { |
||
479 | if (unitsNames == null) { |
||
480 | String[] names = MapContext.getDistanceNames(); |
||
481 | unitsNames = new String[names.length]; |
||
482 | for (int i = 0; i < names.length; i++) { |
||
483 | unitsNames[i] = PluginServices.getText(this, names[i]);
|
||
484 | if (names[i].equals("Metros")) { |
||
485 | FACTORY_DEFAULT_DISTANCE_UNITS = i; |
||
486 | FACTORY_DEFAULT_DISTANCE_AREA = i; |
||
487 | FACTORY_DEFAULT_MAP_UNITS = i; |
||
488 | } |
||
489 | } |
||
490 | |||
491 | } |
||
492 | } |
||
493 | 40435 | jjdelcerro | } |