Changeset 15707 in osm for applications/editors/josm/plugins/cadastre-fr
- Timestamp:
- 2009-06-06T22:25:31+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/cadastre-fr
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/build.xml
r14120 r15707 26 26 <attribute name="Plugin-Description" value="A special handler for the french land registry WMS server."/> 27 27 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/Cadastre"/> 28 <attribute name="Plugin-Mainversion" value="1 498"/>28 <attribute name="Plugin-Mainversion" value="1646"/> 29 29 <attribute name="Plugin-Stage" value="60"/> 30 30 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/> -
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r13784 r15707 25 25 import javax.swing.JOptionPane; 26 26 import javax.swing.JSeparator; 27 import javax.swing.filechooser.FileFilter;28 27 29 28 import org.openstreetmap.josm.Main; 30 import org.openstreetmap.josm.actions. ExtensionFileFilter;29 import org.openstreetmap.josm.actions.DiskAccessAction; 31 30 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 32 31 import org.openstreetmap.josm.data.projection.Lambert; … … 46 45 public class WMSLayer extends Layer { 47 46 48 Component[] component = null; 47 Component[] component = null; 49 48 50 49 public int lambertZone = -1; … … 54 53 55 54 protected ArrayList<GeorefImage> images = new ArrayList<GeorefImage>(); 56 55 57 56 protected final int serializeFormatVersion = 2; 58 57 59 58 private ArrayList<EastNorthBound> dividedBbox = new ArrayList<EastNorthBound>(); 60 59 61 60 private CacheControl cacheControl = null; 62 61 63 62 private String location = ""; 64 63 65 64 private String codeCommune = ""; 66 65 67 66 private EastNorthBound communeBBox = new EastNorthBound(new EastNorth(0,0), new EastNorth(0,0)); 68 67 69 68 private boolean isRaster = false; 70 69 71 70 private EastNorth rasterMin; 72 71 73 72 private EastNorth rasterCenter; 74 73 75 74 private double rasterRatio; 76 75 … … 81 80 this(tr("Blank Layer"), "", -1); 82 81 } 83 82 84 83 public WMSLayer(String location, String codeCommune, int lambertZone) { 85 84 super(buildName(location, codeCommune)); … … 90 89 CadastrePlugin.pluginUsed = true; 91 90 } 92 91 93 92 private static String buildName(String location, String codeCommune) { 94 93 String ret = new String(location.toUpperCase()); … … 138 137 139 138 /** 140 * 139 * 141 140 * @param b the original bbox, usually the current bbox on screen 142 141 * @param factor 1 = source bbox 1:1 … … 202 201 public void paint(Graphics g, final MapView mv) { 203 202 for (GeorefImage img : images) 204 img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent, 203 img.paint((Graphics2D) g, mv, CadastrePlugin.backgroundTransparent, 205 204 CadastrePlugin.transparency, CadastrePlugin.drawBoundaries); 206 205 } … … 244 243 return null; 245 244 } 246 245 247 246 public boolean isOverlapping(Bounds bounds) { 248 GeorefImage georefImage = 247 GeorefImage georefImage = 249 248 new GeorefImage(new BufferedImage(1,1,BufferedImage.TYPE_INT_RGB ), // not really important 250 249 Main.proj.latlon2eastNorth(bounds.min), … … 262 261 } 263 262 } 264 263 265 264 public void saveNewCache() { 266 265 if (CacheControl.cacheEnabled) { … … 270 269 } 271 270 } 272 271 273 272 public CacheControl getCacheControl() { 274 273 if (cacheControl == null) … … 276 275 return cacheControl; 277 276 } 278 277 279 278 public class SaveWmsAction extends AbstractAction { 280 279 private static final long serialVersionUID = 1L; … … 285 284 286 285 public void actionPerformed(ActionEvent ev) { 287 File f = openFileDialog(false); 286 File f = DiskAccessAction.createAndOpenSaveFileChooser( 287 tr("Save WMS layer"), ".wms"); 288 288 try { 289 289 FileOutputStream fos = new FileOutputStream(f); … … 311 311 312 312 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; 316 318 try { 317 319 FileInputStream fis = new FileInputStream(f); … … 342 344 } 343 345 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 == null364 || (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 else385 fn += ".osm";386 file = new File(fn);387 }388 return file;389 }390 391 346 /** 392 347 * Convert the eastNorth input coordinates to raster coordinates. … … 434 389 /** 435 390 * 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. 437 392 * @param bounds 438 393 */ … … 470 425 img.resize(rasterCenter, proportion); 471 426 } 472 427 473 428 public void rotate(double angle) { 474 429 this.rasterMin = rasterMin.rotate(rasterCenter, angle); … … 476 431 img.rotate(rasterCenter, angle); 477 432 } 478 433 479 434 /** 480 435 * Repaint the LayerList dialog. … … 491 446 } 492 447 } 493 448 494 449 /** 495 450 * Called by CacheControl when a new cache file is created on disk … … 503 458 oos.writeInt(this.lambertZone); 504 459 oos.writeBoolean(this.isRaster); 505 if (this.isRaster) { 460 if (this.isRaster) { 506 461 oos.writeObject(this.rasterMin); 507 462 oos.writeObject(this.rasterCenter); … … 514 469 } 515 470 } 516 471 517 472 /** 518 473 * Called by CacheControl when a cache file is read from disk … … 532 487 this.lambertZone = ois.readInt(); 533 488 this.isRaster = ois.readBoolean(); 534 if (this.isRaster) { 489 if (this.isRaster) { 535 490 this.rasterMin = (EastNorth) ois.readObject(); 536 491 this.rasterCenter = (EastNorth) ois.readObject();
Note:
See TracChangeset
for help on using the changeset viewer.