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