Changeset 15972 in osm for applications/editors/josm/plugins/cadastre-fr/src
- Timestamp:
- 2009-06-17T20:33:03+02:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/cadastre-fr/src/cadastre_fr/WMSLayer.java
r15962 r15972 7 7 import java.awt.Graphics2D; 8 8 import java.awt.Toolkit; 9 import java.awt.event.ActionEvent;10 9 import java.awt.image.BufferedImage; 11 10 import java.io.EOFException; 12 import java.io.File;13 import java.io.FileInputStream;14 import java.io.FileOutputStream;15 11 import java.io.IOException; 16 12 import java.io.ObjectInputStream; … … 18 14 import java.util.ArrayList; 19 15 20 import javax.swing.AbstractAction;21 16 import javax.swing.Icon; 22 17 import javax.swing.ImageIcon; 23 import javax.swing.JFileChooser;24 18 import javax.swing.JMenuItem; 25 19 import javax.swing.JOptionPane; 26 import javax.swing.JSeparator;27 20 28 21 import org.openstreetmap.josm.Main; 29 import org.openstreetmap.josm.actions.DiskAccessAction;30 22 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 31 23 import org.openstreetmap.josm.data.projection.Lambert; … … 36 28 import org.openstreetmap.josm.gui.layer.Layer; 37 29 import org.openstreetmap.josm.io.OsmTransferException; 38 import org.openstreetmap.josm.tools.ImageProvider;39 30 import org.openstreetmap.josm.data.coor.EastNorth; 40 31 … … 224 215 @Override 225 216 public Component[] getMenuEntries() { 226 /*227 return new Component[] { new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)),228 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), new JMenuItem(new LoadWmsAction()),229 new JMenuItem(new SaveWmsAction()), new JSeparator(),230 new JMenuItem(new LayerListPopup.InfoAction(this)) };231 */232 217 component = new Component[] { new JMenuItem(new LayerListDialog.ShowHideLayerAction(this)), 233 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), new JMenuItem(new LoadWmsAction()), 234 new JMenuItem(new SaveWmsAction()), new JSeparator(), 218 new JMenuItem(new LayerListDialog.DeleteLayerAction(this)), new JMenuItem(new MenuActionLoadFromCache()), 235 219 new JMenuItem(new LayerListPopup.InfoAction(this)) }; 236 220 return component; … … 278 262 cacheControl = new CacheControl(this); 279 263 return cacheControl; 280 }281 282 public class SaveWmsAction extends AbstractAction {283 private static final long serialVersionUID = 1L;284 285 public SaveWmsAction() {286 super(tr("Save WMS layer to file"), ImageProvider.get("save"));287 }288 289 public void actionPerformed(ActionEvent ev) {290 File f = DiskAccessAction.createAndOpenSaveFileChooser(291 tr("Save WMS layer"), ".wms");292 try {293 FileOutputStream fos = new FileOutputStream(f);294 ObjectOutputStream oos = new ObjectOutputStream(fos);295 oos.writeInt(serializeFormatVersion);296 oos.writeInt(lambertZone);297 oos.writeInt(images.size());298 for (GeorefImage img : images) {299 oos.writeObject(img);300 }301 oos.close();302 fos.close();303 } catch (Exception ex) {304 ex.printStackTrace(System.out);305 }306 }307 }308 309 public class LoadWmsAction extends AbstractAction {310 private static final long serialVersionUID = 1L;311 312 public LoadWmsAction() {313 super(tr("Load WMS layer from file"), ImageProvider.get("load"));314 }315 316 public void actionPerformed(ActionEvent ev) {317 JFileChooser fc = DiskAccessAction.createAndOpenFileChooser(true,318 false, tr("Load WMS layer"));319 if(fc == null) return;320 File f = fc.getSelectedFile();321 if (f == null) return;322 try {323 FileInputStream fis = new FileInputStream(f);324 ObjectInputStream ois = new ObjectInputStream(fis);325 int sfv = ois.readInt();326 if (sfv != serializeFormatVersion) {327 JOptionPane.showMessageDialog(Main.parent, tr(328 "Unsupported WMS file version; found {0}, expected {1}", sfv, serializeFormatVersion),329 tr("File Format Error"), JOptionPane.ERROR_MESSAGE);330 return;331 }332 lambertZone = ois.readInt();333 int numImg = ois.readInt();334 for (int i = 0; i < numImg; i++) {335 GeorefImage img = (GeorefImage) ois.readObject();336 images.add(img);337 }338 ois.close();339 fis.close();340 } catch (Exception ex) {341 // FIXME be more specific342 ex.printStackTrace(System.out);343 JOptionPane.showMessageDialog(Main.parent, tr("Error loading file"), tr("Error"),344 JOptionPane.ERROR_MESSAGE);345 return;346 }347 }348 264 } 349 265
Note:
See TracChangeset
for help on using the changeset viewer.