Ignore:
Timestamp:
2009-06-06T22:25:31+02:00 (15 years ago)
Author:
stoecker
Message:

lots of updates due to josm changes

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

Legend:

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

    r14120 r15707  
    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="1498"/>
     28                <attribute name="Plugin-Mainversion" value="1646"/>
    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

    r13784 r15707  
    2525import javax.swing.JOptionPane;
    2626import javax.swing.JSeparator;
    27 import javax.swing.filechooser.FileFilter;
    2827
    2928import org.openstreetmap.josm.Main;
    30 import org.openstreetmap.josm.actions.ExtensionFileFilter;
     29import org.openstreetmap.josm.actions.DiskAccessAction;
    3130import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    3231import org.openstreetmap.josm.data.projection.Lambert;
     
    4645public class WMSLayer extends Layer {
    4746
    48     Component[] component = null; 
     47    Component[] component = null;
    4948
    5049    public int lambertZone = -1;
     
    5453
    5554    protected ArrayList<GeorefImage> images = new ArrayList<GeorefImage>();
    56    
     55
    5756    protected final int serializeFormatVersion = 2;
    58    
     57
    5958    private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>();
    60    
     59
    6160    private CacheControl cacheControl = null;
    62    
     61
    6362    private String location = "";
    6463
    6564    private String codeCommune = "";
    66    
     65
    6766    private EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0));
    68    
     67
    6968    private boolean isRaster = false;
    70    
     69
    7170    private EastNorth rasterMin;
    72    
     71
    7372    private EastNorth rasterCenter;
    74    
     73
    7574    private double rasterRatio;
    7675
     
    8180        this(tr("Blank Layer"), "", -1);
    8281    }
    83    
     82
    8483    public WMSLayer(String location, String codeCommune, int lambertZone) {
    8584        super(buildName(location, codeCommune));
     
    9089        CadastrePlugin.pluginUsed = true;
    9190    }
    92    
     91
    9392    private static String buildName(String location, String codeCommune) {
    9493        String ret = new String(location.toUpperCase());
     
    138137
    139138    /**
    140      * 
     139     *
    141140     * @param b      the original bbox, usually the current bbox on screen
    142141     * @param factor 1 = source bbox 1:1
     
    202201    public void paint(Graphics g, final MapView mv) {
    203202        for (GeorefImage img : images)
    204             img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent, 
     203            img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent,
    205204                    CadastrePlugin.transparency, CadastrePlugin.drawBoundaries);
    206205    }
     
    244243        return null;
    245244    }
    246    
     245
    247246    public boolean isOverlapping(Bounds bounds) {
    248         GeorefImage georefImage = 
     247        GeorefImage georefImage =
    249248            new GeorefImage(new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB ), // not really important
    250249            Main.proj.latlon2eastNorth(bounds.min),
     
    262261        }
    263262    }
    264    
     263
    265264    public void saveNewCache() {
    266265        if (CacheControl.cacheEnabled) {
     
    270269        }
    271270    }
    272    
     271
    273272    public CacheControl getCacheControl() {
    274273        if (cacheControl == null)
     
    276275        return cacheControl;
    277276    }
    278    
     277
    279278    public class SaveWmsAction extends AbstractAction {
    280279        private static final long serialVersionUID = 1L;
     
    285284
    286285        public void actionPerformed(ActionEvent ev) {
    287             File f = openFileDialog(false);
     286            File f = DiskAccessAction.createAndOpenSaveFileChooser(
     287            tr("Save WMS layer"), ".wms");
    288288            try {
    289289                FileOutputStream fos = new FileOutputStream(f);
     
    311311
    312312        public void actionPerformed(ActionEvent ev) {
    313             File f = openFileDialog(true);
    314             if (f == null)
    315                 return;
     313            JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true,
     314            false, tr("Load WMS layer"));
     315            if(fc == null) return;
     316            File f = fc.getSelectedFile();
     317            if (f == null) return;
    316318            try {
    317319                FileInputStream fis = new FileInputStream(f);
     
    342344    }
    343345
    344     protected static JFileChooser createAndOpenFileChooser(boolean open, boolean multiple) {
    345         String curDir = Main.pref.get("lastDirectory");
    346         if (curDir.equals(""))
    347             curDir = ".";
    348         JFileChooser fc = new JFileChooser(new File(curDir));
    349         fc.setMultiSelectionEnabled(multiple);
    350         for (int i = 0; i < ExtensionFileFilter.filters.length; ++i)
    351             fc.addChoosableFileFilter(ExtensionFileFilter.filters[i]);
    352         fc.setAcceptAllFileFilterUsed(true);
    353 
    354         int answer = open ? fc.showOpenDialog(Main.parent) : fc.showSaveDialog(Main.parent);
    355         if (answer != JFileChooser.APPROVE_OPTION)
    356             return null;
    357 
    358         if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
    359             Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
    360 
    361         if (!open) {
    362             File file = fc.getSelectedFile();
    363             if (file == null
    364                     || (file.exists() && JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(Main.parent,
    365                             tr("File exists. Overwrite?"), tr("Overwrite"), JOptionPane.YES_NO_OPTION)))
    366                 return null;
    367         }
    368 
    369         return fc;
    370     }
    371 
    372     public static File openFileDialog(boolean open) {
    373         JFileChooser fc = createAndOpenFileChooser(open, false);
    374         if (fc == null)
    375             return null;
    376 
    377         File file = fc.getSelectedFile();
    378 
    379         String fn = file.getPath();
    380         if (fn.indexOf('.') == -1) {
    381             FileFilter ff = fc.getFileFilter();
    382             if (ff instanceof ExtensionFileFilter)
    383                 fn = "." + ((ExtensionFileFilter) ff).defaultExtension;
    384             else
    385                 fn += ".osm";
    386             file = new File(fn);
    387         }
    388         return file;
    389     }
    390 
    391346    /**
    392347     * Convert the eastNorth input coordinates to raster coordinates.
     
    434389    /**
    435390     * Set the eastNorth position in rasterMin which is the 0,0 coordinate (bottom left corner).
    436      * The bounds width is the raster width and height is calculate on a fixed image ratio. 
     391     * The bounds width is the raster width and height is calculate on a fixed image ratio.
    437392     * @param bounds
    438393     */
     
    470425            img.resize(rasterCenter, proportion);
    471426    }
    472    
     427
    473428    public void rotate(double angle) {
    474429        this.rasterMin = rasterMin.rotate(rasterCenter, angle);
     
    476431            img.rotate(rasterCenter, angle);
    477432    }
    478    
     433
    479434    /**
    480435     * Repaint the LayerList dialog.
     
    491446        }
    492447    }
    493    
     448
    494449    /**
    495450     * Called by CacheControl when a new cache file is created on disk
     
    503458        oos.writeInt(this.lambertZone);
    504459        oos.writeBoolean(this.isRaster);
    505         if (this.isRaster) { 
     460        if (this.isRaster) {
    506461            oos.writeObject(this.rasterMin);
    507462            oos.writeObject(this.rasterCenter);
     
    514469        }
    515470    }
    516    
     471
    517472    /**
    518473     * Called by CacheControl when a cache file is read from disk
     
    532487        this.lambertZone = ois.readInt();
    533488        this.isRaster = ois.readBoolean();
    534         if (this.isRaster) { 
     489        if (this.isRaster) {
    535490            this.rasterMin = (EastNorth) ois.readObject();
    536491            this.rasterCenter = (EastNorth) ois.readObject();
Note: See TracChangeset for help on using the changeset viewer.