Changeset 17181 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
- Timestamp:
- 2009-08-19T22:54:02+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 } else // action cancelled or image loaded from cache (and already georeferenced)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.
