Ignore:
Timestamp:
2008-12-23T15:07:05+01:00 (15 years ago)
Author:
stoecker
Message:

removed usage of tab stops

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinNodeWayAction.java

    r1084 r1169  
    2626
    2727public class JoinNodeWayAction extends JosmAction {
    28         public JoinNodeWayAction() {
    29             super(tr("Join node to way"), "joinnodeway", tr("Join a node into the nearest way segments"),
    30                         Shortcut.registerShortcut("tools:joinnodeway", tr("Tool: {0}", tr("Join node to way")), KeyEvent.VK_J, Shortcut.GROUP_EDIT), true);
    31         }
     28    public JoinNodeWayAction() {
     29        super(tr("Join node to way"), "joinnodeway", tr("Join a node into the nearest way segments"),
     30            Shortcut.registerShortcut("tools:joinnodeway", tr("Tool: {0}", tr("Join node to way")), KeyEvent.VK_J, Shortcut.GROUP_EDIT), true);
     31    }
    3232
    33         public void actionPerformed(ActionEvent e) {
    34                 Collection<OsmPrimitive> sel = Main.ds.getSelected();
    35                 if (sel.size() != 1 || !(sel.iterator().next() instanceof Node)) return;
    36                 Node node = (Node) sel.iterator().next();
     33    public void actionPerformed(ActionEvent e) {
     34        Collection<OsmPrimitive> sel = Main.ds.getSelected();
     35        if (sel.size() != 1 || !(sel.iterator().next() instanceof Node)) return;
     36        Node node = (Node) sel.iterator().next();
    3737
    38                 List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(
    39                         Main.map.mapView.getPoint(node.eastNorth));
    40                 HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>();
    41                 for (WaySegment ws : wss) {
    42                         List<Integer> is;
    43                         if (insertPoints.containsKey(ws.way)) {
    44                                 is = insertPoints.get(ws.way);
    45                         } else {
    46                                 is = new ArrayList<Integer>();
    47                                 insertPoints.put(ws.way, is);
    48                         }
     38        List<WaySegment> wss = Main.map.mapView.getNearestWaySegments(
     39            Main.map.mapView.getPoint(node.eastNorth));
     40        HashMap<Way, List<Integer>> insertPoints = new HashMap<Way, List<Integer>>();
     41        for (WaySegment ws : wss) {
     42            List<Integer> is;
     43            if (insertPoints.containsKey(ws.way)) {
     44                is = insertPoints.get(ws.way);
     45            } else {
     46                is = new ArrayList<Integer>();
     47                insertPoints.put(ws.way, is);
     48            }
    4949
    50                         if (ws.way.nodes.get(ws.lowerIndex) != node
    51                                         && ws.way.nodes.get(ws.lowerIndex+1) != node) {
    52                                 is.add(ws.lowerIndex);
    53                         }
    54                 }
     50            if (ws.way.nodes.get(ws.lowerIndex) != node
     51                    && ws.way.nodes.get(ws.lowerIndex+1) != node) {
     52                is.add(ws.lowerIndex);
     53            }
     54        }
    5555
    56                 Collection<Command> cmds = new LinkedList<Command>();
    57                 for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) {
    58                         Way w = insertPoint.getKey();
    59                         Way wnew = new Way(w);
    60                         List<Integer> is = insertPoint.getValue();
    61                         pruneSuccsAndReverse(is);
    62                         for (int i : is) wnew.nodes.add(i+1, node);
    63                         cmds.add(new ChangeCommand(w, wnew));
    64                 }
     56        Collection<Command> cmds = new LinkedList<Command>();
     57        for (Map.Entry<Way, List<Integer>> insertPoint : insertPoints.entrySet()) {
     58            Way w = insertPoint.getKey();
     59            Way wnew = new Way(w);
     60            List<Integer> is = insertPoint.getValue();
     61            pruneSuccsAndReverse(is);
     62            for (int i : is) wnew.nodes.add(i+1, node);
     63            cmds.add(new ChangeCommand(w, wnew));
     64        }
    6565
    66                 Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds));
    67                 Main.map.repaint();
    68         }
     66        Main.main.undoRedo.add(new SequenceCommand(tr("Join Node and Line"), cmds));
     67        Main.map.repaint();
     68    }
    6969
    70         private static void pruneSuccsAndReverse(List<Integer> is) {
    71                 //if (is.size() < 2) return;
     70    private static void pruneSuccsAndReverse(List<Integer> is) {
     71        //if (is.size() < 2) return;
    7272
    73                 HashSet<Integer> is2 = new HashSet<Integer>();
    74                 for (int i : is) {
    75                         if (!is2.contains(i - 1) && !is2.contains(i + 1)) {
    76                                 is2.add(i);
    77                         }
    78                 }
    79                 is.clear();
    80                 is.addAll(is2);
    81                 Collections.sort(is);
    82                 Collections.reverse(is);
    83         }
     73        HashSet<Integer> is2 = new HashSet<Integer>();
     74        for (int i : is) {
     75            if (!is2.contains(i - 1) && !is2.contains(i + 1)) {
     76                is2.add(i);
     77            }
     78        }
     79        is.clear();
     80        is.addAll(is2);
     81        Collections.sort(is);
     82        Collections.reverse(is);
     83    }
    8484}
Note: See TracChangeset for help on using the changeset viewer.