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