Changeset 18595 in osm for applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr
- Timestamp:
- 2009-11-14T19:38:46+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r18544 r18595 26 26 27 27 import org.openstreetmap.josm.Main; 28 import org.openstreetmap.josm.data.Bounds; 29 import org.openstreetmap.josm.data.coor.EastNorth; 28 30 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 29 31 import org.openstreetmap.josm.data.projection.LambertCC9Zones; 30 import org.openstreetmap.josm.data.Bounds;31 32 import org.openstreetmap.josm.gui.MapView; 32 33 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 34 35 import org.openstreetmap.josm.gui.layer.Layer; 35 36 import org.openstreetmap.josm.io.OsmTransferException; 36 import org.openstreetmap.josm.data.coor.EastNorth;37 37 38 38 /** … … 65 65 66 66 private boolean isRaster = false; 67 67 68 68 private boolean isAlreadyGeoreferenced = false; 69 69 70 70 public double X0, Y0, angle, fX, fY; 71 71 … … 73 73 private EastNorth rasterMax; 74 74 private double rasterRatio; 75 75 76 76 private JMenuItem saveAsPng; 77 77 … … 103 103 if (isRaster) { 104 104 b = new Bounds(Main.proj.eastNorth2latlon(rasterMin), Main.proj.eastNorth2latlon(rasterMax)); 105 divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", 105 divideBbox(b, Integer.parseInt(Main.pref.get("cadastrewms.rasterDivider", 106 106 CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER))); 107 107 } else … … 203 203 204 204 @Override 205 public void paint(Graphics g, final MapView mv) {205 public void paint(Graphics2D g, final MapView mv, Bounds bounds) { 206 206 synchronized(this){ 207 207 for (GeorefImage img : images) 208 img.paint( (Graphics2D)g, mv, CadastrePlugin.backgroundTransparent,208 img.paint(g, mv, CadastrePlugin.backgroundTransparent, 209 209 CadastrePlugin.transparency, CadastrePlugin.drawBoundaries); 210 210 } … … 236 236 saveAsPng, 237 237 new JMenuItem(new LayerListPopup.InfoAction(this)), 238 238 239 239 }; 240 240 return component; … … 336 336 337 337 /** 338 * Set raster positions used for grabbing and georeferencing. 338 * Set raster positions used for grabbing and georeferencing. 339 339 * rasterMin is the Eaast North of bottom left corner raster image on the screen when image is grabbed. 340 340 * The bounds width and height are the raster width and height. The image width matches the current view 341 341 * and the image height is adapted. 342 * Required: the communeBBox must be set (normally it is catched by CadastreInterface and saved by DownloadWMSPlanImage) 342 * Required: the communeBBox must be set (normally it is catched by CadastreInterface and saved by DownloadWMSPlanImage) 343 343 * @param bounds the current main map view boundaries 344 344 */ … … 347 347 EastNorth eaMin = Main.proj.latlon2eastNorth(bounds.getMin()); 348 348 EastNorth eaMax = Main.proj.latlon2eastNorth(bounds.getMax()); 349 double rasterSizeX = communeBBox.max.getX() - communeBBox.min.getX(); 349 double rasterSizeX = communeBBox.max.getX() - communeBBox.min.getX(); 350 350 double rasterSizeY = communeBBox.max.getY() - communeBBox.min.getY(); 351 351 double ratio = rasterSizeY/rasterSizeX; … … 443 443 return true; 444 444 } 445 445 446 446 /** 447 447 * Join the grabbed images into one single. … … 454 454 EastNorth max = images.get(images.size()-1).max; 455 455 int oldImgWidth = images.get(0).image.getWidth(); 456 int oldImgHeight = images.get(0).image.getHeight(); 456 int oldImgHeight = images.get(0).image.getHeight(); 457 457 int newWidth = oldImgWidth*(int)Math.sqrt(images.size()); 458 458 int newHeight = oldImgHeight*(int)Math.sqrt(images.size()); … … 475 475 } 476 476 } 477 477 478 478 /** 479 479 * Image cropping based on two EN coordinates pointing to two corners in diagonal 480 480 * Because it's coming from user mouse clics, we have to sort de positions first. 481 481 * Works only for raster image layer (only one image in collection). 482 * Updates layer georeferences. 482 * Updates layer georeferences. 483 483 * @param en1 484 484 * @param en2 485 485 */ 486 486 public void cropImage(EastNorth en1, EastNorth en2){ 487 // adj1 is corner bottom, left 487 // adj1 is corner bottom, left 488 488 EastNorth adj1 = new EastNorth(en1.east() <= en2.east() ? en1.east() : en2.east(), 489 489 en1.north() <= en2.north() ? en1.north() : en2.north()); … … 501 501 Graphics g = new_img.getGraphics(); 502 502 g.drawImage(images.get(0).image, 0, 0, newWidth-1, newHeight-1, 503 (int)sx1, (int)sy1, (int)sx2, (int)sy2,503 sx1, sy1, sx2, sy2, 504 504 this); 505 505 images.set(0, new GeorefImage(new_img, adj1, adj2)); … … 522 522 523 523 /** 524 * Method required by ImageObserver when drawing an image 524 * Method required by ImageObserver when drawing an image 525 525 */ 526 526 public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { … … 540 540 if (Main.map.mapView.getAllLayers().size() == 1) { 541 541 /* Enable this code below when JOSM will have a proper support of dynamic projection change 542 * 542 * 543 543 System.out.println("close all layers and change current Lambert zone from "+LambertCC9Zones.layoutZone+" to "+lambertZone); 544 544 Bounds b = null; … … 562 562 (images.get(0).max.north()+images.get(0).min.north())/2); 563 563 } 564 564 565 565 public void displace(double dx, double dy) { 566 566 this.rasterMin = new EastNorth(rasterMin.east() + dx, rasterMin.north() + dy); … … 582 582 if (!crosspieces.equals("0")) { 583 583 int modulo = 50; 584 if (crosspieces.equals("2")) modulo = 100; 584 if (crosspieces.equals("2")) modulo = 100; 585 585 EastNorthBound currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()), 586 586 mv.getEastNorth(mv.getWidth(), 0)); … … 603 603 } 604 604 } 605 605 606 606 }
Note:
See TracChangeset
for help on using the changeset viewer.