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

Last change on this file since 27788 was 27484, checked in by pieren, 13 years ago

Fix grab resolution preferences solving the "plan image" in portrait format.

  • 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 enableTableauAssemblage = new JCheckBox(tr("Use \"Tableau d''assemblage\""));
44
45 private JCheckBox autoFirstLayer = new JCheckBox(tr("Select first WMS layer in list."));
46
47 private JCheckBox dontUseRelation = new JCheckBox(tr("Don''t use relation for addresses (but \"addr:street\" on elements)."));
48
49 private JRadioButton grabMultiplier1 = new JRadioButton("", true);
50
51 private JRadioButton grabMultiplier2 = new JRadioButton("", true);
52
53 private JRadioButton grabMultiplier3 = new JRadioButton("", true);
54
55 private JRadioButton grabMultiplier4 = new JRadioButton("", true);
56
57 private JRadioButton crosspiece1 = new JRadioButton(tr("off"));
58
59 private JRadioButton crosspiece2 = new JRadioButton(tr("25 m"));
60
61 private JRadioButton crosspiece3 = new JRadioButton(tr("50 m"));
62
63 private JRadioButton crosspiece4 = new JRadioButton(tr("100 m"));
64
65 private JRadioButton grabRes1 = new JRadioButton(tr("high"));
66 private JRadioButton grabRes2 = new JRadioButton(tr("medium"));
67 private JRadioButton grabRes3 = new JRadioButton(tr("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 background 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 grabRes1.setToolTipText(tr("High resolution (1000x800)"));
153 grabRes2.setToolTipText(tr("Medium resolution (800x600)"));
154 grabRes3.setToolTipText(tr("Low resolution (600x400)"));
155 bgResolution.add(grabRes1);
156 bgResolution.add(grabRes2);
157 bgResolution.add(grabRes3);
158 String currentResolution = Main.pref.get("cadastrewms.resolution", "high");
159 if (currentResolution.equals("high"))
160 grabRes1.setSelected(true);
161 if (currentResolution.equals("medium"))
162 grabRes2.setSelected(true);
163 if (currentResolution.equals("low"))
164 grabRes3.setSelected(true);
165 cadastrewms.add(grabRes1, GBC.std().insets(5, 0, 5, 0));
166 cadastrewms.add(grabRes2, GBC.std().insets(5, 0, 5, 0));
167 cadastrewms.add(grabRes3, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
168
169 // option to select image zooming interpolation method
170 JLabel jLabelImageZoomInterpolation = new JLabel(tr("Image filter interpolation:"));
171 cadastrewms.add(jLabelImageZoomInterpolation, GBC.std().insets(0, 0, 10, 0));
172 imageInterpolationMethod.addItem(tr("Nearest-Neighbor (fastest) [ Default ]"));
173 imageInterpolationMethod.addItem(tr("Bilinear (fast)"));
174 imageInterpolationMethod.addItem(tr("Bicubic (slow)"));
175 String savedImageInterpolationMethod = Main.pref.get("cadastrewms.imageInterpolation", "standard");
176 if (savedImageInterpolationMethod.equals("bilinear"))
177 imageInterpolationMethod.setSelectedIndex(1);
178 else if (savedImageInterpolationMethod.equals("bicubic"))
179 imageInterpolationMethod.setSelectedIndex(2);
180 else
181 imageInterpolationMethod.setSelectedIndex(0);
182 cadastrewms.add(imageInterpolationMethod, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
183
184 // separator
185 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
186
187 // the vectorized images multiplier
188 JLabel jLabelScale = new JLabel(tr("Vector images grab multiplier:"));
189 cadastrewms.add(jLabelScale, GBC.std().insets(0, 5, 10, 0));
190 ButtonGroup bgGrabMultiplier = new ButtonGroup();
191 ActionListener multiplierActionListener = new ActionListener() {
192 public void actionPerformed(ActionEvent actionEvent) {
193 AbstractButton button = (AbstractButton) actionEvent.getSource();
194 grabMultiplier4Size.setEnabled(button == grabMultiplier4);
195 }
196 };
197 grabMultiplier1.setIcon(ImageProvider.get("preferences", "unsel_box_1"));
198 grabMultiplier1.setSelectedIcon(ImageProvider.get("preferences", "sel_box_1"));
199 grabMultiplier1.addActionListener( multiplierActionListener);
200 grabMultiplier1.setToolTipText(tr("Grab one image full screen"));
201 grabMultiplier2.setIcon(ImageProvider.get("preferences", "unsel_box_2"));
202 grabMultiplier2.setSelectedIcon(ImageProvider.get("preferences", "sel_box_2"));
203 grabMultiplier2.addActionListener( multiplierActionListener);
204 grabMultiplier2.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
205 grabMultiplier3.setIcon(ImageProvider.get("preferences", "unsel_box_3"));
206 grabMultiplier3.setSelectedIcon(ImageProvider.get("preferences", "sel_box_3"));
207 grabMultiplier3.addActionListener( multiplierActionListener);
208 grabMultiplier3.setToolTipText(tr("Grab smaller images (higher quality but use more memory)"));
209 grabMultiplier4.setIcon(ImageProvider.get("preferences", "unsel_box_4"));
210 grabMultiplier4.setSelectedIcon(ImageProvider.get("preferences", "sel_box_4"));
211 grabMultiplier4.addActionListener( multiplierActionListener);
212 grabMultiplier4.setToolTipText(tr("Fixed size square (default is 100m)"));
213 bgGrabMultiplier.add(grabMultiplier1);
214 bgGrabMultiplier.add(grabMultiplier2);
215 bgGrabMultiplier.add(grabMultiplier3);
216 bgGrabMultiplier.add(grabMultiplier4);
217 String currentScale = Main.pref.get("cadastrewms.scale", "1");
218 if (currentScale.equals(Scale.X1.value))
219 grabMultiplier1.setSelected(true);
220 if (currentScale.equals(Scale.X2.value))
221 grabMultiplier2.setSelected(true);
222 if (currentScale.equals(Scale.X3.value))
223 grabMultiplier3.setSelected(true);
224 if (currentScale.equals(Scale.SQUARE_100M.value))
225 grabMultiplier4.setSelected(true);
226 cadastrewms.add(grabMultiplier1, GBC.std().insets(5, 0, 5, 0));
227 cadastrewms.add(grabMultiplier2, GBC.std().insets(5, 0, 5, 0));
228 cadastrewms.add(grabMultiplier3, GBC.std().insets(5, 0, 5, 0));
229 cadastrewms.add(grabMultiplier4, GBC.std().insets(5, 0, 5, 0));
230 int squareSize = getNumber("cadastrewms.squareSize", DEFAULT_SQUARE_SIZE);
231 grabMultiplier4Size.setText(String.valueOf(squareSize));
232 grabMultiplier4Size.setToolTipText(tr("Fixed size (from 25 to 1000 meters)"));
233 grabMultiplier4Size.setEnabled(currentScale.equals(Scale.SQUARE_100M.value));
234 cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
235
236 // WMS layers selection
237 JLabel jLabelLayers = new JLabel(tr("Layers:"));
238 cadastrewms.add(jLabelLayers, GBC.std().insets(0, 5, 10, 0));
239 layerLS3.setSelected(Main.pref.getBoolean("cadastrewms.layerWater", true));
240 layerLS3.setToolTipText(tr("See, rivers, swimming pools."));
241 cadastrewms.add(layerLS3, GBC.std().insets(5, 0, 5, 0));
242 layerLS2.setSelected(Main.pref.getBoolean("cadastrewms.layerBuilding", true));
243 layerLS2.setToolTipText(tr("Buildings, covers, underground constructions."));
244 cadastrewms.add(layerLS2, GBC.std().insets(5, 0, 5, 0));
245 layerLS1.setSelected(Main.pref.getBoolean("cadastrewms.layerSymbol", true));
246 layerLS1.setToolTipText(tr("Symbols like cristian cross."));
247 cadastrewms.add(layerLS1, GBC.std().insets(5, 0, 5, 0));
248 layerParcel.setSelected(Main.pref.getBoolean("cadastrewms.layerParcel", true));
249 layerParcel.setToolTipText(tr("Parcels."));
250 cadastrewms.add(layerParcel, GBC.eop().insets(5, 0, 5, 0));
251 layerLabel.setSelected(Main.pref.getBoolean("cadastrewms.layerLabel", true));
252 layerLabel.setToolTipText(tr("Parcels numbers, street names."));
253 cadastrewms.add(layerLabel, GBC.std().insets(70, 0, 5, 0));
254 layerNumero.setSelected(Main.pref.getBoolean("cadastrewms.layerNumero", true));
255 layerNumero.setToolTipText(tr("Address, houses numbers."));
256 cadastrewms.add(layerNumero, GBC.std().insets(5, 0, 5, 0));
257 layerLieudit.setSelected(Main.pref.getBoolean("cadastrewms.layerLieudit", true));
258 layerLieudit.setToolTipText(tr("Locality, hamlet, place."));
259 cadastrewms.add(layerLieudit, GBC.std().insets(5, 0, 5, 0));
260 layerSection.setSelected(Main.pref.getBoolean("cadastrewms.layerSection", true));
261 layerSection.setToolTipText(tr("Cadastral sections and subsections."));
262 cadastrewms.add(layerSection, GBC.std().insets(5, 0, 5, 0));
263 layerCommune.setSelected(Main.pref.getBoolean("cadastrewms.layerCommune", true));
264 layerCommune.setToolTipText(tr("Municipality administrative borders."));
265 cadastrewms.add(layerCommune, GBC.eop().insets(5, 0, 5, 0));
266
267 // separator
268 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
269
270 // for raster images (not vectorized), image grab divider (from 1 to 12)
271 String savedRasterDivider = Main.pref.get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER);
272 JLabel jLabelRasterDivider = new JLabel(tr("Raster images grab multiplier:"));
273 rasterDivider.setText(savedRasterDivider);
274 rasterDivider.setToolTipText("Raster image grab division, from 1 to 12; 12 is very high definition");
275 cadastrewms.add(jLabelRasterDivider, GBC.std().insets(0, 5, 10, 0));
276 cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
277 // option to disable image cropping during raster image georeferencing
278 disableImageCropping.setSelected(Main.pref.getBoolean("cadastrewms.noImageCropping", false));
279 disableImageCropping.setToolTipText(tr("Disable image cropping during georeferencing."));
280 cadastrewms.add(disableImageCropping, GBC.std().insets(0, 0, 10, 0));
281 // option to add the "Tableau d'assemblage" in list of sheets to grab
282 enableTableauAssemblage.setSelected(Main.pref.getBoolean("cadastrewms.useTA", false));
283 enableTableauAssemblage.setToolTipText(tr("Add the \"Tableau(x) d''assemblage\" in the list of cadastre sheets to grab."));
284 cadastrewms.add(enableTableauAssemblage, GBC.eop().insets(0, 0, 0, 0));
285 // the crosspiece display
286 JLabel jLabelCrosspieces = new JLabel(tr("Display crosspieces:"));
287 cadastrewms.add(jLabelCrosspieces, GBC.std().insets(0, 0, 10, 0));
288 ButtonGroup bgCrosspieces = new ButtonGroup();
289 int crosspieces = getNumber("cadastrewms.crosspieces", DEFAULT_CROSSPIECES);
290 if (crosspieces == 0) crosspiece1.setSelected(true);
291 if (crosspieces == 1) crosspiece2.setSelected(true);
292 if (crosspieces == 2) crosspiece3.setSelected(true);
293 if (crosspieces == 3) crosspiece4.setSelected(true);
294 bgCrosspieces.add(crosspiece1);
295 bgCrosspieces.add(crosspiece2);
296 bgCrosspieces.add(crosspiece3);
297 bgCrosspieces.add(crosspiece4);
298 cadastrewms.add(crosspiece1, GBC.std().insets(5, 0, 5, 0));
299 cadastrewms.add(crosspiece2, GBC.std().insets(5, 0, 5, 0));
300 cadastrewms.add(crosspiece3, GBC.std().insets(5, 0, 5, 0));
301 cadastrewms.add(crosspiece4, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5));
302
303 // separator
304 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
305
306 // option to enable automatic caching
307 enableCache.addActionListener(new ActionListener() {
308 public void actionPerformed(ActionEvent e) {
309 jLabelCacheSize.setEnabled(enableCache.isSelected());
310 cacheSize.setEnabled(enableCache.isSelected());
311 }
312 });
313 enableCache.setSelected(Main.pref.getBoolean("cadastrewms.enableCaching", true));
314 enableCache.setToolTipText(tr("Allows an automatic caching"));
315 cadastrewms.add(enableCache, GBC.eop().insets(0, 0, 0, 0));
316
317 // option to fix the cache size(in MB)
318 int size = getNumber("cadastrewms.cacheSize", DEFAULT_CACHE_SIZE);
319 cacheSize.setText(String.valueOf(size));
320 cacheSize.setToolTipText(tr("Oldest files are automatically deleted when this size is exceeded"));
321 cadastrewms.add(jLabelCacheSize, GBC.std().insets(20, 0, 0, 0));
322 cadastrewms.add(cacheSize, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5));
323
324 // separator
325 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
326
327 // option to select the first WMS layer
328 autoFirstLayer.setSelected(Main.pref.getBoolean("cadastrewms.autoFirstLayer", false));
329 autoFirstLayer.setToolTipText(tr("Automatically selects the first WMS layer if multiple layers exist when grabbing."));
330 cadastrewms.add(autoFirstLayer, GBC.eop().insets(0, 0, 0, 0));
331
332 // separator
333 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL));
334
335 // option to use or not relations in addresses
336 dontUseRelation.setSelected(Main.pref.getBoolean("cadastrewms.addr.dontUseRelation", false));
337 dontUseRelation.setToolTipText(tr("Enable this to use the tag \"add:street\" on nodes."));
338 cadastrewms.add(dontUseRelation, GBC.eop().insets(0, 0, 0, 0));
339
340 // end of dialog, scroll bar
341 cadastrewms.add(Box.createVerticalGlue(), GBC.eol().fill(GBC.VERTICAL));
342 JScrollPane scrollpane = new JScrollPane(cadastrewms);
343 scrollpane.setBorder(BorderFactory.createEmptyBorder( 0, 0, 0, 0 ));
344 cadastrewmsMast.add(scrollpane, GBC.eol().fill(GBC.BOTH));
345 }
346
347 public boolean ok() {
348 Main.pref.put("cadastrewms.source", sourcing.getText());
349 CadastrePlugin.source = sourcing.getText();
350 Main.pref.put("cadastrewms.alterColors", alterColors.isSelected());
351 Main.pref.put("cadastrewms.invertGrey", reversGrey.isSelected());
352 Main.pref.put("cadastrewms.backgroundTransparent", transparency.isSelected());
353 Main.pref.put("cadastrewms.brightness", Float.toString((float)sliderTrans.getValue()/10));
354 Main.pref.put("cadastrewms.drawBoundaries", drawBoundaries.isSelected());
355 if (grabRes1.isSelected())
356 Main.pref.put("cadastrewms.resolution", "high");
357 else if (grabRes2.isSelected())
358 Main.pref.put("cadastrewms.resolution", "medium");
359 else if (grabRes3.isSelected())
360 Main.pref.put("cadastrewms.resolution", "low");
361 if (imageInterpolationMethod.getSelectedIndex() == 2)
362 Main.pref.put("cadastrewms.imageInterpolation", "bicubic");
363 else if (imageInterpolationMethod.getSelectedIndex() == 1)
364 Main.pref.put("cadastrewms.imageInterpolation", "bilinear");
365 else
366 Main.pref.put("cadastrewms.imageInterpolation", "standard");
367 if (grabMultiplier1.isSelected())
368 Main.pref.put("cadastrewms.scale", Scale.X1.toString());
369 else if (grabMultiplier2.isSelected())
370 Main.pref.put("cadastrewms.scale", Scale.X2.toString());
371 else if (grabMultiplier3.isSelected())
372 Main.pref.put("cadastrewms.scale", Scale.X3.toString());
373 else {
374 Main.pref.put("cadastrewms.scale", Scale.SQUARE_100M.toString());
375 try {
376 int squareSize = Integer.parseInt(grabMultiplier4Size.getText());
377 if (squareSize >= 25 && squareSize <= 1000)
378 Main.pref.put("cadastrewms.squareSize", grabMultiplier4Size.getText());
379 } catch (NumberFormatException e) { // ignore the last input
380 }
381 }
382 Main.pref.put("cadastrewms.layerWater", layerLS3.isSelected());
383 Main.pref.put("cadastrewms.layerBuilding", layerLS2.isSelected());
384 Main.pref.put("cadastrewms.layerSymbol", layerLS1.isSelected());
385 Main.pref.put("cadastrewms.layerParcel", layerParcel.isSelected());
386 Main.pref.put("cadastrewms.layerLabel", layerLabel.isSelected());
387 Main.pref.put("cadastrewms.layerNumero", layerNumero.isSelected());
388 Main.pref.put("cadastrewms.layerLieudit", layerLieudit.isSelected());
389 Main.pref.put("cadastrewms.layerSection", layerSection.isSelected());
390 Main.pref.put("cadastrewms.layerCommune", layerCommune.isSelected());
391 try {
392 int i = Integer.parseInt(rasterDivider.getText());
393 if (i > 0 && i < 13)
394 Main.pref.put("cadastrewms.rasterDivider", String.valueOf(i));
395 } catch (NumberFormatException e) { // ignore the last input
396 }
397 Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected());
398 Main.pref.put("cadastrewms.useTA", enableTableauAssemblage.isSelected());
399 if (crosspiece1.isSelected()) Main.pref.put("cadastrewms.crosspieces", "0");
400 else if (crosspiece2.isSelected()) Main.pref.put("cadastrewms.crosspieces", "1");
401 else if (crosspiece3.isSelected()) Main.pref.put("cadastrewms.crosspieces", "2");
402 else if (crosspiece4.isSelected()) Main.pref.put("cadastrewms.crosspieces", "3");
403 Main.pref.put("cadastrewms.enableCaching", enableCache.isSelected());
404
405 // spread data into objects instead of restarting the application
406 try {
407 CacheControl.cacheSize = Integer.parseInt(cacheSize.getText());
408 Main.pref.put("cadastrewms.cacheSize", String.valueOf(CacheControl.cacheSize));
409 } catch (NumberFormatException e) { // ignore the last input
410 }
411 Main.pref.put("cadastrewms.autoFirstLayer", autoFirstLayer.isSelected());
412 CacheControl.cacheEnabled = enableCache.isSelected();
413 Main.pref.put("cadastrewms.addr.dontUseRelation", dontUseRelation.isSelected());
414 CadastrePlugin.refreshConfiguration();
415 CadastrePlugin.refreshMenu();
416
417 return false;
418 }
419
420 private int getNumber(String pref_parameter, int def_value) {
421 try {
422 return Integer.parseInt(Main.pref.get(pref_parameter, String.valueOf(def_value)));
423 } catch (NumberFormatException e) {
424 return def_value;
425 }
426 }
427}
Note: See TracBrowser for help on using the repository browser.