Changeset 34544 in osm for applications/editors/josm


Ignore:
Timestamp:
2018-08-18T19:30:20+02:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 14153

Location:
applications/editors/josm/plugins/piclayer
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/piclayer/build.xml

    r33809 r34544  
    33    <property name="commit.message" value="[josm/PicLayer] - #12045 add ability to localize dialog titles"/>
    44    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    5     <property name="plugin.main.version" value="13050"/>
     5    <property name="plugin.main.version" value="14153"/>
    66       
    77    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/PicLayerPlugin.java

    r34170 r34544  
    99import javax.swing.JOptionPane;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.JosmAction;
    1312import org.openstreetmap.josm.actions.mapmode.MapMode;
     
    151150    public void layerRemoving(LayerRemoveEvent e) {
    152151        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}?",
    154153                    ((PicLayerAbstract) e.getRemovedLayer()).getPicLayerName()),
    155154                    tr("Select an option"),
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationAction.java

    r34170 r34544  
    1111import javax.swing.JOptionPane;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.actions.JosmAction;
     14import org.openstreetmap.josm.gui.MainApplication;
    1515import org.openstreetmap.josm.plugins.piclayer.layer.CalibrationFileFilter;
    1616import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract;
     
    4848        fc.setFileFilter(new CalibrationFileFilter());
    4949        fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    50         int result = fc.showOpenDialog(Main.parent);
     50        int result = fc.showOpenDialog(MainApplication.getMainFrame());
    5151
    5252        if (result == JFileChooser.APPROVE_OPTION) {
     
    5858                // Error
    5959                e.printStackTrace();
    60                 JOptionPane.showMessageDialog(Main.parent,
     60                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    6161                        tr("Loading file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    6262            }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/LoadPictureCalibrationFromWorldAction.java

    r34170 r34544  
    1010import javax.swing.JOptionPane;
    1111
    12 import org.openstreetmap.josm.Main;
    1312import org.openstreetmap.josm.actions.JosmAction;
     13import org.openstreetmap.josm.gui.MainApplication;
    1414import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract;
    1515
     
    3232        JFileChooser fc = new JFileChooser();
    3333        fc.setAcceptAllFileFilterUsed(true);
    34         int result = fc.showOpenDialog(Main.parent);
     34        int result = fc.showOpenDialog(MainApplication.getMainFrame());
    3535
    3636        if (result == JFileChooser.APPROVE_OPTION) {
     
    4242                // Error
    4343                ex.printStackTrace();
    44                 JOptionPane.showMessageDialog(Main.parent,
     44                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    4545                        tr("Loading file failed: {0}", ex.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    4646            }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/SavePictureCalibrationAction.java

    r34170 r34544  
    1212import javax.swing.JOptionPane;
    1313
    14 import org.openstreetmap.josm.Main;
    1514import org.openstreetmap.josm.actions.JosmAction;
     15import org.openstreetmap.josm.gui.MainApplication;
    1616import org.openstreetmap.josm.plugins.piclayer.layer.CalibrationFileFilter;
    1717import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract;
     
    4747        fc.setFileFilter(new CalibrationFileFilter());
    4848        fc.setSelectedFile(new File(m_owner.getPicLayerName() + CalibrationFileFilter.EXTENSION));
    49         int result = fc.showSaveDialog(Main.parent);
     49        int result = fc.showSaveDialog(MainApplication.getMainFrame());
    5050
    5151        if (result == JFileChooser.APPROVE_OPTION) {
     
    6666                // Error
    6767                e.printStackTrace();
    68                 JOptionPane.showMessageDialog(Main.parent,
     68                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    6969                        tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    7070            }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/SavePictureCalibrationToWorldAction.java

    r34170 r34544  
    1313import javax.swing.JOptionPane;
    1414
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.actions.JosmAction;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.plugins.piclayer.layer.PicLayerAbstract;
    1818
     
    6363        fc.setAcceptAllFileFilterUsed(true);
    6464        fc.setSelectedFile(new File(picFilenameNoext + "." + wext));
    65         int result = fc.showSaveDialog(Main.parent);
     65        int result = fc.showSaveDialog(MainApplication.getMainFrame());
    6666
    6767        if (result == JFileChooser.APPROVE_OPTION) {
     
    8383                // Error
    8484                e.printStackTrace();
    85                 JOptionPane.showMessageDialog(Main.parent,
     85                JOptionPane.showMessageDialog(MainApplication.getMainFrame(),
    8686                        tr("Saving file failed: {0}", e.getMessage()), tr("Problem occurred"), JOptionPane.WARNING_MESSAGE);
    8787            }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/newlayer/NewLayerFromFileAction.java

    r34170 r34544  
    1515import javax.swing.filechooser.FileFilter;
    1616
    17 import org.openstreetmap.josm.Main;
    1817import org.openstreetmap.josm.actions.JosmAction;
    1918import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     
    2524import org.openstreetmap.josm.plugins.piclayer.layer.kml.KMLGroundOverlay;
    2625import org.openstreetmap.josm.plugins.piclayer.layer.kml.KMLReader;
     26import org.openstreetmap.josm.spi.preferences.Config;
    2727
    2828/**
     
    8888
    8989        // Choose a file
    90         JFileChooser fc = new JFileChooser(Main.pref.get(m_lastdirprefname));
     90        JFileChooser fc = new JFileChooser(Config.getPref().get(m_lastdirprefname));
    9191        fc.setAcceptAllFileFilterUsed(true);
    9292        fc.setFileFilter(new ImageFileFilter());
    9393
    9494        fc.setMultiSelectionEnabled(true);
    95         int result = fc.showOpenDialog(Main.parent);
     95        int result = fc.showOpenDialog(MainApplication.getMainFrame());
    9696
    9797        // Create a layer?
     
    109109                // TODO: we need a progress bar here, it can take quite some time
    110110
    111                 Main.pref.put(m_lastdirprefname, file.getParent());
     111                Config.getPref().put(m_lastdirprefname, file.getParent());
    112112
    113113                // Create layer from file
     
    148148        MainApplication.getMap().mapView.moveLayer(layer, newLayerPos++);
    149149
    150         if (isZoomToLayer && Main.pref.getInt("piclayer.zoom-on-load", 1) != 0) {
     150        if (isZoomToLayer && Config.getPref().getInt("piclayer.zoom-on-load", 1) != 0) {
    151151            // if we are loading a single picture file, zoom on it, so that the user can see something
    152152            BoundingXYVisitor v = new BoundingXYVisitor();
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/MovePointAction.java

    r34170 r34544  
    1010import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction;
    1111import org.openstreetmap.josm.tools.ImageProvider;
     12import org.openstreetmap.josm.tools.Logging;
    1213
    1314/**
     
    3031            }
    3132        } catch (NoninvertibleTransformException e1) {
    32             e1.printStackTrace();
     33            Logging.error(e1);
    3334        }
    3435    }
     
    4647            currentCommand.addIfChanged();
    4748        } catch (NoninvertibleTransformException e1) {
    48             e1.printStackTrace();
     49            Logging.error(e1);
    4950        }
    5051    }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/actions/transform/affine/TransformPointAction.java

    r34170 r34544  
    1010import org.openstreetmap.josm.plugins.piclayer.actions.GenericPicTransformAction;
    1111import org.openstreetmap.josm.tools.ImageProvider;
     12import org.openstreetmap.josm.tools.Logging;
    1213
    1314/**
     
    3738            currentCommand.addIfChanged();
    3839        } catch (NoninvertibleTransformException e1) {
    39             e1.printStackTrace();
     40            Logging.error(e1);
    4041        }
    4142    }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/command/TransformCommand.java

    r33822 r34544  
    88import javax.swing.Icon;
    99
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.command.Command;
     11import org.openstreetmap.josm.data.UndoRedoHandler;
    1212import org.openstreetmap.josm.data.osm.DataSet;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitive;
     
    8181            !(beforeTransform.getImagePosition().equals(afterTransform.getImagePosition()));
    8282        if (changed && !alreadyAdded) {
    83             Main.main.undoRedo.add(this);
     83            UndoRedoHandler.getInstance().add(this);
    8484            alreadyAdded = true;
    8585        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerAbstract.java

    r34170 r34544  
    1818import java.io.InputStreamReader;
    1919import java.io.Reader;
     20import java.nio.charset.StandardCharsets;
    2021import java.util.Properties;
    2122
     
    2425import javax.swing.ImageIcon;
    2526
    26 import org.openstreetmap.josm.Main;
    2727import org.openstreetmap.josm.actions.RenameLayerAction;
    2828import org.openstreetmap.josm.data.Bounds;
     
    3131import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    3232import org.openstreetmap.josm.data.projection.Projection;
     33import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3334import org.openstreetmap.josm.gui.MainApplication;
    3435import org.openstreetmap.josm.gui.MapView;
     
    127128        }
    128129
    129         projection = Main.getProjection();
     130        projection = ProjectionRegistry.getProjection();
    130131    }
    131132
     
    462463
    463464        try (
    464             Reader reader = new InputStreamReader(is);
     465            Reader reader = new InputStreamReader(is, StandardCharsets.UTF_8);
    465466            BufferedReader br = new BufferedReader(reader)
    466467        ) {
     
    480481                    dy + w/2*ry + h/2*sy
    481482            );
    482 //            initialImagePosition.setLocation(imagePosition);
    483 //            m_angle = 0;
    484483            double scalex = 100*sx*getMetersPerEasting(imagePosition);
    485484            double scaley = -100*sy*getMetersPerNorthing(imagePosition);
     
    613612            return selected;
    614613        } catch (NoninvertibleTransformException e) {
    615             e.printStackTrace();
     614            Logging.error(e);
    616615        }
    617616        return selected;
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/PicLayerFromFile.java

    r33822 r34544  
    1717import javax.swing.JOptionPane;
    1818
    19 import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.gui.MainApplication;
     20import org.openstreetmap.josm.spi.preferences.Config;
    2021import org.openstreetmap.josm.tools.Logging;
    2122
     
    181182    protected boolean confirmCalibrationLoading(String fileName) {
    182183        String prefkey = "piclayer.autoloadcal";
    183         String policy = Main.pref.get(prefkey, "");
     184        String policy = Config.getPref().get(prefkey, "");
    184185        policy = policy.trim().toLowerCase();
    185186        boolean loadcal = false;
     
    194195                            "to control the autoloading of calibration files.", prefkey);
    195196            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);
    197198            if (answer == JOptionPane.YES_OPTION) {
    198199                loadcal = true;
     
    204205                            "to control the autoloading of calibration files.", prefkey);
    205206            // 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,
    207208                "Automatic loading of the calibration", JOptionPane.INFORMATION_MESSAGE);
    208             Main.pref.put(prefkey, "yes");
     209            Config.getPref().put(prefkey, "yes");
    209210            loadcal = true;
    210211        }
  • applications/editors/josm/plugins/piclayer/src/org/openstreetmap/josm/plugins/piclayer/layer/kml/KMLReader.java

    r33822 r34544  
    55import java.io.FileReader;
    66import java.io.IOException;
    7 import java.util.ArrayList;
    87import java.util.List;
    98
    10 import org.xml.sax.Attributes;
     9import org.openstreetmap.josm.tools.Logging;
    1110import org.xml.sax.InputSource;
    1211import org.xml.sax.SAXException;
    1312import org.xml.sax.XMLReader;
    14 import org.xml.sax.helpers.DefaultHandler;
    1513import org.xml.sax.helpers.XMLReaderFactory;
    1614
     
    3028            xr.setContentHandler(handler);
    3129            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);
    3632        }
    3733        groundOverlays = handler.getResult();
     
    4238    }
    4339}
    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     @Override
    59     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     @Override
    72     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     @Override
    99     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.