Changeset 34544 in osm for applications/editors/josm
- Timestamp:
- 2018-08-18T19:30:20+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/piclayer
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/piclayer/build.xml
r33809 r34544 3 3 <property name="commit.message" value="[josm/PicLayer] - #12045 add ability to localize dialog titles"/> 4 4 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 5 <property name="plugin.main.version" value="1 3050"/>5 <property name="plugin.main.version" value="14153"/> 6 6 7 7 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java
r34170 r34544 9 9 import javax.swing.JOptionPane; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.actions.JosmAction; 13 12 import org.openstreetmap.josm.actions.mapmode.MapMode; … … 151 150 public void layerRemoving(LayerRemoveEvent e) { 152 151 if (e.getRemovedLayer() instanceof PicLayerAbstract && ((PicLayerAbstract) e.getRemovedLayer()).getTransformer().isModified()) { 153 if (JOptionPane.showConfirmDialog(Main .parent, tr("Do you want to save current calibration of layer {0}?",152 if (JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), tr("Do you want to save current calibration of layer {0}?", 154 153 ((PicLayerAbstract) e.getRemovedLayer()).getPicLayerName()), 155 154 tr("Select an option"), -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationAction.java
r34170 r34544 11 11 import javax.swing.JOptionPane; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.plugins.piclayer.layer.CalibrationFileFilter; 16 16 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; … … 48 48 fc.setFileFilter(new CalibrationFileFilter()); 49 49 fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION)); 50 int result = fc.showOpenDialog(Main .parent);50 int result = fc.showOpenDialog(MainApplication.getMainFrame()); 51 51 52 52 if (result == JFileChooser.APPROVE_OPTION) { … … 58 58 // Error 59 59 e.printStackTrace(); 60 JOptionPane.showMessageDialog(Main .parent,60 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 61 61 tr("Loading file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE); 62 62 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationFromWorldAction.java
r34170 r34544 10 10 import javax.swing.JOptionPane; 11 11 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.actions.JosmAction; 13 import org.openstreetmap.josm.gui.MainApplication; 14 14 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; 15 15 … … 32 32 JFileChooser fc = new JFileChooser(); 33 33 fc.setAcceptAllFileFilterUsed(true); 34 int result = fc.showOpenDialog(Main .parent);34 int result = fc.showOpenDialog(MainApplication.getMainFrame()); 35 35 36 36 if (result == JFileChooser.APPROVE_OPTION) { … … 42 42 // Error 43 43 ex.printStackTrace(); 44 JOptionPane.showMessageDialog(Main .parent,44 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 45 45 tr("Loading file failed: {0}", ex.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE); 46 46 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/SavePictureCalibrationAction.java
r34170 r34544 12 12 import javax.swing.JOptionPane; 13 13 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.actions.JosmAction; 15 import org.openstreetmap.josm.gui.MainApplication; 16 16 import org.openstreetmap.josm.plugins.piclayer.layer.CalibrationFileFilter; 17 17 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; … … 47 47 fc.setFileFilter(new CalibrationFileFilter()); 48 48 fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION)); 49 int result = fc.showSaveDialog(Main .parent);49 int result = fc.showSaveDialog(MainApplication.getMainFrame()); 50 50 51 51 if (result == JFileChooser.APPROVE_OPTION) { … … 66 66 // Error 67 67 e.printStackTrace(); 68 JOptionPane.showMessageDialog(Main .parent,68 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 69 69 tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE); 70 70 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/SavePictureCalibrationToWorldAction.java
r34170 r34544 13 13 import javax.swing.JOptionPane; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.actions.JosmAction; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract; 18 18 … … 63 63 fc.setAcceptAllFileFilterUsed(true); 64 64 fc.setSelectedFile(new File(picFilenameNoext + "." + wext)); 65 int result = fc.showSaveDialog(Main .parent);65 int result = fc.showSaveDialog(MainApplication.getMainFrame()); 66 66 67 67 if (result == JFileChooser.APPROVE_OPTION) { … … 83 83 // Error 84 84 e.printStackTrace(); 85 JOptionPane.showMessageDialog(Main .parent,85 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), 86 86 tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE); 87 87 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java
r34170 r34544 15 15 import javax.swing.filechooser.FileFilter; 16 16 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.actions.JosmAction; 19 18 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; … … 25 24 import org.openstreetmap.josm.plugins.piclayer.layer.kml.KMLGroundOverlay; 26 25 import org.openstreetmap.josm.plugins.piclayer.layer.kml.KMLReader; 26 import org.openstreetmap.josm.spi.preferences.Config; 27 27 28 28 /** … … 88 88 89 89 // Choose a file 90 JFileChooser fc = new JFileChooser( Main.pref.get(m_lastdirprefname));90 JFileChooser fc = new JFileChooser(Config.getPref().get(m_lastdirprefname)); 91 91 fc.setAcceptAllFileFilterUsed(true); 92 92 fc.setFileFilter(new ImageFileFilter()); 93 93 94 94 fc.setMultiSelectionEnabled(true); 95 int result = fc.showOpenDialog(Main .parent);95 int result = fc.showOpenDialog(MainApplication.getMainFrame()); 96 96 97 97 // Create a layer? … … 109 109 // TODO: we need a progress bar here, it can take quite some time 110 110 111 Main.pref.put(m_lastdirprefname, file.getParent());111 Config.getPref().put(m_lastdirprefname, file.getParent()); 112 112 113 113 // Create layer from file … … 148 148 MainApplication.getMap().mapView.moveLayer(layer, newLayerPos++); 149 149 150 if (isZoomToLayer && Main.pref.getInt("piclayer.zoom-on-load", 1) != 0) {150 if (isZoomToLayer && Config.getPref().getInt("piclayer.zoom-on-load", 1) != 0) { 151 151 // if we are loading a single picture file, zoom on it, so that the user can see something 152 152 BoundingXYVisitor v = new BoundingXYVisitor(); -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/MovePointAction.java
r34170 r34544 10 10 import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction; 11 11 import org.openstreetmap.josm.tools.ImageProvider; 12 import org.openstreetmap.josm.tools.Logging; 12 13 13 14 /** … … 30 31 } 31 32 } catch (NoninvertibleTransformException e1) { 32 e1.printStackTrace();33 Logging.error(e1); 33 34 } 34 35 } … … 46 47 currentCommand.addIfChanged(); 47 48 } catch (NoninvertibleTransformException e1) { 48 e1.printStackTrace();49 Logging.error(e1); 49 50 } 50 51 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/TransformPointAction.java
r34170 r34544 10 10 import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction; 11 11 import org.openstreetmap.josm.tools.ImageProvider; 12 import org.openstreetmap.josm.tools.Logging; 12 13 13 14 /** … … 37 38 currentCommand.addIfChanged(); 38 39 } catch (NoninvertibleTransformException e1) { 39 e1.printStackTrace();40 Logging.error(e1); 40 41 } 41 42 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/command/TransformCommand.java
r33822 r34544 8 8 import javax.swing.Icon; 9 9 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.command.Command; 11 import org.openstreetmap.josm.data.UndoRedoHandler; 12 12 import org.openstreetmap.josm.data.osm.DataSet; 13 13 import org.openstreetmap.josm.data.osm.OsmPrimitive; … … 81 81 !(beforeTransform.getImagePosition().equals(afterTransform.getImagePosition())); 82 82 if (changed && !alreadyAdded) { 83 Main.main.undoRedo.add(this);83 UndoRedoHandler.getInstance().add(this); 84 84 alreadyAdded = true; 85 85 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java
r34170 r34544 18 18 import java.io.InputStreamReader; 19 19 import java.io.Reader; 20 import java.nio.charset.StandardCharsets; 20 21 import java.util.Properties; 21 22 … … 24 25 import javax.swing.ImageIcon; 25 26 26 import org.openstreetmap.josm.Main;27 27 import org.openstreetmap.josm.actions.RenameLayerAction; 28 28 import org.openstreetmap.josm.data.Bounds; … … 31 31 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 32 32 import org.openstreetmap.josm.data.projection.Projection; 33 import org.openstreetmap.josm.data.projection.ProjectionRegistry; 33 34 import org.openstreetmap.josm.gui.MainApplication; 34 35 import org.openstreetmap.josm.gui.MapView; … … 127 128 } 128 129 129 projection = Main.getProjection();130 projection = ProjectionRegistry.getProjection(); 130 131 } 131 132 … … 462 463 463 464 try ( 464 Reader reader = new InputStreamReader(is); 465 Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8); 465 466 BufferedReader br = new BufferedReader(reader) 466 467 ) { … … 480 481 dy + w/2*ry + h/2*sy 481 482 ); 482 // initialImagePosition.setLocation(imagePosition);483 // m_angle = 0;484 483 double scalex = 100*sx*getMetersPerEasting(imagePosition); 485 484 double scaley = -100*sy*getMetersPerNorthing(imagePosition); … … 613 612 return selected; 614 613 } catch (NoninvertibleTransformException e) { 615 e.printStackTrace();614 Logging.error(e); 616 615 } 617 616 return selected; -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerFromFile.java
r33822 r34544 17 17 import javax.swing.JOptionPane; 18 18 19 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.gui.MainApplication; 20 import org.openstreetmap.josm.spi.preferences.Config; 20 21 import org.openstreetmap.josm.tools.Logging; 21 22 … … 181 182 protected boolean confirmCalibrationLoading(String fileName) { 182 183 String prefkey = "piclayer.autoloadcal"; 183 String policy = Main.pref.get(prefkey, "");184 String policy = Config.getPref().get(prefkey, ""); 184 185 policy = policy.trim().toLowerCase(); 185 186 boolean loadcal = false; … … 194 195 "to control the autoloading of calibration files.", prefkey); 195 196 msg += "\n" + tr("Do you want to apply it ?"); 196 int answer = JOptionPane.showConfirmDialog(Main .parent, msg, tr("Load calibration file?"), JOptionPane.YES_NO_OPTION);197 int answer = JOptionPane.showConfirmDialog(MainApplication.getMainFrame(), msg, tr("Load calibration file?"), JOptionPane.YES_NO_OPTION); 197 198 if (answer == JOptionPane.YES_OPTION) { 198 199 loadcal = true; … … 204 205 "to control the autoloading of calibration files.", prefkey); 205 206 // TODO: there should be here a yes/no dialog with a checkbox "do not ask again" 206 JOptionPane.showMessageDialog(Main .parent, msg,207 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), msg, 207 208 "Automatic loading of the calibration", JOptionPane.INFORMATION_MESSAGE); 208 Main.pref.put(prefkey, "yes");209 Config.getPref().put(prefkey, "yes"); 209 210 loadcal = true; 210 211 } -
applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/kml/KMLReader.java
r33822 r34544 5 5 import java.io.FileReader; 6 6 import java.io.IOException; 7 import java.util.ArrayList;8 7 import java.util.List; 9 8 10 import org. xml.sax.Attributes;9 import org.openstreetmap.josm.tools.Logging; 11 10 import org.xml.sax.InputSource; 12 11 import org.xml.sax.SAXException; 13 12 import org.xml.sax.XMLReader; 14 import org.xml.sax.helpers.DefaultHandler;15 13 import org.xml.sax.helpers.XMLReaderFactory; 16 14 … … 30 28 xr.setContentHandler(handler); 31 29 xr.parse(new InputSource(new FileReader(file))); 32 } catch (SAXException e) { 33 e.printStackTrace(); 34 } catch (IOException e) { 35 e.printStackTrace(); 30 } catch (SAXException | IOException e) { 31 Logging.error(e); 36 32 } 37 33 groundOverlays = handler.getResult(); … … 42 38 } 43 39 } 44 45 class KMLHandler extends DefaultHandler {46 47 private boolean inGroundOverlay = false;48 private boolean inIcon = false;49 private boolean inLatLonBox = false;50 private String value;51 private List<KMLGroundOverlay> result;52 private KMLGroundOverlay overlay;53 54 KMLHandler() {55 result = new ArrayList<>();56 }57 58 @Override59 public void startElement(String uri, String localName, String qName,60 Attributes attributes) throws SAXException {61 if ("GroundOverlay".equals(localName)) {62 inGroundOverlay = true;63 overlay = new KMLGroundOverlay();64 } else if (inGroundOverlay && "Icon".equals(localName)) {65 inIcon = true;66 } else if (inGroundOverlay && "LatLonBox".equals(localName)) {67 inLatLonBox = true;68 }69 }70 71 @Override72 public void endElement(String uri, String localName, String qName)73 throws SAXException {74 if (inGroundOverlay && "name".equals(localName)) {75 overlay.setName(value.trim());76 } else if (inIcon && "href".equals(localName)) {77 overlay.setFileName(value.trim());78 } else if (inLatLonBox && "north".equals(localName)) {79 overlay.setNorth(Double.valueOf(value.trim()));80 } else if (inLatLonBox && "east".equals(localName)) {81 overlay.setEast(Double.valueOf(value.trim()));82 } else if (inLatLonBox && "south".equals(localName)) {83 overlay.setSouth(Double.valueOf(value.trim()));84 } else if (inLatLonBox && "west".equals(localName)) {85 overlay.setWest(Double.valueOf(value.trim()));86 } else if (inLatLonBox && "rotation".equals(localName)) {87 overlay.setRotate(Double.valueOf(value.trim()));88 } else if (inLatLonBox && "LatLonBox".equals(localName)) {89 inLatLonBox = false;90 } else if (inIcon && "Icon".equals(localName)) {91 inIcon = false;92 } else if (inGroundOverlay && "GroundOverlay".equals(localName)) {93 inGroundOverlay = false;94 result.add(overlay);95 }96 }97 98 @Override99 public void characters(char[] ch, int start, int length)100 throws SAXException {101 value = new String(ch, start, length);102 }103 104 public List<KMLGroundOverlay> getResult() {105 return result;106 }107 }
Note:
See TracChangeset
for help on using the changeset viewer.