Changeset 17181 in osm for applications
- Timestamp:
- 2009-08-19T22:54:02+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
r17089 r17181 72 72 } catch (IOException e) { 73 73 /*JOptionPane.showMessageDialog(Main.parent, 74 tr("Town/city {0} not found or not available in WMS.\n" +75 " Please check its availibility on www.cadastre.gouv.fr", wmsLayer.getLocation()));*/74 tr("Town/city {0} not found or not available\n" + 75 "or action canceled", wmsLayer.getLocation()));*/ 76 76 JOptionPane pane = new JOptionPane( 77 tr("Town/city {0} not found or not available in WMS.\n" +78 " Please check its availibility on www.cadastre.gouv.fr", wmsLayer.getLocation()),77 tr("Town/city {0} not found or not available\n" + 78 "or action canceled", wmsLayer.getLocation()), 79 79 JOptionPane.INFORMATION_MESSAGE); 80 80 // this below is a temporary workaround to fix the "always on top" issue … … 260 260 // list of values parsed in listOfFeuilles (list all non-georeferenced images) 261 261 lines = getFeuillesList(); 262 parseFeuillesList(lines); 263 if (listOfFeuilles.size() > 0) { 264 int res = selectFeuilleDialog(); 265 if (res != -1) { 266 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name); 267 checkLayerDuplicates(wmsLayer); 268 interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune()); 269 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref); 270 lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref); 271 System.out.println("interface ref.:"+lines); 272 return lines; 273 } 262 if (!downloadCancelled) { 263 parseFeuillesList(lines); 264 if (listOfFeuilles.size() > 0) { 265 int res = selectFeuilleDialog(); 266 if (res != -1) { 267 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name); 268 checkLayerDuplicates(wmsLayer); 269 interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune()); 270 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref); 271 lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref); 272 System.out.println("interface ref.:"+lines); 273 return lines; 274 } 275 } 274 276 } 275 277 return null; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
r17089 r17181 6 6 import java.awt.event.ActionListener; 7 7 import javax.swing.*; 8 8 9 import org.openstreetmap.josm.Main; 9 10 import org.openstreetmap.josm.gui.preferences.PreferenceDialog; … … 34 35 private JCheckBox drawBoundaries = new JCheckBox(tr("Draw boundaries of downloaded data.")); 35 36 37 private JCheckBox disableImageCropping = new JCheckBox(tr("Disable image cropping during georeferencing.")); 38 36 39 private JRadioButton grabMultiplier1 = new JRadioButton("", true); 37 40 … … 106 109 cadastrewms.add(drawBoundaries, GBC.eop().insets(0, 0, 0, 5)); 107 110 111 // separator 112 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL)); 113 108 114 // the vectorized images multiplier 109 115 JLabel jLabelScale = new JLabel(tr("Vector images grab multiplier:")); … … 154 160 cadastrewms.add(grabMultiplier4Size, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 0, 5)); 155 161 162 // separator 163 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL)); 164 156 165 // for raster images (not vectorized), image grab divider (from 1 to 10) 157 166 String savedRasterDivider = Main.pref.get("cadastrewms.rasterDivider", DEFAULT_RASTER_DIVIDER); … … 161 170 cadastrewms.add(jLabelRasterDivider, GBC.std().insets(0, 5, 10, 0)); 162 171 cadastrewms.add(rasterDivider, GBC.eol().fill(GBC.HORIZONTAL).insets(5, 5, 200, 5)); 172 // option to disable image cropping during raster image georeferencing 173 disableImageCropping.setSelected(Main.pref.getBoolean("cadastrewms.noImageCropping", false)); 174 disableImageCropping.setToolTipText(tr("Disable image cropping during georeferencing.")); 175 cadastrewms.add(disableImageCropping, GBC.eop().insets(0, 0, 0, 5)); 176 177 // separator 178 cadastrewms.add(new JSeparator(SwingConstants.HORIZONTAL), GBC.eol().fill(GBC.HORIZONTAL)); 163 179 164 180 // option to enable automatic caching … … 213 229 } catch (NumberFormatException e) { // ignore the last input 214 230 } 231 Main.pref.put("cadastrewms.noImageCropping", disableImageCropping.isSelected()); 215 232 Main.pref.put("cadastrewms.enableCaching", enableCache.isSelected()); 216 233 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/DownloadWMSPlanImage.java
r17089 r17181 91 91 protected void cancel() { 92 92 grabber.getWmsInterface().cancel(); 93 dontGeoreference = true; 93 94 } 94 95 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrab.java
r17089 r17181 37 37 tr("To enable the cadastre WMS plugin, change\n" 38 38 + "the current projection to one of the cadastre\n" 39 + "projection and retry"));39 + "projections and retry")); 40 40 } 41 41 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
r17089 r17181 81 81 tr("To enable the cadastre WMS plugin, change\n" 82 82 + "the current projection to one of the cadastre\n" 83 + "projection and retry"));83 + "projections and retry")); 84 84 } 85 85 } … … 91 91 if (wmsLayer.images.size() == 1 && !loadedFromCache) { 92 92 Main.map.mapView.addMouseListener(this); 93 mousePrevious.setLocation(0, 0);94 mode = cGetCorners;95 JOptionPane.showMessageDialog(Main.parent,tr("Click first corner for image cropping\n"+96 "(two points required)"));97 93 if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false) 94 startCropping(); 95 else 96 startGeoreferencing(); 97 } else // action cancelled or image loaded from cache (and already georeferenced) 98 98 Main.map.repaint(); 99 99 } … … 114 114 if (countMouseClicked == 1) { 115 115 ea1 = ea; 116 JOptionPane.showMessageDialog(Main.parent,tr("Click second corner for image cropping"));116 continueCropping(); 117 117 } 118 118 if (countMouseClicked == 2) { 119 119 wmsLayer.cropImage(ea1, ea); 120 120 Main.map.mapView.repaint(); 121 countMouseClicked = 0; 122 mode = cGetLambertCrosspieces; 123 JOptionPane.showMessageDialog(Main.parent,tr("Click first Lambert crosspiece for georeferencing\n"+ 124 "(two points required)")); 121 startGeoreferencing(); 125 122 } 126 123 } else if (mode == cGetLambertCrosspieces) { 127 124 if (countMouseClicked == 1) { 128 125 ea1 = ea; 129 georefpoint1 = inputLambertPosition(); 130 if (georefpoint1 == null) 131 return; 132 JOptionPane.showMessageDialog(Main.parent,tr("Click second Lambert crosspiece for georeferencing\n")); 126 if (inputLambertPosition()) 127 continueGeoreferencing(); 133 128 } 134 129 if (countMouseClicked == 2) { 135 Main.map.mapView.removeMouseListener(this); 136 georefpoint2 = inputLambertPosition(); 137 if (georefpoint2 == null) 138 return; 139 affineTransform(ea1, ea, georefpoint1, georefpoint2); 140 wmsLayer.saveNewCache(); 141 Main.map.mapView.repaint(); 142 actionCompleted(); 130 if (inputLambertPosition()) { 131 Main.map.mapView.removeMouseListener(this); 132 affineTransform(ea1, ea, georefpoint1, georefpoint2); 133 wmsLayer.saveNewCache(); 134 Main.map.mapView.repaint(); 135 actionCompleted(); 136 } 143 137 } 144 138 } 145 139 } 146 140 147 private EastNorth inputLambertPosition() { 141 /** 142 * 143 * @return false if all operations are canceled 144 */ 145 private boolean startCropping() { 146 mode = cGetCorners; 147 countMouseClicked = 0; 148 Object[] options = { "OK", "Cancel" }; 149 int ret = JOptionPane.showOptionDialog( null, 150 tr("Click first corner for image cropping\n(two points required)"), 151 tr("Image cropping"), 152 JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, 153 null, options, options[0]); 154 if (ret == JOptionPane.OK_OPTION) { 155 mousePrevious.setLocation(0, 0); 156 } else 157 if (canceledOrRestartCurrAction("image cropping")) 158 return startCropping(); 159 return true; 160 } 161 162 /** 163 * 164 * @return false if all operations are canceled 165 */ 166 private boolean continueCropping() { 167 Object[] options = { "OK", "Cancel" }; 168 int ret = JOptionPane.showOptionDialog( null, 169 tr("Click second corner for image cropping"), 170 tr("Image cropping"), 171 JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, 172 null, options, options[0]); 173 if (ret != JOptionPane.OK_OPTION) { 174 if (canceledOrRestartCurrAction("image cropping")) 175 return startCropping(); 176 } 177 return true; 178 } 179 180 /** 181 * 182 * @return false if all operations are canceled 183 */ 184 private boolean startGeoreferencing() { 185 countMouseClicked = 0; 186 mode = cGetLambertCrosspieces; 187 Object[] options = { "OK", "Cancel" }; 188 int ret = JOptionPane.showOptionDialog( null, 189 tr("Click first Lambert crosspiece for georeferencing\n(two points required)"), 190 tr("Image georeferencing"), 191 JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, 192 null, options, options[0]); 193 if (ret == JOptionPane.OK_OPTION) { 194 mousePrevious.setLocation(0, 0); 195 } else 196 if (canceledOrRestartCurrAction("georeferencing")) 197 return startGeoreferencing(); 198 return true; 199 } 200 201 /** 202 * 203 * @return false if all operations are canceled 204 */ 205 private boolean continueGeoreferencing() { 206 Object[] options = { "OK", "Cancel" }; 207 int ret = JOptionPane.showOptionDialog( null, 208 tr("Click second Lambert crosspiece for georeferencing"), 209 tr("Image georeferencing"), 210 JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, 211 null, options, options[0]); 212 if (ret != JOptionPane.OK_OPTION) { 213 if (canceledOrRestartCurrAction("georeferencing")) 214 return startGeoreferencing(); 215 } 216 return true; 217 } 218 219 /** 220 * 221 * @return false if all operations are canceled 222 */ 223 private boolean canceledOrRestartCurrAction(String action) { 224 Object[] options = { "Cancel", "Retry" }; 225 int selectedValue = JOptionPane.showOptionDialog( null, 226 tr("Do you want to cancel completely\n"+ 227 "or just retry "+action+" ?"), "", 228 JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, 229 null, options, options[0]); 230 if (selectedValue == 0) { // "Cancel" 231 // remove layer 232 Main.map.mapView.removeLayer(wmsLayer); 233 wmsLayer = null; 234 Main.map.mapView.removeMouseListener(this); 235 return false; 236 } else 237 countMouseClicked = 0; 238 return true; 239 } 240 241 private boolean inputLambertPosition() { 148 242 JLabel labelEnterPosition = new JLabel(tr("Enter cadastre east,north position")); 149 243 JLabel labelWarning = new JLabel(tr("(Warning: verify north with arrow !!)")); … … 160 254 p.add(inputNorth, GBC.eol().fill(GBC.HORIZONTAL).insets(10, 5, 0, 5)); 161 255 JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null); 162 pane.createDialog(Main.parent, tr("Set Lambert coordinate")).setVisible(true); 163 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 164 return null; 165 if (inputEast.getText().length() == 0 || inputNorth.getText().length() == 0) 166 return null; 167 try { 168 double e = Double.parseDouble(inputEast.getText()); 169 double n = Double.parseDouble(inputNorth.getText()); 170 return new EastNorth(e, n); 171 } catch (NumberFormatException e) { 172 return null; 173 } 256 String number; 257 if (countMouseClicked == 1) number = "first"; 258 else number = "second"; 259 pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinate")).setVisible(true); 260 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) { 261 if (canceledOrRestartCurrAction("georeferencing")) 262 startGeoreferencing(); 263 return false; 264 } 265 if (inputEast.getText().length() != 0 && inputNorth.getText().length() != 0) { 266 try { 267 double e = Double.parseDouble(inputEast.getText()); 268 double n = Double.parseDouble(inputNorth.getText()); 269 if (countMouseClicked == 1) 270 georefpoint1 = new EastNorth(e, n); 271 else 272 georefpoint2 = new EastNorth(e, n); 273 return true; 274 } catch (NumberFormatException e) { 275 return false; 276 } 277 } 278 return false; 174 279 } 175 280
Note:
See TracChangeset
for help on using the changeset viewer.