Ignore:
Timestamp:
2009-11-14T19:38:46+01:00 (15 years ago)
Author:
jttt
Message:

Updated to new MapViewPaintable.paint arguments

Location:
applications/editors/josm/plugins/cadastre-fr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/cadastre-fr/build.xml

    r18413 r18595  
    2626                <attribute name="Plugin-Description" value="A special handler for the French land registry WMS server."/>
    2727                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/Cadastre"/>
    28                 <attribute name="Plugin-Mainversion" value="2381"/>
     28                <attribute name="Plugin-Mainversion" value="2450"/>
    2929                <attribute name="Plugin-Stage" value="60"/>
    3030                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
  • applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java

    r18544 r18595  
    2626
    2727import org.openstreetmap.josm.Main;
     28import org.openstreetmap.josm.data.Bounds;
     29import org.openstreetmap.josm.data.coor.EastNorth;
    2830import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    2931import org.openstreetmap.josm.data.projection.LambertCC9Zones;
    30 import org.openstreetmap.josm.data.Bounds;
    3132import org.openstreetmap.josm.gui.MapView;
    3233import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    3435import org.openstreetmap.josm.gui.layer.Layer;
    3536import org.openstreetmap.josm.io.OsmTransferException;
    36 import org.openstreetmap.josm.data.coor.EastNorth;
    3737
    3838/**
     
    6565
    6666    private boolean isRaster = false;
    67    
     67
    6868    private boolean isAlreadyGeoreferenced = false;
    69    
     69
    7070    public double X0, Y0, angle, fX, fY;
    7171
     
    7373    private EastNorth rasterMax;
    7474    private double rasterRatio;
    75    
     75
    7676    private JMenuItem saveAsPng;
    7777
     
    103103        if (isRaster) {
    104104            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",
    106106                    CadastrePreferenceSetting.DEFAULT_RASTER_DIVIDER)));
    107107        } else
     
    203203
    204204    @Override
    205     public void paint(Graphics g, final MapView mv) {
     205    public void paint(Graphics2D g, final MapView mv, Bounds bounds) {
    206206        synchronized(this){
    207207            for (GeorefImage img : images)
    208                 img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent,
     208                img.paint(g, mv, CadastrePlugin.backgroundTransparent,
    209209                        CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
    210210        }
     
    236236                saveAsPng,
    237237                new JMenuItem(new LayerListPopup.InfoAction(this)),
    238                
     238
    239239        };
    240240        return component;
     
    336336
    337337    /**
    338      * Set raster positions used for grabbing and georeferencing. 
     338     * Set raster positions used for grabbing and georeferencing.
    339339     * rasterMin is the Eaast North of bottom left corner raster image on the screen when image is grabbed.
    340340     * The bounds width and height are the raster width and height. The image width matches the current view
    341341     * 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)
    343343     * @param bounds the current main map view boundaries
    344344     */
     
    347347        EastNorth eaMin = Main.proj.latlon2eastNorth(bounds.getMin());
    348348        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();
    350350        double rasterSizeY = communeBBox.max.getY() - communeBBox.min.getY();
    351351        double ratio = rasterSizeY/rasterSizeX;
     
    443443        return true;
    444444    }
    445    
     445
    446446    /**
    447447     * Join the grabbed images into one single.
     
    454454            EastNorth max = images.get(images.size()-1).max;
    455455            int oldImgWidth = images.get(0).image.getWidth();
    456             int oldImgHeight = images.get(0).image.getHeight(); 
     456            int oldImgHeight = images.get(0).image.getHeight();
    457457            int newWidth = oldImgWidth*(int)Math.sqrt(images.size());
    458458            int newHeight = oldImgHeight*(int)Math.sqrt(images.size());
     
    475475        }
    476476    }
    477    
     477
    478478    /**
    479479     * Image cropping based on two EN coordinates pointing to two corners in diagonal
    480480     * Because it's coming from user mouse clics, we have to sort de positions first.
    481481     * Works only for raster image layer (only one image in collection).
    482      * Updates layer georeferences. 
     482     * Updates layer georeferences.
    483483     * @param en1
    484484     * @param en2
    485485     */
    486486    public void cropImage(EastNorth en1, EastNorth en2){
    487         // adj1 is corner bottom, left 
     487        // adj1 is corner bottom, left
    488488        EastNorth adj1 = new EastNorth(en1.east() <= en2.east() ? en1.east() : en2.east(),
    489489                en1.north() <= en2.north() ? en1.north() : en2.north());
     
    501501        Graphics g = new_img.getGraphics();
    502502        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,
    504504                this);
    505505        images.set(0, new GeorefImage(new_img, adj1, adj2));
     
    522522
    523523    /**
    524      * Method required by ImageObserver when drawing an image 
     524     * Method required by ImageObserver when drawing an image
    525525     */
    526526    public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) {
     
    540540            if (Main.map.mapView.getAllLayers().size() == 1) {
    541541                /* Enable this code below when JOSM will have a proper support of dynamic projection change
    542                  * 
     542                 *
    543543                System.out.println("close all layers and change current Lambert zone from "+LambertCC9Zones.layoutZone+" to "+lambertZone);
    544544                Bounds b = null;
     
    562562                (images.get(0).max.north()+images.get(0).min.north())/2);
    563563    }
    564    
     564
    565565    public void displace(double dx, double dy) {
    566566        this.rasterMin = new EastNorth(rasterMin.east() + dx, rasterMin.north() + dy);
     
    582582        if (!crosspieces.equals("0")) {
    583583            int modulo = 50;
    584             if (crosspieces.equals("2")) modulo = 100; 
     584            if (crosspieces.equals("2")) modulo = 100;
    585585            EastNorthBound currentView = new EastNorthBound(mv.getEastNorth(0, mv.getHeight()),
    586586                    mv.getEastNorth(mv.getWidth(), 0));
     
    603603        }
    604604    }
    605    
     605
    606606}
Note: See TracChangeset for help on using the changeset viewer.