Ignore:
Timestamp:
2009-07-21T20:56:01+02:00 (15 years ago)
Author:
jttt
Message:

Make it work without Main.ds

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

Legend:

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

    r16162 r16626  
    2626                <attribute name="Plugin-Description" value="Make terraced houses out of single blocks."/>
    2727                <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/wiki/JOSM/Plugins/Terracer"/>
    28                 <attribute name="Plugin-Mainversion" value="1638"/>
     28                <attribute name="Plugin-Mainversion" value="1815"/>
    2929                <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
    3030            </manifest>
  • applications/editors/josm/plugins/terracer/src/terracer/ReverseTerraceAction.java

    r13990 r16626  
    2626 * in the wrong direction, or when someone has added house numbers in the wrong
    2727 * direction anyway.
    28  * 
     28 *
    2929 * Finds all connected ways which have a building=* tag on them in order (breadth
    3030 * first search) and then changes the tags to be the reverse of the order in which
     
    3434
    3535        public ReverseTerraceAction() {
    36                 super(tr("Reverse a terrace"), 
    37                                 "reverse_terrace", 
     36                super(tr("Reverse a terrace"),
     37                                "reverse_terrace",
    3838                                tr("Reverses house numbers on a terrace."),
    39                                 Shortcut.registerShortcut("tools:ReverseTerrace", 
     39                                Shortcut.registerShortcut("tools:ReverseTerrace",
    4040                                                tr("Tool: {0}", tr("Reverse a Terrace")),
    41                                                 KeyEvent.VK_R, Shortcut.GROUP_EDIT, 
     41                                                KeyEvent.VK_R, Shortcut.GROUP_EDIT,
    4242                                                Shortcut.SHIFT_DEFAULT),
    4343                                                true);
     
    5050         */
    5151        public void actionPerformed(ActionEvent e) {
    52                 Collection<OsmPrimitive> sel = Main.ds.getSelected();
    53                
     52                Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected();
     53
    5454                // set to keep track of all the nodes that have been visited - that is: if
    5555                // we encounter them again we will not follow onto the connected ways.
    5656                HashSet<Node> visitedNodes = new HashSet<Node>();
    57                
     57
    5858                // set to keep track of the ways the algorithm has seen, but not yet visited.
    5959                // since when a way is visited all of its nodes are marked as visited, there
     
    6161                HashSet<Way> front = new HashSet<Way>();
    6262
    63                 // initialise the set with all the buildings in the selection. this means 
     63                // initialise the set with all the buildings in the selection. this means
    6464                // there is undefined behaviour when there is a multiple selection, as the
    6565                // ordering will be based on the hash.
     
    6969                        }
    7070                }
    71                
     71
    7272                // this is like a visitedWays set, but in a linear order.
    7373                LinkedList<Way> orderedWays = new LinkedList<Way>();
    74                
     74
    7575                // and the tags to reverse on the orderedWays.
    7676                LinkedList<String> houseNumbers = new LinkedList<String>();
    77                
     77
    7878                while (front.size() > 0) {
    7979                        // Java apparently doesn't have useful methods to get single items from sets...
    8080                        Way w = front.iterator().next();
    81                        
     81
    8282                        // visit all the nodes in the way, adding the building's they're members of
    8383                        // to the front.
    8484                        for (Node n : w.nodes) {
    8585                                if (!visitedNodes.contains(n)) {
    86                                         CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.ds);
     86                                        CollectBackReferencesVisitor v = new CollectBackReferencesVisitor(Main.main.getCurrentDataSet());
    8787                                        v.visit(n);
    8888                                        for (OsmPrimitive prim : v.data) {
     
    101101                        houseNumbers.addFirst(w.get("addr:housenumber"));
    102102                }
    103                
     103
    104104                Collection<Command> commands = new LinkedList<Command>();
    105105                // what, no zipWith?
     
    112112
    113113                Main.main.undoRedo.add(new SequenceCommand(tr("Reverse Terrace"), commands));
    114                 Main.ds.setSelected(orderedWays);
     114                Main.main.getCurrentDataSet().setSelected(orderedWays);
    115115        }
    116116
  • applications/editors/josm/plugins/terracer/src/terracer/TerracerAction.java

    r16162 r16626  
    6363        // smsms1 asked for the last value to be remembered to make it easier to do
    6464        // repeated terraces. this is the easiest, but not necessarily nicest, way.
    65         private static String lastSelectedValue = "";
     65        //private static String lastSelectedValue = "";
    6666
    6767        public TerracerAction() {
     
    8181         */
    8282        public void actionPerformed(ActionEvent e) {
    83                 Collection<OsmPrimitive> sel = Main.ds.getSelected();
     83                Collection<OsmPrimitive> sel = Main.main.getCurrentDataSet().getSelected();
    8484                boolean badSelect = false;
    8585
     
    198198
    199199                Main.main.undoRedo.add(new SequenceCommand(tr("Terrace"), commands));
    200                 Main.ds.setSelected(ways);
     200                Main.main.getCurrentDataSet().setSelected(ways);
    201201        }
    202202
     
    516516        private TreeSet<String> createAutoCompletionInfo() {
    517517                final TreeSet<String> names = new TreeSet<String>();
    518                 for (OsmPrimitive osm : Main.ds.allNonDeletedPrimitives()) {
     518                for (OsmPrimitive osm : Main.main.getCurrentDataSet().allNonDeletedPrimitives()) {
    519519                        if (osm.keys != null &&
    520520                                        osm.keys.containsKey("highway") &&
Note: See TracChangeset for help on using the changeset viewer.