Changeset 34556 in osm for applications


Ignore:
Timestamp:
2018-08-18T20:16:45+02:00 (6 years ago)
Author:
donvip
Message:

update to JOSM 14153

Location:
applications/editors/josm/plugins/simplifyarea
Files:
3 edited

Legend:

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

    r33918 r34556  
    44    <property name="commit.message" value="Initial commit"/>
    55    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    6     <property name="plugin.main.version" value="12643"/>
     6    <property name="plugin.main.version" value="14153"/>
    77       
    88    <!-- Configure these properties (replace "..." accordingly).
  • applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java

    r33918 r34556  
    2121import javax.swing.JOptionPane;
    2222
    23 import org.openstreetmap.josm.Main;
    2423import org.openstreetmap.josm.actions.JosmAction;
    2524import org.openstreetmap.josm.command.ChangeCommand;
     
    2928import org.openstreetmap.josm.command.SequenceCommand;
    3029import org.openstreetmap.josm.data.Bounds;
     30import org.openstreetmap.josm.data.UndoRedoHandler;
    3131import org.openstreetmap.josm.data.coor.LatLon;
    3232import org.openstreetmap.josm.data.osm.Node;
     
    3535import org.openstreetmap.josm.data.osm.Way;
    3636import org.openstreetmap.josm.gui.HelpAwareOptionPane;
     37import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
    3738import org.openstreetmap.josm.gui.MainApplication;
    38 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec;
     39import org.openstreetmap.josm.spi.preferences.Config;
    3940import org.openstreetmap.josm.tools.ImageProvider;
    4041import org.openstreetmap.josm.tools.Shortcut;
     
    6566                new ButtonSpec(tr("No, abort"), ImageProvider.get("cancel"), tr("Cancel operation"), null) };
    6667        return 0 == HelpAwareOptionPane.showOptionDialog(
    67                 Main.parent,
     68                MainApplication.getMainFrame(),
    6869                "<html>" + trn("The selected way has nodes outside of the downloaded data region.", "The selected ways have nodes outside of the downloaded data region.",
    6970                        MainApplication.getLayerManager().getEditDataSet().getSelectedWays().size())
     
    7475
    7576    private void alertSelectAtLeastOneWay() {
    76         HelpAwareOptionPane.showOptionDialog(Main.parent, tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null);
     77        HelpAwareOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("Please select at least one way to simplify."), tr("Warning"), JOptionPane.WARNING_MESSAGE, null);
    7778    }
    7879
     
    8081        final ButtonSpec[] options = new ButtonSpec[] { new ButtonSpec(tr("Yes"), ImageProvider.get("ok"), tr("Simplify all selected ways"), null),
    8182                new ButtonSpec(tr("Cancel"), ImageProvider.get("cancel"), tr("Cancel operation"), null) };
    82         return 0 == HelpAwareOptionPane.showOptionDialog(Main.parent, tr("The selection contains {0} ways. Are you sure you want to simplify them all?", numWays),
     83        return 0 == HelpAwareOptionPane.showOptionDialog(MainApplication.getMainFrame(), tr("The selection contains {0} ways. Are you sure you want to simplify them all?", numWays),
    8384                tr("Simplify ways?"),
    8485                JOptionPane.WARNING_MESSAGE, null, // no special icon
     
    174175        if (!allCommands.isEmpty()) {
    175176            final SequenceCommand rootCommand = new SequenceCommand(trn("Simplify {0} way", "Simplify {0} ways", allCommands.size(), allCommands.size()), allCommands);
    176             Main.main.undoRedo.add(rootCommand);
     177            UndoRedoHandler.getInstance().add(rootCommand);
    177178            MainApplication.getMap().repaint();
    178179        }
     
    198199    // average nearby nodes
    199200    private static Collection<Command> averageNearbyNodes(final Collection<Way> ways, final Collection<Node> nodesAlreadyDeleted) {
    200         final double mergeThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.MERGE_THRESHOLD, 0.2);
     201        final double mergeThreshold = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.MERGE_THRESHOLD, 0.2);
    201202
    202203        final Map<Node, LatLon> coordMap = new HashMap<>();
     
    321322
    322323    private static void addNodesToDelete(final Collection<Node> nodesToDelete, final Way w) {
    323         final double angleThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10);
    324         final double angleFactor = Main.pref.getDouble(SimplifyAreaPreferenceSetting.ANGLE_FACTOR, 1.0);
    325         final double areaThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.AREA_THRESHOLD, 5.0);
    326         final double areaFactor = Main.pref.getDouble(SimplifyAreaPreferenceSetting.AREA_FACTOR, 1.0);
    327         final double distanceThreshold = Main.pref.getDouble(SimplifyAreaPreferenceSetting.DIST_THRESHOLD, 3);
    328         final double distanceFactor = Main.pref.getDouble(SimplifyAreaPreferenceSetting.DIST_FACTOR, 3);
     324        final double angleThreshold = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.ANGLE_THRESHOLD, 10);
     325        final double angleFactor = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.ANGLE_FACTOR, 1.0);
     326        final double areaThreshold = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.AREA_THRESHOLD, 5.0);
     327        final double areaFactor = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.AREA_FACTOR, 1.0);
     328        final double distanceThreshold = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.DIST_THRESHOLD, 3);
     329        final double distanceFactor = Config.getPref().getDouble(SimplifyAreaPreferenceSetting.DIST_FACTOR, 3);
    329330
    330331        final List<Node> nodes = w.getNodes();
  • applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaPreferenceSetting.java

    r30688 r34556  
    99import javax.swing.JTextField;
    1010
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting;
    1312import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1413import org.openstreetmap.josm.gui.widgets.JosmTextField;
     14import org.openstreetmap.josm.spi.preferences.Config;
    1515import org.openstreetmap.josm.tools.GBC;
    1616
     
    4949        final JPanel tab = gui.createPreferenceTab(this);
    5050
    51         angleThreshold.setText(Main.pref.get(ANGLE_THRESHOLD, "10"));
     51        angleThreshold.setText(Config.getPref().get(ANGLE_THRESHOLD, "10"));
    5252        tab.add(new JLabel(tr("Angle Threshold")), GBC.std());
    5353        tab.add(angleThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    5454
    55         angleFactor.setText(Main.pref.get(ANGLE_FACTOR, "1.0"));
     55        angleFactor.setText(Config.getPref().get(ANGLE_FACTOR, "1.0"));
    5656        tab.add(new JLabel(tr("Angle Factor")), GBC.std());
    5757        tab.add(angleFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    5858
    59         areaThreshold.setText(Main.pref.get(AREA_THRESHOLD, "5.0"));
     59        areaThreshold.setText(Config.getPref().get(AREA_THRESHOLD, "5.0"));
    6060        tab.add(new JLabel(tr("Area Threshold")), GBC.std());
    6161        tab.add(areaThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    6262
    63         areaFactor.setText(Main.pref.get(AREA_FACTOR, "1.0"));
     63        areaFactor.setText(Config.getPref().get(AREA_FACTOR, "1.0"));
    6464        tab.add(new JLabel(tr("Area Factor")), GBC.std());
    6565        tab.add(areaFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    6666
    67         distanceThreshold.setText(Main.pref.get(DIST_THRESHOLD, "3"));
     67        distanceThreshold.setText(Config.getPref().get(DIST_THRESHOLD, "3"));
    6868        tab.add(new JLabel(tr("Distance Threshold")), GBC.std());
    6969        tab.add(distanceThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    7070
    71         distanceFactor.setText(Main.pref.get(DIST_FACTOR, "3"));
     71        distanceFactor.setText(Config.getPref().get(DIST_FACTOR, "3"));
    7272        tab.add(new JLabel(tr("Distance Factor")), GBC.std());
    7373        tab.add(distanceFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
    7474
    75         mergeThreshold.setText(Main.pref.get(MERGE_THRESHOLD, "0.2"));
     75        mergeThreshold.setText(Config.getPref().get(MERGE_THRESHOLD, "0.2"));
    7676        tab.add(new JLabel(tr("Merge Nearby Nodes Threshold")), GBC.std());
    7777        tab.add(mergeThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5));
     
    8282    @Override
    8383    public boolean ok() {
    84         Main.pref.put(MERGE_THRESHOLD, mergeThreshold.getText());
    85         Main.pref.put(ANGLE_THRESHOLD, angleThreshold.getText());
    86         Main.pref.put(ANGLE_FACTOR, angleFactor.getText());
    87         Main.pref.put(AREA_THRESHOLD, areaThreshold.getText());
    88         Main.pref.put(AREA_FACTOR, areaFactor.getText());
    89         Main.pref.put(DIST_THRESHOLD, distanceThreshold.getText());
    90         Main.pref.put(DIST_FACTOR, distanceFactor.getText());
     84        Config.getPref().put(MERGE_THRESHOLD, mergeThreshold.getText());
     85        Config.getPref().put(ANGLE_THRESHOLD, angleThreshold.getText());
     86        Config.getPref().put(ANGLE_FACTOR, angleFactor.getText());
     87        Config.getPref().put(AREA_THRESHOLD, areaThreshold.getText());
     88        Config.getPref().put(AREA_FACTOR, areaFactor.getText());
     89        Config.getPref().put(DIST_THRESHOLD, distanceThreshold.getText());
     90        Config.getPref().put(DIST_FACTOR, distanceFactor.getText());
    9191        return false;
    9292    }
Note: See TracChangeset for help on using the changeset viewer.