Changeset 34556 in osm
- Timestamp:
- 2018-08-18T20:16:45+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/simplifyarea
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/simplifyarea/build.xml
r33918 r34556 4 4 <property name="commit.message" value="Initial commit"/> 5 5 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 6 <property name="plugin.main.version" value="1 2643"/>6 <property name="plugin.main.version" value="14153"/> 7 7 8 8 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaAction.java
r33918 r34556 21 21 import javax.swing.JOptionPane; 22 22 23 import org.openstreetmap.josm.Main;24 23 import org.openstreetmap.josm.actions.JosmAction; 25 24 import org.openstreetmap.josm.command.ChangeCommand; … … 29 28 import org.openstreetmap.josm.command.SequenceCommand; 30 29 import org.openstreetmap.josm.data.Bounds; 30 import org.openstreetmap.josm.data.UndoRedoHandler; 31 31 import org.openstreetmap.josm.data.coor.LatLon; 32 32 import org.openstreetmap.josm.data.osm.Node; … … 35 35 import org.openstreetmap.josm.data.osm.Way; 36 36 import org.openstreetmap.josm.gui.HelpAwareOptionPane; 37 import org.openstreetmap.josm.gui.HelpAwareOptionPane.ButtonSpec; 37 38 import org.openstreetmap.josm.gui.MainApplication; 38 import org.openstreetmap.josm. gui.HelpAwareOptionPane.ButtonSpec;39 import org.openstreetmap.josm.spi.preferences.Config; 39 40 import org.openstreetmap.josm.tools.ImageProvider; 40 41 import org.openstreetmap.josm.tools.Shortcut; … … 65 66 new ButtonSpec(tr("No, abort"), ImageProvider.get("cancel"), tr("Cancel operation"), null) }; 66 67 return 0 == HelpAwareOptionPane.showOptionDialog( 67 Main .parent,68 MainApplication.getMainFrame(), 68 69 "<html>" + trn("The selected way has nodes outside of the downloaded data region.", "The selected ways have nodes outside of the downloaded data region.", 69 70 MainApplication.getLayerManager().getEditDataSet().getSelectedWays().size()) … … 74 75 75 76 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); 77 78 } 78 79 … … 80 81 final ButtonSpec[] options = new ButtonSpec[] { new ButtonSpec(tr("Yes"), ImageProvider.get("ok"), tr("Simplify all selected ways"), null), 81 82 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), 83 84 tr("Simplify ways?"), 84 85 JOptionPane.WARNING_MESSAGE, null, // no special icon … … 174 175 if (!allCommands.isEmpty()) { 175 176 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); 177 178 MainApplication.getMap().repaint(); 178 179 } … … 198 199 // average nearby nodes 199 200 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); 201 202 202 203 final Map<Node, LatLon> coordMap = new HashMap<>(); … … 321 322 322 323 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); 329 330 330 331 final List<Node> nodes = w.getNodes(); -
applications/editors/josm/plugins/simplifyarea/src/sk/zdila/josm/plugin/simplify/SimplifyAreaPreferenceSetting.java
r30688 r34556 9 9 import javax.swing.JTextField; 10 10 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.gui.preferences.DefaultTabPreferenceSetting; 13 12 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; 14 13 import org.openstreetmap.josm.gui.widgets.JosmTextField; 14 import org.openstreetmap.josm.spi.preferences.Config; 15 15 import org.openstreetmap.josm.tools.GBC; 16 16 … … 49 49 final JPanel tab = gui.createPreferenceTab(this); 50 50 51 angleThreshold.setText( Main.pref.get(ANGLE_THRESHOLD, "10"));51 angleThreshold.setText(Config.getPref().get(ANGLE_THRESHOLD, "10")); 52 52 tab.add(new JLabel(tr("Angle Threshold")), GBC.std()); 53 53 tab.add(angleThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 54 54 55 angleFactor.setText( Main.pref.get(ANGLE_FACTOR, "1.0"));55 angleFactor.setText(Config.getPref().get(ANGLE_FACTOR, "1.0")); 56 56 tab.add(new JLabel(tr("Angle Factor")), GBC.std()); 57 57 tab.add(angleFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 58 58 59 areaThreshold.setText( Main.pref.get(AREA_THRESHOLD, "5.0"));59 areaThreshold.setText(Config.getPref().get(AREA_THRESHOLD, "5.0")); 60 60 tab.add(new JLabel(tr("Area Threshold")), GBC.std()); 61 61 tab.add(areaThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 62 62 63 areaFactor.setText( Main.pref.get(AREA_FACTOR, "1.0"));63 areaFactor.setText(Config.getPref().get(AREA_FACTOR, "1.0")); 64 64 tab.add(new JLabel(tr("Area Factor")), GBC.std()); 65 65 tab.add(areaFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 66 66 67 distanceThreshold.setText( Main.pref.get(DIST_THRESHOLD, "3"));67 distanceThreshold.setText(Config.getPref().get(DIST_THRESHOLD, "3")); 68 68 tab.add(new JLabel(tr("Distance Threshold")), GBC.std()); 69 69 tab.add(distanceThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 70 70 71 distanceFactor.setText( Main.pref.get(DIST_FACTOR, "3"));71 distanceFactor.setText(Config.getPref().get(DIST_FACTOR, "3")); 72 72 tab.add(new JLabel(tr("Distance Factor")), GBC.std()); 73 73 tab.add(distanceFactor, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); 74 74 75 mergeThreshold.setText( Main.pref.get(MERGE_THRESHOLD, "0.2"));75 mergeThreshold.setText(Config.getPref().get(MERGE_THRESHOLD, "0.2")); 76 76 tab.add(new JLabel(tr("Merge Nearby Nodes Threshold")), GBC.std()); 77 77 tab.add(mergeThreshold, GBC.eol().fill(GBC.HORIZONTAL).insets(5,0,0,5)); … … 82 82 @Override 83 83 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()); 91 91 return false; 92 92 }
Note:
See TracChangeset
for help on using the changeset viewer.