Changeset 17215 in osm for applications/editors/josm/plugins/cadastre-fr/src
- Timestamp:
- 2009-08-23T21:23:13+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CacheControl.java
r17089 r17215 11 11 12 12 import static org.openstreetmap.josm.tools.I18n.tr; 13 14 import java.awt.image.BufferedImage; 13 15 import java.io.*; 14 16 import java.util.ArrayList; … … 127 129 return false; 128 130 } 131 if (wmsLayer.isRaster()) { 132 // serialized raster bufferedImage hangs-up on Java6. Recreate them here 133 wmsLayer.images.get(0).image = RasterImageModifier.fixRasterImage(wmsLayer.images.get(0).image); 134 } 129 135 return true; 130 136 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastreInterface.java
r17181 r17215 246 246 rd.close(); 247 247 urlConn.disconnect(); 248 if (lines.indexOf(cImageFormat) != -1) { 249 int i = lines.indexOf(cImageFormat); 250 int j = lines.indexOf(".", i); 251 wmsLayer.setRaster(lines.substring(i+cImageFormat.length(), j).equals("image")); 252 } 253 if (!wmsLayer.isRaster() && lines.indexOf(cInterfaceVector) != -1) { // "afficherCarteCommune.do" 254 // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269"; 255 lines = lines.substring(lines.indexOf(cInterfaceVector),lines.length()); 256 lines = lines.substring(0, lines.indexOf("'")); 257 System.out.println("interface ref.:"+lines); 258 return lines; 259 } else if (wmsLayer.isRaster() && lines.indexOf(cInterfaceRasterTA) != -1) { // "afficherCarteTa.do" 260 // list of values parsed in listOfFeuilles (list all non-georeferenced images) 261 lines = getFeuillesList(); 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 } 276 } 277 return null; 278 } else if (lines.indexOf(cCommuneListStart) != -1 && lines.indexOf(cCommuneListEnd) != -1) { 279 // list of values parsed in listOfCommunes 280 int i = lines.indexOf(cCommuneListStart); 281 int j = lines.indexOf(cCommuneListEnd, i); 282 parseCommuneList(lines.substring(i, j)); 248 if (lines != null) { 249 if (lines.indexOf(cImageFormat) != -1) { 250 int i = lines.indexOf(cImageFormat); 251 int j = lines.indexOf(".", i); 252 wmsLayer.setRaster(lines.substring(i+cImageFormat.length(), j).equals("image")); 253 } 254 if (!wmsLayer.isRaster() && lines.indexOf(cInterfaceVector) != -1) { // "afficherCarteCommune.do" 255 // shall be something like: interfaceRef = "afficherCarteCommune.do?c=X2269"; 256 lines = lines.substring(lines.indexOf(cInterfaceVector),lines.length()); 257 lines = lines.substring(0, lines.indexOf("'")); 258 System.out.println("interface ref.:"+lines); 259 return lines; 260 } else if (wmsLayer.isRaster() && lines.indexOf(cInterfaceRasterTA) != -1) { // "afficherCarteTa.do" 261 // list of values parsed in listOfFeuilles (list all non-georeferenced images) 262 lines = getFeuillesList(); 263 if (!downloadCancelled) { 264 parseFeuillesList(lines); 265 if (listOfFeuilles.size() > 0) { 266 int res = selectFeuilleDialog(); 267 if (res != -1) { 268 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).name); 269 checkLayerDuplicates(wmsLayer); 270 interfaceRef = buildRasterFeuilleInterfaceRef(wmsLayer.getCodeCommune()); 271 wmsLayer.setCodeCommune(listOfFeuilles.elementAt(res).ref); 272 lines = buildRasterFeuilleInterfaceRef(listOfFeuilles.elementAt(res).ref); 273 System.out.println("interface ref.:"+lines); 274 return lines; 275 } 276 } 277 } 278 return null; 279 } else if (lines.indexOf(cCommuneListStart) != -1 && lines.indexOf(cCommuneListEnd) != -1) { 280 // list of values parsed in listOfCommunes 281 int i = lines.indexOf(cCommuneListStart); 282 int j = lines.indexOf(cCommuneListEnd, i); 283 parseCommuneList(lines.substring(i, j)); 284 } 283 285 } 284 286 } catch (MalformedURLException e) { -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePlugin.java
r17089 r17215 20 20 import org.openstreetmap.josm.actions.UploadAction; 21 21 import org.openstreetmap.josm.actions.UploadAction.UploadHook; 22 import org.openstreetmap.josm.gui.IconToggleButton;23 22 import org.openstreetmap.josm.gui.MainMenu; 24 23 import org.openstreetmap.josm.gui.MapFrame; … … 73 72 * 1.1 11-Jun-2009 - fixed a null exception error when trying to displace a vectorized layer 74 73 * - propose to use shortcut F11 for grabbing 74 * 1.2 16-Aug-2009 - implementation of raster image grabbing, cropping and georeferencing (not the 75 * overview rasters (Tableau d'assemblage) but directly small units (Feuille) 76 * 1.3 23-Aug-2009 - improve georeferencing action cancellation 77 * - fixed bug of raster image loaded from cache not working on Java1.6 78 * - improve mouse click bounce detection during georeferencing process 75 79 */ 76 80 public class CadastrePlugin extends Plugin { 77 static String VERSION = "1. 0";81 static String VERSION = "1.3"; 78 82 79 83 static JMenu cadastreJMenu; -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/CadastrePreferenceSetting.java
r17181 r17215 81 81 reversGrey.setSelected(Main.pref.getBoolean("cadastrewms.invertGrey", false)); 82 82 reversGrey.setToolTipText(tr("Invert the original black and white colors (and all intermediate greys). Useful for texts on dark backgrounds.")); 83 reversGrey.setEnabled(alterColors.isSelected());84 83 cadastrewms.add(reversGrey, GBC.eop().insets(00, 0, 0, 0)); 85 84 … … 102 101 sliderTrans.setPaintTicks(true); 103 102 sliderTrans.setPaintLabels(false); 103 sliderTrans.setEnabled(transparency.isSelected()); 104 104 cadastrewms.add(sliderTrans, GBC.eol().fill(GBC.HORIZONTAL).insets(20, 0, 250, 0)); 105 105 -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/GeorefImage.java
r17089 r17215 133 133 */ 134 134 private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { 135 max = (EastNorth) in.readObject();136 min = (EastNorth) in.readObject();135 max = new EastNorth((Double)in.readObject(), (Double)in.readObject()); 136 min = new EastNorth((Double)in.readObject(), (Double)in.readObject()); 137 137 image = (BufferedImage) ImageIO.read(ImageIO.createImageInputStream(in)); 138 138 updatePixelPer(); … … 143 143 */ 144 144 private void writeObject(ObjectOutputStream out) throws IOException { 145 out.writeObject(max); 146 out.writeObject(min); 145 out.writeObject(max.getX()); 146 out.writeObject(max.getY()); 147 out.writeObject(min.getX()); 148 out.writeObject(min.getY()); 147 149 ImageIO.write(image, "png", ImageIO.createImageOutputStream(out)); 148 150 } -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/MenuActionGrabPlanImage.java
r17181 r17215 4 4 5 5 import java.awt.GridBagLayout; 6 import java.awt.Point;7 6 import java.awt.event.ActionEvent; 8 7 import java.awt.event.MouseEvent; … … 37 36 private int cGetLambertCrosspieces = 2; 38 37 private EastNorth ea1; 39 private Point mousePrevious = new Point();38 private long mouseClickedTime = 0; 40 39 private EastNorth georefpoint1; 41 40 private EastNorth georefpoint2; 41 /** 42 * The time which needs to pass between two clicks during georeferencing, in milliseconds 43 */ 44 private int initialClickDelay; 42 45 43 46 public MenuActionGrabPlanImage() { … … 48 51 countMouseClicked = 0; 49 52 mode = 0; 50 mouse Previous.setLocation(0, 0);53 mouseClickedTime = System.currentTimeMillis(); 51 54 } 52 55 … … 75 78 downloadWMSPlanImage = new DownloadWMSPlanImage(); 76 79 downloadWMSPlanImage.download(wmsLayer); 80 initialClickDelay = Main.pref.getInteger("cadastrewms.georef-click-delay",200); 77 81 // download sub-images of the cadastre scan and join them into one single 78 82 Main.worker.execute(this); … … 90 94 boolean loadedFromCache = downloadWMSPlanImage.waitFinished(); 91 95 if (wmsLayer.images.size() == 1 && !loadedFromCache) { 96 mouseClickedTime = System.currentTimeMillis(); 92 97 Main.map.mapView.addMouseListener(this); 93 98 if (Main.pref.getBoolean("cadastrewms.noImageCropping", false) == false) … … 95 100 else 96 101 startGeoreferencing(); 97 102 } else // action cancelled or image loaded from cache (and already georeferenced) 98 103 Main.map.repaint(); 99 104 } 100 105 101 106 public void mouseClicked(MouseEvent e) { 102 if (e.getX() == mousePrevious.getX() && e.getY() == mousePrevious.getY()) 103 return; // double click filtered 107 if (System.currentTimeMillis() - mouseClickedTime < initialClickDelay) { 108 System.out.println("mouse click bounce detected"); 109 return; // mouse click anti-bounce 110 } 104 111 else 105 mouse Previous.setLocation(e.getX(), e.getY());112 mouseClickedTime = System.currentTimeMillis(); 106 113 countMouseClicked++; 107 114 EastNorth ea = Main.proj.latlon2eastNorth(Main.map.mapView.getLatLon(e.getX(), e.getY())); 108 System.out.println("clic:"+countMouseClicked+" ,"+ea );115 System.out.println("clic:"+countMouseClicked+" ,"+ea+", mode:"+mode); 109 116 // ignore clicks outside the image 110 117 if (ea.east() < wmsLayer.images.get(0).min.east() || ea.east() > wmsLayer.images.get(0).max.east() … … 153 160 null, options, options[0]); 154 161 if (ret == JOptionPane.OK_OPTION) { 155 mouse Previous.setLocation(0, 0);162 mouseClickedTime = System.currentTimeMillis(); 156 163 } else 157 164 if (canceledOrRestartCurrAction("image cropping")) … … 192 199 null, options, options[0]); 193 200 if (ret == JOptionPane.OK_OPTION) { 194 mouse Previous.setLocation(0, 0);201 mouseClickedTime = System.currentTimeMillis(); 195 202 } else 196 203 if (canceledOrRestartCurrAction("georeferencing")) … … 257 264 if (countMouseClicked == 1) number = "first"; 258 265 else number = "second"; 259 pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinate ")).setVisible(true);266 pane.createDialog(Main.parent, tr("Set "+number+" Lambert coordinates")).setVisible(true); 260 267 if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) { 261 268 if (canceledOrRestartCurrAction("georeferencing")) -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/RasterImageModifier.java
r17089 r17215 60 60 private void makeTransparent() { 61 61 if (bufferedImage.getColorModel() instanceof ComponentColorModel) { 62 // raster image (ComponentColorModel)63 62 int width = bufferedImage.getWidth(); 64 63 int height = bufferedImage.getHeight(); … … 85 84 return; 86 85 } 86 87 /** 88 * Temporary fix for Java6 which doesn't de-serialize correctly cached image on disk. 89 * Recreate a new raster image based on what is loaded/serialized from disk cache. 90 * @param img 91 * @return new image 92 */ 93 public static BufferedImage fixRasterImage(BufferedImage img) { 94 int width = img.getWidth(); 95 int height = img.getHeight(); 96 BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); 97 int rgbArray[] = new int[width * height]; 98 img.getRGB(0, 0, width, height, rgbArray, 0, width); 99 bi.setRGB(0, 0, width, height, rgbArray, 0, width); 100 return bi; 101 } 87 102 88 103 }
Note:
See TracChangeset
for help on using the changeset viewer.