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 @ 43983
History | View | Annotate | Download (18.5 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 | 43415 | jjdelcerro | private static String[] areaUnitsNames = null; |
88 | 41414 | fdiaz | |
89 | 43095 | jjdelcerro | private static final double DEFAULT_ZOOM_IN_FACTOR = 2.0; |
90 | private static final double DEFAULT_ZOOM_OUT_FACTOR = 0.5; |
||
91 | private static final Color FACTORY_DEFAULT_SELECTION_COLOR = Color.YELLOW; |
||
92 | private static final Color FACTORY_DEFAULT_VIEW_BACK_COLOR = Color.WHITE; |
||
93 | private static int FACTORY_DEFAULT_MAP_UNITS; |
||
94 | private static int FACTORY_DEFAULT_DISTANCE_UNITS; |
||
95 | private static int FACTORY_DEFAULT_DISTANCE_AREA; |
||
96 | 41414 | fdiaz | |
97 | 43095 | jjdelcerro | private final ImageIcon icon; |
98 | 41414 | fdiaz | |
99 | 43095 | jjdelcerro | private ProjectionController defaultProjection = null; |
100 | private ColorChooserController defaultViewBackColor = null; |
||
101 | private ColorChooserController defaultSelectionColor = null; |
||
102 | 41414 | fdiaz | |
103 | 43095 | jjdelcerro | private boolean hasChanges = false; |
104 | 40435 | jjdelcerro | |
105 | 43095 | jjdelcerro | private static class ProjectionController implements ActionListener { |
106 | 40435 | jjdelcerro | |
107 | 43095 | jjdelcerro | private static final long serialVersionUID = -1442364274073324390L; |
108 | 40435 | jjdelcerro | |
109 | 43095 | jjdelcerro | private final JTextField txtLabel; |
110 | private final JButton btnShowDialog; |
||
111 | private IProjection proj = null; |
||
112 | private ChangeListener changeListener; |
||
113 | 40435 | jjdelcerro | |
114 | 43095 | jjdelcerro | public ProjectionController(JTextField txtLabel, JButton btnShowDialog) { |
115 | this.txtLabel = txtLabel;
|
||
116 | this.btnShowDialog = btnShowDialog;
|
||
117 | 40435 | jjdelcerro | |
118 | 43095 | jjdelcerro | this.btnShowDialog.addActionListener(this); |
119 | this.set(null); |
||
120 | } |
||
121 | 40435 | jjdelcerro | |
122 | 43095 | jjdelcerro | public void addChangeListener(ChangeListener changeListener) { |
123 | this.changeListener = changeListener;
|
||
124 | } |
||
125 | 40435 | jjdelcerro | |
126 | 43095 | jjdelcerro | public void fireChanged() { |
127 | if (this.changeListener != null) { |
||
128 | this.changeListener.stateChanged(null); |
||
129 | } |
||
130 | } |
||
131 | 40435 | jjdelcerro | |
132 | 43095 | jjdelcerro | public void set(IProjection proj) { |
133 | this.proj = proj;
|
||
134 | if (this.proj == null) { |
||
135 | this.txtLabel.setText(""); |
||
136 | } else {
|
||
137 | this.txtLabel.setText(proj.getAbrev());
|
||
138 | } |
||
139 | } |
||
140 | 41414 | fdiaz | |
141 | 43095 | jjdelcerro | public IProjection get() {
|
142 | return this.proj; |
||
143 | } |
||
144 | 40435 | jjdelcerro | |
145 | 43095 | jjdelcerro | @Override
|
146 | public void actionPerformed(ActionEvent e) { |
||
147 | ISelectCrsPanel panel = CRSSelectPanel.getUIFactory().getSelectCrsPanel( |
||
148 | CRSFactory.getCRS(this.txtLabel.getText()), false); |
||
149 | 43213 | jjdelcerro | ToolsSwingLocator.getWindowManager().showWindow( |
150 | panel.asJComponent(), |
||
151 | ToolsLocator.getI18nManager().getTranslation("selecciona_sistema_de_referencia"),
|
||
152 | WindowManager.MODE.DIALOG |
||
153 | ); |
||
154 | 43095 | jjdelcerro | if (panel.isOkPressed()) {
|
155 | this.set(panel.getProjection());
|
||
156 | this.fireChanged();
|
||
157 | } |
||
158 | } |
||
159 | 41414 | fdiaz | |
160 | 43095 | jjdelcerro | } |
161 | 41414 | fdiaz | |
162 | 43095 | jjdelcerro | private static class ColorChooserController implements ActionListener, ChangeListener { |
163 | 40435 | jjdelcerro | |
164 | 43095 | jjdelcerro | private final JTextField txtLabel; |
165 | private final JButton btnShowDialog; |
||
166 | private final JSlider sldAlpha; |
||
167 | private Color color; |
||
168 | private boolean allowNull; |
||
169 | private ChangeListener changeListener; |
||
170 | 40435 | jjdelcerro | |
171 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha, boolean allowNull) { |
172 | this.txtLabel = txtLabel;
|
||
173 | this.btnShowDialog = btnShowDialog;
|
||
174 | this.sldAlpha = sldAlpha;
|
||
175 | this.btnShowDialog.addActionListener(this); |
||
176 | if (this.sldAlpha != null) { |
||
177 | this.sldAlpha.addChangeListener(this); |
||
178 | } |
||
179 | this.allowNull = allowNull;
|
||
180 | if (!this.allowNull) { |
||
181 | this.color = Color.BLACK; |
||
182 | } |
||
183 | } |
||
184 | 40435 | jjdelcerro | |
185 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog) { |
186 | this(txtLabel, btnShowDialog, null, false); |
||
187 | } |
||
188 | 40435 | jjdelcerro | |
189 | 43095 | jjdelcerro | public ColorChooserController(JTextField txtLabel, JButton btnShowDialog, JSlider sldAlpha) { |
190 | this(txtLabel, btnShowDialog, sldAlpha, false); |
||
191 | } |
||
192 | 40435 | jjdelcerro | |
193 | 43095 | jjdelcerro | @Override
|
194 | public void stateChanged(ChangeEvent e) { |
||
195 | if (this.color == null) { |
||
196 | set(Color.BLACK);
|
||
197 | } |
||
198 | if (this.sldAlpha == null) { |
||
199 | this.color = new Color( |
||
200 | color.getRed(), |
||
201 | color.getGreen(), |
||
202 | color.getBlue() |
||
203 | ); |
||
204 | } else {
|
||
205 | this.color = new Color( |
||
206 | color.getRed(), |
||
207 | color.getGreen(), |
||
208 | color.getBlue(), |
||
209 | this.sldAlpha.getValue()
|
||
210 | ); |
||
211 | } |
||
212 | this.txtLabel.setBackground(this.color); |
||
213 | } |
||
214 | 40435 | jjdelcerro | |
215 | 43095 | jjdelcerro | public void addChangeListener(ChangeListener changeListener) { |
216 | this.changeListener = changeListener;
|
||
217 | } |
||
218 | 40435 | jjdelcerro | |
219 | 43095 | jjdelcerro | public void fireChanged() { |
220 | if (this.changeListener != null) { |
||
221 | this.changeListener.stateChanged(null); |
||
222 | } |
||
223 | } |
||
224 | 40435 | jjdelcerro | |
225 | 43095 | jjdelcerro | @Override
|
226 | public void actionPerformed(ActionEvent e) { |
||
227 | Color c = JColorChooser.showDialog( |
||
228 | SwingUtilities.windowForComponent(this.btnShowDialog), |
||
229 | Messages.getText("choose_color"),
|
||
230 | this.get()
|
||
231 | ); |
||
232 | if (c == null) { |
||
233 | return;
|
||
234 | } |
||
235 | set(c); |
||
236 | } |
||
237 | 40435 | jjdelcerro | |
238 | 43095 | jjdelcerro | private void set(Color color) { |
239 | if (color == null) { |
||
240 | if (allowNull) {
|
||
241 | this.color = null; |
||
242 | return;
|
||
243 | } |
||
244 | color = Color.BLACK;
|
||
245 | } |
||
246 | this.color = color;
|
||
247 | this.txtLabel.setBackground(this.color); |
||
248 | if (this.sldAlpha != null) { |
||
249 | this.sldAlpha.setValue(this.color.getAlpha()); |
||
250 | } |
||
251 | } |
||
252 | 40435 | jjdelcerro | |
253 | 43095 | jjdelcerro | public Color get() { |
254 | return this.color; |
||
255 | } |
||
256 | 40435 | jjdelcerro | |
257 | 43095 | jjdelcerro | } |
258 | 40435 | jjdelcerro | |
259 | 43095 | jjdelcerro | /**
|
260 | * Creates a new panel containing View preferences settings.
|
||
261 | *
|
||
262 | */
|
||
263 | public ViewPage() {
|
||
264 | super();
|
||
265 | 40435 | jjdelcerro | |
266 | 43095 | jjdelcerro | initUnitsNames(); |
267 | 40435 | jjdelcerro | |
268 | 43095 | jjdelcerro | icon = IconThemeHelper.getImageIcon("document-view-icon");
|
269 | 40435 | jjdelcerro | |
270 | 43095 | jjdelcerro | this.chkKeepScaleOnResizing.setEnabled(false); |
271 | |||
272 | this.defaultProjection = new ProjectionController( |
||
273 | this.txtDefaultProjection,
|
||
274 | this.btnChangeProjection
|
||
275 | ); |
||
276 | this.defaultProjection.addChangeListener(this); |
||
277 | 40435 | jjdelcerro | |
278 | 43095 | jjdelcerro | this.defaultSelectionColor = new ColorChooserController( |
279 | this.txtDefaultSelectionColor,
|
||
280 | this.btnDefaultSelectionColor,
|
||
281 | this.sldDefaultSelectionColor
|
||
282 | ); |
||
283 | this.defaultSelectionColor.addChangeListener(this); |
||
284 | 40435 | jjdelcerro | |
285 | 43095 | jjdelcerro | this.defaultViewBackColor = new ColorChooserController( |
286 | this.txtDefaultViewBackColor,
|
||
287 | this.btnDefaultViewBackColor
|
||
288 | ); |
||
289 | this.defaultViewBackColor.addChangeListener(this); |
||
290 | 40435 | jjdelcerro | |
291 | 43095 | jjdelcerro | this.chkInvisibleNewLayers.addChangeListener(this); |
292 | this.chkKeepScaleOnResizing.addChangeListener(this); |
||
293 | 40435 | jjdelcerro | |
294 | 43095 | jjdelcerro | this.jCmbDistanceArea.addItemListener(this); |
295 | this.jCmbDistanceUnits.addItemListener(this); |
||
296 | this.jCmbMapUnits.addItemListener(this); |
||
297 | 40435 | jjdelcerro | |
298 | 43095 | jjdelcerro | this.translateAll();
|
299 | this.initializeValues();
|
||
300 | } |
||
301 | 40435 | jjdelcerro | |
302 | 43095 | jjdelcerro | private void translateAll() { |
303 | 43415 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
304 | 42439 | dmartinezizquierdo | |
305 | 43415 | jjdelcerro | this.lblDefaultProjection.setText(i18n.getTranslation("default_projection")); |
306 | this.chkInvisibleNewLayers.setText(i18n.getTranslation("options.view.invisible_new_layers")); |
||
307 | this.chkKeepScaleOnResizing.setText(i18n.getTranslation("options.view.keep_scale_on_resizing")); |
||
308 | this.lblZoomInFactor.setText(i18n.getTranslation("zoom_in_factor")); |
||
309 | this.lblZoomOutFactor.setText(i18n.getTranslation("zoom_out_factor")); |
||
310 | this.lblDefaultViewBackColor.setText(i18n.getTranslation("options.view.default_view_back_color")); |
||
311 | this.lblDefaultSelectionColor.setText(i18n.getTranslation("options.view.default_selection_color")); |
||
312 | this.lblMapUnits.setText(i18n.getTranslation("map_units")); |
||
313 | this.lblDistanceUnits.setText(i18n.getTranslation("distance_units")); |
||
314 | this.lblDistanceArea.setText(i18n.getTranslation("distance_area")); |
||
315 | this.chkHideLegendOfNonVisibleLayers.setText(i18n.getTranslation("_Hide_legend_of_non_visible_layers")); |
||
316 | this.chkOpenWithANewMaximizedView.setText(i18n.getTranslation("_Open_with_a_new_maximized_view")); |
||
317 | this.btnChangeProjection.setText(i18n.getTranslation("_Change")); |
||
318 | this.lblAlpha.setText(i18n.getTranslation("Alpha")); |
||
319 | 43095 | jjdelcerro | } |
320 | 40435 | jjdelcerro | |
321 | 43095 | jjdelcerro | @Override
|
322 | public boolean isResizeable() { |
||
323 | return true; |
||
324 | } |
||
325 | 42439 | dmartinezizquierdo | |
326 | 43095 | jjdelcerro | @Override
|
327 | public void initializeValues() { |
||
328 | Double zif;
|
||
329 | Double zof;
|
||
330 | 40435 | jjdelcerro | |
331 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
332 | PluginServices plugin = PluginsLocator.getManager().getPlugin(this);
|
||
333 | DynObject props = plugin.getPluginProperties(); |
||
334 | XMLEntity xml = plugin.getPersistentXML(); |
||
335 | 40435 | jjdelcerro | |
336 | 43095 | jjdelcerro | this.defaultProjection.set(projectPreferences.getDefaultProjection());
|
337 | 40435 | jjdelcerro | |
338 | 43100 | jjdelcerro | this.chkInvisibleNewLayers.setSelected(projectPreferences.getAddNewLayersInInvisibleMode());
|
339 | this.chkKeepScaleOnResizing.setSelected(projectPreferences.getKeepScaleOnResizing());
|
||
340 | this.chkOpenWithANewMaximizedView.setSelected(projectPreferences.getOpenWithANewMaximizedView());
|
||
341 | this.chkHideLegendOfNonVisibleLayers.setSelected(projectPreferences.getHideLegendInToCOfNonVisibleLayers());
|
||
342 | this.txtZoomInFactor.setModel(
|
||
343 | 43095 | jjdelcerro | new SpinnerNumberModel( |
344 | projectPreferences.getZoomInFactor(), //initial value
|
||
345 | 0.01, //min |
||
346 | 1000, //max |
||
347 | 0.25 //step |
||
348 | ) |
||
349 | ); |
||
350 | 43100 | jjdelcerro | this.txtZoomOutFactor.setModel(
|
351 | 43095 | jjdelcerro | new SpinnerNumberModel( |
352 | 43100 | jjdelcerro | projectPreferences.getZoomOutFactor(), //initial value
|
353 | 43095 | jjdelcerro | 0.01, //min |
354 | 1000, //max |
||
355 | 0.25 //step |
||
356 | ) |
||
357 | ); |
||
358 | MapContext.ZOOMINFACTOR = projectPreferences.getZoomInFactor(); |
||
359 | MapContext.ZOOMOUTFACTOR = projectPreferences.getZoomOutFactor(); |
||
360 | 40435 | jjdelcerro | |
361 | 43095 | jjdelcerro | this.defaultViewBackColor.set(projectPreferences.getDefaultViewBackColor());
|
362 | this.defaultSelectionColor.set(projectPreferences.getDefaultSelectionColor());
|
||
363 | 40435 | jjdelcerro | |
364 | 43095 | jjdelcerro | this.jCmbMapUnits.setModel(new DefaultComboBoxModel(unitsNames)); |
365 | this.jCmbMapUnits.setSelectedIndex(projectPreferences.getDefaultMapUnits());
|
||
366 | 41414 | fdiaz | |
367 | 43095 | jjdelcerro | this.jCmbDistanceUnits.setModel(new DefaultComboBoxModel(unitsNames)); |
368 | this.jCmbDistanceUnits.setSelectedIndex(projectPreferences.getDefaultDistanceUnits());
|
||
369 | 40435 | jjdelcerro | |
370 | 43415 | jjdelcerro | this.jCmbDistanceArea.setModel(new DefaultComboBoxModel(areaUnitsNames)); |
371 | 43095 | jjdelcerro | this.jCmbDistanceArea.setSelectedIndex(projectPreferences.getDefaultDistanceArea());
|
372 | } |
||
373 | 40435 | jjdelcerro | |
374 | 43095 | jjdelcerro | @Override
|
375 | public void stateChanged(ChangeEvent e) { |
||
376 | this.hasChanges = true; |
||
377 | } |
||
378 | 40435 | jjdelcerro | |
379 | 43095 | jjdelcerro | @Override
|
380 | public void itemStateChanged(ItemEvent e) { |
||
381 | this.hasChanges = true; |
||
382 | } |
||
383 | 40435 | jjdelcerro | |
384 | 43095 | jjdelcerro | @Override
|
385 | public String getID() { |
||
386 | return id;
|
||
387 | } |
||
388 | 40435 | jjdelcerro | |
389 | 43095 | jjdelcerro | @Override
|
390 | public String getTitle() { |
||
391 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
392 | return i18nManager.getTranslation("Vista"); |
||
393 | } |
||
394 | 40435 | jjdelcerro | |
395 | 43095 | jjdelcerro | @Override
|
396 | public JPanel getPanel() { |
||
397 | return this; |
||
398 | } |
||
399 | 40435 | jjdelcerro | |
400 | 43095 | jjdelcerro | @Override
|
401 | public void storeValues() throws StoreException { |
||
402 | 40435 | jjdelcerro | |
403 | 43095 | jjdelcerro | ProjectPreferences projectPreferences = ApplicationLocator.getProjectManager().getProjectPreferences(); |
404 | 40435 | jjdelcerro | |
405 | 43095 | jjdelcerro | try {
|
406 | double zif = (double) txtZoomInFactor.getValue(); |
||
407 | double zof = (double) txtZoomOutFactor.getValue(); |
||
408 | if (zif == 0 || zof == 0) { |
||
409 | throw new NumberFormatException(); |
||
410 | } |
||
411 | 40435 | jjdelcerro | |
412 | 43095 | jjdelcerro | projectPreferences.setZoomInFactor(zif); |
413 | projectPreferences.setZoomOutFactor(zof); |
||
414 | MapContext.ZOOMINFACTOR = zif; |
||
415 | MapContext.ZOOMOUTFACTOR = zof; |
||
416 | 40435 | jjdelcerro | |
417 | 43095 | jjdelcerro | projectPreferences.setDefaultProjection(this.defaultProjection.get());
|
418 | projectPreferences.setDefaultSelectionColor(defaultSelectionColor.get()); |
||
419 | projectPreferences.setDefaultViewBackColor(defaultViewBackColor.get()); |
||
420 | 40435 | jjdelcerro | |
421 | 43095 | jjdelcerro | projectPreferences.setDefaultMapUnits(jCmbMapUnits.getSelectedIndex()); |
422 | projectPreferences.setDefaultDistanceUnits(jCmbDistanceUnits.getSelectedIndex()); |
||
423 | projectPreferences.setDefaultDistanceArea(jCmbDistanceArea.getSelectedIndex()); |
||
424 | 40435 | jjdelcerro | |
425 | 43095 | jjdelcerro | projectPreferences.setAddNewLayersInInvisibleMode(chkInvisibleNewLayers.isSelected()); |
426 | projectPreferences.setKeepScaleOnResizing(chkKeepScaleOnResizing.isSelected()); |
||
427 | projectPreferences.setOpenWithANewMaximizedView(chkOpenWithANewMaximizedView.isSelected()); |
||
428 | 43100 | jjdelcerro | projectPreferences.setHideLegendInToCOfNonVisibleLayers(this.chkHideLegendOfNonVisibleLayers.isSelected());
|
429 | |||
430 | 43095 | jjdelcerro | } catch (Exception e) { |
431 | throw new StoreException(PluginServices.getText(this, "factor_zoom_incorrecto")); |
||
432 | } |
||
433 | } |
||
434 | |||
435 | @Override
|
||
436 | public void initializeDefaults() { |
||
437 | defaultProjection.set(FACTORY_DEFAULT_PROJECTION); |
||
438 | txtZoomInFactor.setModel( |
||
439 | new SpinnerNumberModel( |
||
440 | DEFAULT_ZOOM_IN_FACTOR, //initial value
|
||
441 | 1, //min |
||
442 | 1000, //max |
||
443 | 0.25 //step |
||
444 | ) |
||
445 | ); |
||
446 | txtZoomOutFactor.setModel( |
||
447 | new SpinnerNumberModel( |
||
448 | DEFAULT_ZOOM_OUT_FACTOR, //initial value
|
||
449 | 1, //min |
||
450 | 1000, //max |
||
451 | 0.25 //step |
||
452 | ) |
||
453 | ); |
||
454 | // txtZoomInFactor.setText(String.valueOf(DEFAULT_ZOOM_IN_FACTOR));
|
||
455 | // txtZoomOutFactor.setText(String.valueOf(DEFAULT_ZOOM_OUT_FACTOR));
|
||
456 | 43100 | jjdelcerro | this.chkInvisibleNewLayers.setSelected(false); |
457 | this.chkKeepScaleOnResizing.setSelected(false); |
||
458 | this.chkHideLegendOfNonVisibleLayers.setSelected(true); |
||
459 | this.defaultViewBackColor.set(FACTORY_DEFAULT_VIEW_BACK_COLOR);
|
||
460 | this.defaultSelectionColor.set(FACTORY_DEFAULT_SELECTION_COLOR);
|
||
461 | this.jCmbMapUnits.setSelectedIndex(FACTORY_DEFAULT_MAP_UNITS);
|
||
462 | this.jCmbDistanceUnits.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_UNITS);
|
||
463 | this.jCmbDistanceArea.setSelectedIndex(FACTORY_DEFAULT_DISTANCE_AREA);
|
||
464 | 43095 | jjdelcerro | |
465 | } |
||
466 | |||
467 | @Override
|
||
468 | public ImageIcon getIcon() { |
||
469 | return icon;
|
||
470 | } |
||
471 | |||
472 | @Override
|
||
473 | public boolean isValueChanged() { |
||
474 | return this.hasChanges; |
||
475 | } |
||
476 | |||
477 | @Override
|
||
478 | public void setChangesApplied() { |
||
479 | this.hasChanges = false; |
||
480 | } |
||
481 | |||
482 | private void initUnitsNames() { |
||
483 | 43415 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
484 | 43095 | jjdelcerro | if (unitsNames == null) { |
485 | String[] names = MapContext.getDistanceNames(); |
||
486 | unitsNames = new String[names.length]; |
||
487 | for (int i = 0; i < names.length; i++) { |
||
488 | 43415 | jjdelcerro | unitsNames[i] = i18n.getTranslation(names[i]); |
489 | 43095 | jjdelcerro | if (names[i].equals("Metros")) { |
490 | FACTORY_DEFAULT_DISTANCE_UNITS = i; |
||
491 | FACTORY_DEFAULT_DISTANCE_AREA = i; |
||
492 | FACTORY_DEFAULT_MAP_UNITS = i; |
||
493 | } |
||
494 | } |
||
495 | } |
||
496 | 43415 | jjdelcerro | if( areaUnitsNames == null ) { |
497 | String[] names = MapContext.getAreaNames(); |
||
498 | areaUnitsNames = new String[names.length]; |
||
499 | for (int i = 0; i < names.length; i++) { |
||
500 | 43441 | jjdelcerro | areaUnitsNames[i] = i18n.getTranslation(names[i])+MapContext.getOfLinear(i); |
501 | 43415 | jjdelcerro | } |
502 | } |
||
503 | 43095 | jjdelcerro | } |
504 | 40435 | jjdelcerro | } |