Changeset 31224 in osm for applications/editors/josm/plugins/FastDraw/src/org/openstreetmap
- Timestamp:
- 2015-06-06T18:54:58+02:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FDSettings.java
r29457 r31224 35 35 // option for simplifiction: 0="Autosimplify and wait", 36 36 //1="Simplify and wait", 2="Save as is" 37 38 public boolean allowEditExistingWays; 37 39 38 40 public boolean drawClosed; … … 73 75 drawClosed = Main.pref.getBoolean("fastdraw.drawclosed", false); 74 76 simplifyMode = Main.pref.getInteger("fastdraw.simplifymode", 0); 77 allowEditExistingWays = Main.pref.getBoolean("fastdraw.alloweditexisting", false); 78 75 79 autoTags = Main.pref.get("fastdraw.autotags"); 76 80 } … … 91 95 Main.pref.putInteger("fastdraw.simplifymode", simplifyMode); 92 96 Main.pref.put("fastdraw.autotags", autoTags); 97 Main.pref.put("fastdraw.alloweditexisting", allowEditExistingWays); 93 98 try {Main.pref.save();} catch (IOException e) { 94 99 System.err.println(tr("Can not save preferences")); -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawConfigDialog.java
r30710 r31224 41 41 private final JCheckBox fixedClickCb = new JCheckBox(tr("Add fixed points on click")); 42 42 private final JCheckBox fixedSpaceCb = new JCheckBox(tr("Add fixed points on spacebar")); 43 private final JCheckBox allowEditExistingWaysCb = new JCheckBox(tr("Allow edit existing ways")); 43 44 private final JCheckBox drawClosedCb = new JCheckBox(tr("Draw closed polygons only")); 44 45 private final HistoryComboBox addTags = new HistoryComboBox(); … … 87 88 all.add(drawClosedCb,GBC.eop().insets(20,0,0,0)); 88 89 90 all.add(allowEditExistingWaysCb,GBC.eop().insets(20,0,0,0)); 91 89 92 addTags.setText(settings.autoTags); 90 93 text1.setValue(settings.epsilonMult); … … 95 98 fixedSpaceCb.setSelected(settings.fixedSpacebar); 96 99 drawClosedCb.setSelected(settings.drawClosed); 100 allowEditExistingWaysCb.setSelected(settings.allowEditExistingWays); 97 101 combo1.setSelectedIndex(settings.simplifyMode); 98 102 … … 110 114 public ExtendedDialog showDialog() { 111 115 ExtendedDialog result = super.showDialog(); 112 if (getValue() == 0) {116 if (getValue() == 1) { 113 117 try { 114 118 settings.epsilonMult=NumberFormat.getInstance().parse(text1.getText()).doubleValue(); … … 118 122 settings.fixedClick=fixedClickCb.isSelected(); 119 123 settings.fixedSpacebar=fixedSpaceCb.isSelected(); 124 settings.allowEditExistingWays=allowEditExistingWaysCb.isSelected(); 120 125 settings.drawClosed=drawClosedCb.isSelected(); 121 126 settings.simplifyMode=combo1.getSelectedIndex(); -
applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java
r30710 r31224 15 15 import java.util.ArrayList; 16 16 import java.util.Collection; 17 import java.util.Collections; 17 18 import java.util.HashSet; 18 19 import java.util.Iterator; … … 27 28 import org.openstreetmap.josm.actions.mapmode.MapMode; 28 29 import org.openstreetmap.josm.command.AddCommand; 30 import org.openstreetmap.josm.command.ChangeCommand; 29 31 import org.openstreetmap.josm.command.Command; 30 32 import org.openstreetmap.josm.command.DeleteCommand; … … 73 75 private int nearestPointIndex; 74 76 private int dragNode=-1; 75 private SequenceCommand delCmd;76 77 private List<Node> oldNodes; 77 78 78 79 private boolean lineWasSaved; 79 80 private boolean deltaChanged; 81 private Way oldWay; 80 82 81 83 FastDrawingMode(MapFrame mapFrame) { … … 511 513 // <editor-fold defaultstate="collapsed" desc="Different action helper methods"> 512 514 public void newDrawing() { 513 if (delCmd!=null) delCmd.undoCommand(); 514 delCmd=null; oldNodes=null; 515 oldWay=null; oldNodes=null; 515 516 eps=settings.startingEps; 516 517 line.clear(); … … 526 527 Collection<Command> cmds = new LinkedList<>(); 527 528 int i = 0; 528 Way w = new Way(); 529 530 Way w; 531 if (oldWay==null) { 532 w = new Way(); 533 } else { 534 w = new Way(oldWay); 535 w.setNodes(new ArrayList<Node>()); // nodes will be created frosm scratch 536 } 537 529 538 LatLon first=pts.get(0); 530 539 Node firstNode=null; … … 570 579 } 571 580 } 572 if ( delCmd!=null) {581 if (oldWay!=null) { 573 582 List<Node> nodes = w.getNodes(); 583 cmds.add(new ChangeCommand(oldWay, w)); 574 584 for (Node nd: oldNodes) { 575 585 // node from old way but not in new way … … 577 587 List<OsmPrimitive> refs = nd.getReferrers(); 578 588 // does someone need this node? if no-delete it. 579 if (refs. isEmpty()&& !nd.isDeleted() && nd.isUsable()) cmds.add(new DeleteCommand(nd));589 if (refs.size()==1 && !nd.isDeleted() && nd.isUsable() && !nd.isTagged()) cmds.add(new DeleteCommand(nd)); 580 590 } 581 591 } 582 delCmd = null; // that is all with this command 583 cmds.add(new AddCommand(w)); 592 oldWay = null; // that is all with this command 584 593 } else cmds.add(new AddCommand(w)); 585 594 Command c = new SequenceCommand(tr("Draw the way by mouse"), cmds); … … 638 647 639 648 private void loadFromWay(Way w) { 640 Collection<Command> cmds = new LinkedList<>();641 649 642 650 Object[] nodes = w.getNodes().toArray(); … … 645 653 for (int i=0;i<n;i++) { 646 654 Node nd=(Node) nodes[i]; 647 line.addLast(nd.getCoor()); 655 List<OsmPrimitive> refs = nd.getReferrers(); 656 if (refs.size()>1 || nd.isTagged()) { 657 line.addFixed(nd.getCoor()); 658 } else { 659 line.addLast(nd.getCoor()); 660 } 648 661 } 649 662 if (w.isClosed()) line.closeLine(); 650 663 oldNodes = w.getNodes(); 651 List <OsmPrimitive> wl = new ArrayList<>(); wl.add(w); 652 653 Command c = DeleteCommand.delete(getEditLayer(), wl, false); 654 if (c != null) cmds.add(c); 655 delCmd = new SequenceCommand(tr("Convert way to FastDraw line"), cmds); 656 Main.main.undoRedo.add(delCmd); 664 oldWay = w; 657 665 } 658 666 … … 690 698 Way w = selectedWays.iterator().next(); 691 699 692 if (w.isNew()) loadFromWay(w); 700 if (w.isNew() || settings.allowEditExistingWays) loadFromWay(w); 693 701 } 694 702 }
Note:
See TracChangeset
for help on using the changeset viewer.