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