source: osm/applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java@ 22186

Last change on this file since 22186 was 22186, checked in by pieren, 16 years ago

First working version for help tool addr.

  • Property svn:eol-style set to native
File size: 23.7 KB
Line 
1// License: GPL. v2 and later. Copyright 2008-2009 by Pieren <pieren3@gmail.com> and others
2package cadastre_fr;
3
4import static org.openstreetmap.josm.tools.I18n.tr;
5
6import java.awt.GridBagLayout;
7import java.awt.event.ActionEvent;
8import java.awt.event.ActionListener;
9import javax.swing.*;
10
11import org.openstreetmap.josm.Main;
12import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
13import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
14import org.openstreetmap.josm.tools.GBC;
15import org.openstreetmap.josm.tools.I18n;
16import org.openstreetmap.josm.tools.ImageProvider;
17
18/**
19 * Preference settings for the French Cadastre plugin
20 *
21 * @author Pieren <pieren3@gmail.com>
22 */
23public class CadastrePreferenceSetting implements PreferenceSetting {
24
25 static final int TRANS_MIN = 1;
26 static final int TRANS_MAX = 10;
27 private JSlider sliderTrans = new JSlider(JSlider.HORIZONTAL, TRANS_MIN, TRANS_MAX, TRANS_MAX);
28
29 private JTextField sourcing = new JTextField(20);
30
31 private JCheckBox alterColors = new JCheckBox(tr("Replace original background by JOSM background color."));
32
33 private JCheckBox reversGrey = new JCheckBox(tr("Reverse grey colors (for black backgrounds)."));
34
35 private JCheckBox transparency = new JCheckBox(tr("Set background transparent."));
36
37 private JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data."));
38
39 private JComboBox imageInterpolationMethod = new JComboBox();
40
41 private JCheckBox disableImageCropping = new JCheckBox(tr("Disable image cropping during georeferencing."));
42
43 private JCheckBox autoFirstLayer = new JCheckBox(tr("Select first WMS layer in list."));
44
45 private JCheckBox dontUseRelation = new JCheckBox(tr("Don't use relation for addresses (but \"addr:street\" on nodes)."));
46
47 private JRadioButton grabMultiplier1 = new JRadioButton("", true);
48
49 private JRadioButton grabMultiplier2 = new JRadioButton("", true);
50
51 private JRadioButton grabMultiplier3 = new JRadioButton("", true);
52
53 private JRadioButton grabMultiplier4 = new JRadioButton("", true);
54
55 private JRadioButton crosspiece1 = new JRadioButton("off");
56
57 private JRadioButton crosspiece2 = new JRadioButton("25m");
58
59 private JRadioButton crosspiece3 = new JRadioButton("50m");
60
61 private JRadioButton crosspiece4 = new JRadioButton("100m");
62
63 private JRadioButton grabRes1 = new JRadioButton("high");
64
65 private JRadioButton grabRes2 = new JRadioButton("medium");
66
67 private JRadioButton grabRes3 = new JRadioButton("low");
68
69 private JCheckBox layerLS3 = new JCheckBox(tr("water"));
70 private JCheckBox layerLS2 = new JCheckBox(tr("building"));
71 private JCheckBox layerLS1 = new JCheckBox(tr("symbol"));
72 private JCheckBox layerParcel = new JCheckBox(tr("parcel"));
73 private JCheckBox layerLabel = new JCheckBox(tr("parcel number"));
74 private JCheckBox layerNumero = new JCheckBox(tr("address"));
75 private JCheckBox layerLieudit = new JCheckBox(tr("locality"));
76 private JCheckBox layerSection = new JCheckBox(tr("section"));
77 private JCheckBox layerCommune = new JCheckBox(tr("commune"));
78
79 static final int DEFAULT_SQUARE_SIZE = 100;
80 private JTextField grabMultiplier4Size = new JTextField(5);
81
82 private JCheckBox enableCache = new JCheckBox(tr("Enable automatic caching."));
83
84 static final int DEFAULT_CACHE_SIZE = 0; // disabled by default
85 JLabel jLabelCacheSize = new JLabel(tr("Max. cache size (in MB)"));
86 private JTextField cacheSize = new JTextField(20);
87
88 static final String DEFAULT_RASTER_DIVIDER = "5";
89 private JTextField rasterDivider = new JTextField(10);
90
91 static final int DEFAULT_CROSSPIECES = 0;
92
93 public void addGui(final PreferenceTabbedPane gui) {
94
95 String description = tr("A special handler of the French cadastre wms at www.cadastre.gouv.fr" + "<BR><BR>"
96 + "Please read the Terms and Conditions of Use here (in French): <br>"
97 + "<a href=\"http://www.cadastre.gouv.fr/scpc/html/CU_01_ConditionsGenerales_fr.html\"> "
98 + "http://www.cadastre.gouv.fr/scpc/html/CU_01_ConditionsGenerales_fr.html</a> <BR>"
99 + "before any upload of data created by this plugin.");
100 JPanel cadastrewmsMast = gui.createPreferenceTab("cadastrewms.gif", I18n.tr("French cadastre WMS"), description);
101
102 JPanel cadastrewms = new JPanel(new GridBagLayout());
103 cadastrewms.setBorder(BorderFactory.createEmptyBorder(0,0,0,0));
104
105 // option to automatically set the source tag when uploading
106 sourcing.setText(CadastrePlugin.source);
107 sourcing.setToolTipText(tr("<html>Value of key \"source\" when autosourcing is enabled</html>"));
108 JLabel jLabelSource = new JLabel(tr("Source"));
109 cadastrewms.add(jLabelSource, GBC.eop().insets(0, 0, 0, 0));
110 cadastrewms.add(sourcing, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 0, 0, 5));
111
112 // option to alter the original colors of the wms images
113 alterColors.setSelected(Main.pref.getBoolean("cadastrewms.alterColors", false));
114 alterColors.setToolTipText(tr("Replace the original white background by the backgound color defined in JOSM preferences."));
115 cadastrewms.add(alterColors, GBC.eop().insets(0, 0, 0, 0));
116
117 // option to reverse the grey colors (to see texts background)
118 reversGrey.setSelected(Main.pref.getBoolean("cadastrewms.invertGrey", false));
119 reversGrey.setToolTipText(tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds."));
120 cadastrewms.add(reversGrey, GBC.eop().insets(00, 0, 0, 0));
121
122 // option to enable transparency
123 transparency.addActionListener(new ActionListener() {
124 public void actionPerformed(ActionEvent e) {
125 sliderTrans.setEnabled(transparency.isSelected());
126 }
127 });
128 transparency.setSelected(Main.pref.getBoolean("cadastrewms.backgroundTransparent", false));
129 transparency.setToolTipText(tr("Allows multiple layers stacking"));
130 cadastrewms.add(transparency, GBC.eop().insets(0, 0, 0, 0));
131
132 // slider for transparency level
133 sliderTrans.setSnapToTicks(true);
134 sliderTrans.setToolTipText(tr("Set WMS layers transparency. Right is opaque, left is transparent."));
135 sliderTrans.setMajorTickSpacing(10);
136 sliderTrans.setMinorTickSpacing(1);
137 sliderTrans.setValue((int)(Float.parseFloat(Main.pref.get("cadastrewms.brightness", "1.0f"))*10));
138 sliderTrans.setPaintTicks(true);
139 sliderTrans.setPaintLabels(false);
140 sliderTrans.setEnabled(transparency.isSelected());
141 cadastrewms.add(sliderTrans, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 250, 0));
142
143 // option to draw boundaries of downloaded data
144 drawBoundaries.setSelected(Main.pref.getBoolean("cadastrewms.drawBoundaries", false));
145 drawBoundaries.setToolTipText(tr("Draw a rectangle around downloaded data from WMS server."));
146 cadastrewms.add(drawBoundaries, GBC.eop().insets(0, 0, 0, 5));
147
148 // option to select the single grabbed image resolution
149 JLabel jLabelRes = new JLabel(tr("Image resolution:"));
150 cadastrewms.add(jLabelRes, GBC.std().insets(0, 5, 10, 0));
151 ButtonGroup bgResolution = new ButtonGroup();
152 ActionListener resActionListener = new ActionListener() {
153 public void actionPerformed(ActionEvent actionEvent) {
154 AbstractButton button = (AbstractButton) actionEvent.getSource();
155 grabMultiplier4Size.setEnabled(button == grabMultiplier4);
156 }
157 };
158 grabRes1.addActionListener( resActionListener);
159 grabRes1.setToolTipText(tr("High resolution (1000x800)"));
160 grabRes2.addActionListener( resActionListener);
161 grabRes2.setToolTipText(tr("Medium resolution (800x600)"));
162 grabRes3.addActionListener( resActionListener);
163 grabRes3.setToolTipText(tr("Low resolution (600x400)"));
164 bgResolution.add(grabRes1);
165 bgResolution.add(grabRes2);
166 bgResolution.add(grabRes3);
167 String currentResolution = Main.pref.get("cadastrewms.resolution", "high");
168 if (currentResolution.equals("high"))
169 grabRes1.setSelected(true);
170 if (currentResolution.equals("medium"))
171 grabRes2.setSelected(true);
172 if (currentResolution.equals("low"))
173 grabRes3.setSelected(true);
174 cadastrewms.add(grabRes1, GBC.std().insets(5, 0, 5, 0));
175 cadastrewms.add(grabRes2, GBC.std().insets(5, 0, 5, 0));
176 cadastrewms.add(grabRes3, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
177
178 // option to select image zooming interpolation method
179 JLabel jLabelImageZoomInterpolation = new JLabel(tr("Image filter interpolation:"));
180 cadastrewms.add(jLabelImageZoomInterpolation, GBC.std().insets(0, 0, 10, 0));
181 imageInterpolationMethod.addItem(tr("Nearest-Neighbor (fastest) [ Default ]"));
182 imageInterpolationMethod.addItem(tr("Bilinear (fast)"));
183 imageInterpolationMethod.addItem(tr("Bicubic (slow)"));
184 String savedImageInterpolationMethod = Main.pref.get("cadastrewms.imageInterpolation", "standard");
185 if (savedImageInterpolationMethod.equals("bilinear"))
186 imageInterpolationMethod.setSelectedIndex(1);
187 else if (savedImageInterpolationMethod.equals("bicubic"))
188 imageInterpolationMethod.setSelectedIndex(2);
189 else
190 imageInterpolationMethod.setSelectedIndex(0);
191 cadastrewms.add(imageInterpolationMethod, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
192
193 // separator
194 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
195
196 // the vectorized images multiplier
197 JLabel jLabelScale = new JLabel(tr("Vector images grab multiplier:"));
198 cadastrewms.add(jLabelScale, GBC.std().insets(0, 5, 10, 0));
199 ButtonGroup bgGrabMultiplier = new ButtonGroup();
200 ActionListener multiplierActionListener = new ActionListener() {
201 public void actionPerformed(ActionEvent actionEvent) {
202 AbstractButton button = (AbstractButton) actionEvent.getSource();
203 grabMultiplier4Size.setEnabled(button == grabMultiplier4);
204 }
205 };
206 grabMultiplier1.setIcon(ImageProvider.get("preferences", "unsel_box_1"));
207 grabMultiplier1.setSelectedIcon(ImageProvider.get("preferences", "sel_box_1"));
208 grabMultiplier1.addActionListener( multiplierActionListener);
209 grabMultiplier1.setToolTipText(tr("Grab one image full screen"));
210 grabMultiplier2.setIcon(ImageProvider.get("preferences", "unsel_box_2"));
211 grabMultiplier2.setSelectedIcon(ImageProvider.get("preferences", "sel_box_2"));
212 grabMultiplier2.addActionListener( multiplierActionListener);
213 grabMultiplier2.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
214 grabMultiplier3.setIcon(ImageProvider.get("preferences", "unsel_box_3"));
215 grabMultiplier3.setSelectedIcon(ImageProvider.get("preferences", "sel_box_3"));
216 grabMultiplier3.addActionListener( multiplierActionListener);
217 grabMultiplier3.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
218 grabMultiplier4.setIcon(ImageProvider.get("preferences", "unsel_box_4"));
219 grabMultiplier4.setSelectedIcon(ImageProvider.get("preferences", "sel_box_4"));
220 grabMultiplier4.addActionListener( multiplierActionListener);
221 grabMultiplier4.setToolTipText(tr("Fixed size square (default is 100m)"));
222 bgGrabMultiplier.add(grabMultiplier1);
223 bgGrabMultiplier.add(grabMultiplier2);
224 bgGrabMultiplier.add(grabMultiplier3);
225 bgGrabMultiplier.add(grabMultiplier4);
226 String currentScale = Main.pref.get("cadastrewms.scale", "1");
227 if (currentScale.equals(Scale.X1.value))
228 grabMultiplier1.setSelected(true);
229 if (currentScale.equals(Scale.X2.value))
230 grabMultiplier2.setSelected(true);
231 if (currentScale.equals(Scale.X3.value))
232 grabMultiplier3.setSelected(true);
233 if (currentScale.equals(Scale.SQUARE_100M.value))
234 grabMultiplier4.setSelected(true);
235 cadastrewms.add(grabMultiplier1, GBC.std().insets(5, 0, 5, 0));
236 cadastrewms.add(grabMultiplier2, GBC.std().insets(5, 0, 5, 0));
237 cadastrewms.add(grabMultiplier3, GBC.std().insets(5, 0, 5, 0));
238 cadastrewms.add(grabMultiplier4, GBC.std().insets(5, 0, 5, 0));
239 int squareSize = getNumber("cadastrewms.squareSize", DEFAULT_SQUARE_SIZE);
240 grabMultiplier4Size.setText(String.valueOf(squareSize));
241 grabMultiplier4Size.setToolTipText(tr("Fixed size (from 25 to 1000 meters)"));
242 grabMultiplier4Size.setEnabled(currentScale.equals(Scale.SQUARE_100M.value));
243 cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
244
245 // WMS layers selection
246 JLabel jLabelLayers = new JLabel(tr("Layers:"));
247 cadastrewms.add(jLabelLayers, GBC.std().insets(0, 5, 10, 0));
248 layerLS3.setSelected(Main.pref.getBoolean("cadastrewms.layerWater", true));
249 layerLS3.setToolTipText(tr("See, rivers, swimming pools."));
250 cadastrewms.add(layerLS3, GBC.std().insets(5, 0, 5, 0));
251 layerLS2.setSelected(Main.pref.getBoolean("cadastrewms.layerBuilding", true));
252 layerLS2.setToolTipText(tr("Buildings, covers, underground constructions."));
253 cadastrewms.add(layerLS2, GBC.std().insets(5, 0, 5, 0));
254 layerLS1.setSelected(Main.pref.getBoolean("cadastrewms.layerSymbol", true));
255 layerLS1.setToolTipText(tr("Symbols like cristian cross."));
256 cadastrewms.add(layerLS1, GBC.std().insets(5, 0, 5, 0));
257 layerParcel.setSelected(Main.pref.getBoolean("cadastrewms.layerParcel", true));
258 layerParcel.setToolTipText(tr("Parcels."));
259 cadastrewms.add(layerParcel, GBC.eop().insets(5, 0, 5, 0));
260 layerLabel.setSelected(Main.pref.getBoolean("cadastrewms.layerLabel", true));
261 layerLabel.setToolTipText(tr("Parcels numbers, street names."));
262 cadastrewms.add(layerLabel, GBC.std().insets(70, 0, 5, 0));
263 layerNumero.setSelected(Main.pref.getBoolean("cadastrewms.layerNumero", true));
264 layerNumero.setToolTipText(tr("Address, houses numbers."));
265 cadastrewms.add(layerNumero, GBC.std().insets(5, 0, 5, 0));
266 layerLieudit.setSelected(Main.pref.getBoolean("cadastrewms.layerLieudit", true));
267 layerLieudit.setToolTipText(tr("Locality, hamlet, place."));
268 cadastrewms.add(layerLieudit, GBC.std().insets(5, 0, 5, 0));
269 layerSection.setSelected(Main.pref.getBoolean("cadastrewms.layerSection", true));
270 layerSection.setToolTipText(tr("Cadastral sections and subsections."));
271 cadastrewms.add(layerSection, GBC.std().insets(5, 0, 5, 0));
272 layerCommune.setSelected(Main.pref.getBoolean("cadastrewms.layerCommune", true));
273 layerCommune.setToolTipText(tr("Municipality administrative borders."));
274 cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
275
276 // separator
277 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
278
279 // for raster images (not vectorized), image grab divider (from 1 to 12)
280 String savedRasterDivider = Main.pref.get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER);
281 JLabel jLabelRasterDivider = new JLabel(tr("Raster images grab multiplier:"));
282 rasterDivider.setText(savedRasterDivider);
283 rasterDivider.setToolTipText("Raster image grab division, from 1 to 12; 12 is very high definition");
284 cadastrewms.add(jLabelRasterDivider, GBC.std().insets(0, 5, 10, 0));
285 cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
286 // option to disable image cropping during raster image georeferencing
287 disableImageCropping.setSelected(Main.pref.getBoolean("cadastrewms.noImageCropping", false));
288 disableImageCropping.setToolTipText(tr("Disable image cropping during georeferencing."));
289 cadastrewms.add(disableImageCropping, GBC.eop().insets(0, 0, 0, 0));
290 // the crosspiece display
291 JLabel jLabelCrosspieces = new JLabel(tr("Display crosspieces:"));
292 cadastrewms.add(jLabelCrosspieces, GBC.std().insets(0, 0, 10, 0));
293 ButtonGroup bgCrosspieces = new ButtonGroup();
294 int crosspieces = getNumber("cadastrewms.crosspieces", DEFAULT_CROSSPIECES);
295 if (crosspieces == 0) crosspiece1.setSelected(true);
296 if (crosspieces == 1) crosspiece2.setSelected(true);
297 if (crosspieces == 2) crosspiece3.setSelected(true);
298 if (crosspieces == 3) crosspiece4.setSelected(true);
299 bgCrosspieces.add(crosspiece1);
300 bgCrosspieces.add(crosspiece2);
301 bgCrosspieces.add(crosspiece3);
302 bgCrosspieces.add(crosspiece4);
303 cadastrewms.add(crosspiece1, GBC.std().insets(5, 0, 5, 0));
304 cadastrewms.add(crosspiece2, GBC.std().insets(5, 0, 5, 0));
305 cadastrewms.add(crosspiece3, GBC.std().insets(5, 0, 5, 0));
306 cadastrewms.add(crosspiece4, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
307
308 // separator
309 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
310
311 // option to enable automatic caching
312 enableCache.addActionListener(new ActionListener() {
313 public void actionPerformed(ActionEvent e) {
314 jLabelCacheSize.setEnabled(enableCache.isSelected());
315 cacheSize.setEnabled(enableCache.isSelected());
316 }
317 });
318 enableCache.setSelected(Main.pref.getBoolean("cadastrewms.enableCaching", true));
319 enableCache.setToolTipText(tr("Replace the original white background by the backgound color defined in JOSM preferences."));
320 cadastrewms.add(enableCache, GBC.eop().insets(0, 0, 0, 0));
321
322 // option to fix the cache size(in MB)
323 int size = getNumber("cadastrewms.cacheSize", DEFAULT_CACHE_SIZE);
324 cacheSize.setText(String.valueOf(size));
325 cacheSize.setToolTipText(tr("Oldest files are automatically deleted when this size is exceeded"));
326 cadastrewms.add(jLabelCacheSize, GBC.std().insets(20, 0, 0, 0));
327 cadastrewms.add(cacheSize, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
328
329 // separator
330 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
331
332 // option to select the first WMS layer
333 autoFirstLayer.setSelected(Main.pref.getBoolean("cadastrewms.autoFirstLayer", false));
334 autoFirstLayer.setToolTipText(tr("Automatically selects the first WMS layer if multiple layers exist when grabbing."));
335 cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0));
336
337 // separator
338 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
339
340 // option to use or not relations in addresses
341 dontUseRelation.setSelected(Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false));
342 dontUseRelation.setToolTipText(tr("Enable this to use the tag \"add:street\" on nodes."));
343 cadastrewms.add(dontUseRelation, GBC.eop().insets(0, 0, 0, 0));
344
345 // end of dialog, scroll bar
346 cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
347 JScrollPane scrollpane = new JScrollPane(cadastrewms);
348 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
349 cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH));
350 }
351
352 public boolean ok() {
353 Main.pref.put("cadastrewms.source", sourcing.getText());
354 CadastrePlugin.source = sourcing.getText();
355 Main.pref.put("cadastrewms.alterColors", alterColors.isSelected());
356 Main.pref.put("cadastrewms.invertGrey", reversGrey.isSelected());
357 Main.pref.put("cadastrewms.backgroundTransparent", transparency.isSelected());
358 Main.pref.put("cadastrewms.brightness", Float.toString((float)sliderTrans.getValue()/10));
359 Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
360 if (grabRes1.isSelected())
361 Main.pref.put("cadastrewms.resolution", "high");
362 else if (grabRes2.isSelected())
363 Main.pref.put("cadastrewms.resolution", "medium");
364 else if (grabRes3.isSelected())
365 Main.pref.put("cadastrewms.resolution", "low");
366 if (imageInterpolationMethod.getSelectedIndex() == 2)
367 Main.pref.put("cadastrewms.imageInterpolation", "bicubic");
368 else if (imageInterpolationMethod.getSelectedIndex() == 1)
369 Main.pref.put("cadastrewms.imageInterpolation", "bilinear");
370 else
371 Main.pref.put("cadastrewms.imageInterpolation", "standard");
372 if (grabMultiplier1.isSelected())
373 Main.pref.put("cadastrewms.scale", Scale.X1.toString());
374 else if (grabMultiplier2.isSelected())
375 Main.pref.put("cadastrewms.scale", Scale.X2.toString());
376 else if (grabMultiplier3.isSelected())
377 Main.pref.put("cadastrewms.scale", Scale.X3.toString());
378 else {
379 Main.pref.put("cadastrewms.scale", Scale.SQUARE_100M.toString());
380 try {
381 int squareSize = Integer.parseInt(grabMultiplier4Size.getText());
382 if (squareSize >= 25 && squareSize <= 1000)
383 Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());
384 } catch (NumberFormatException e) { // ignore the last input
385 }
386 }
387 Main.pref.put("cadastrewms.layerWater", layerLS3.isSelected());
388 Main.pref.put("cadastrewms.layerBuilding", layerLS2.isSelected());
389 Main.pref.put("cadastrewms.layerSymbol", layerLS1.isSelected());
390 Main.pref.put("cadastrewms.layerParcel", layerParcel.isSelected());
391 Main.pref.put("cadastrewms.layerLabel", layerLabel.isSelected());
392 Main.pref.put("cadastrewms.layerNumero", layerNumero.isSelected());
393 Main.pref.put("cadastrewms.layerLieudit", layerLieudit.isSelected());
394 Main.pref.put("cadastrewms.layerSection", layerSection.isSelected());
395 Main.pref.put("cadastrewms.layerCommune", layerCommune.isSelected());
396 try {
397 int i = Integer.parseInt(rasterDivider.getText());
398 if (i > 0 && i < 13)
399 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));
400 } catch (NumberFormatException e) { // ignore the last input
401 }
402 Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected());
403 if (crosspiece1.isSelected()) Main.pref.put("cadastrewms.crosspieces", "0");
404 else if (crosspiece2.isSelected()) Main.pref.put("cadastrewms.crosspieces", "1");
405 else if (crosspiece3.isSelected()) Main.pref.put("cadastrewms.crosspieces", "2");
406 else if (crosspiece4.isSelected()) Main.pref.put("cadastrewms.crosspieces", "3");
407 Main.pref.put("cadastrewms.enableCaching", enableCache.isSelected());
408
409 // spread data into objects instead of restarting the application
410 try {
411 CacheControl.cacheSize = Integer.parseInt(cacheSize.getText());
412 Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize));
413 } catch (NumberFormatException e) { // ignore the last input
414 }
415 Main.pref.put("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
416 CacheControl.cacheEnabled = enableCache.isSelected();
417 Main.pref.put("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
418 CadastrePlugin.refreshConfiguration();
419 CadastrePlugin.refreshMenu();
420
421 return false;
422 }
423
424 private int getNumber(String pref_parameter, int def_value) {
425 try {
426 return Integer.parseInt(Main.pref.get(pref_parameter, String.valueOf(def_value)));
427 } catch (NumberFormatException e) {
428 return def_value;
429 }
430 }
431}
Note: See TracBrowser for help on using the repository browser.