Work in progress
authorRichard Fairhurst <richard@systemeD.net>
Sat, 21 May 2011 12:53:46 +0000 (13:53 +0100)
committerRichard Fairhurst <richard@systemeD.net>
Sat, 21 May 2011 12:53:46 +0000 (13:53 +0100)
13 files changed:
REFACTOR.txt
net/systemeD/halcyon/Elastic.as
net/systemeD/halcyon/Map.as
net/systemeD/potlatch2/controller/ControllerState.as
net/systemeD/potlatch2/controller/DragSelection.as
net/systemeD/potlatch2/controller/DragWayNode.as
net/systemeD/potlatch2/controller/DrawWay.as
net/systemeD/potlatch2/controller/SelectedMarker.as
net/systemeD/potlatch2/controller/SelectedMultiple.as
net/systemeD/potlatch2/controller/SelectedPOINode.as
net/systemeD/potlatch2/controller/SelectedParallelWay.as
net/systemeD/potlatch2/controller/SelectedWay.as
net/systemeD/potlatch2/controller/SelectedWayNode.as

index 7746a86..5334bde 100644 (file)
@@ -25,6 +25,7 @@ VectorLayer.as changes:
 - move into Connection
 
 Global changes:
+- move lots of connection.map to connection.map.editableLayer
 - remove all references to getConnection etc. - there can now be more than one Connection
 - remove all back-references to Map except where necessary for lat/long/scale
 - Controllers are full of references to controller.map and to controller.connection
index f0daa9d..fdb521e 100644 (file)
@@ -17,14 +17,16 @@ package net.systemeD.halcyon {
 
                public var map:Map;                                                     // reference to parent map
                public var sprites:Array=new Array();           // instances in display list
+               private var editableLayer:MapPaint;
         private var _start:Point;
         private var _end:Point;
 
                /** Create and draw the elastic. */
                public function Elastic(map:Map, start:Point, end:Point) {
                        this.map = map;
-                       this._start = start;
-                       this._end = end;
+                       editableLayer = map.editableLayer;
+                       \7f_start = start;
+                       _end = end;
                        redraw();
                }
                
@@ -62,7 +64,7 @@ package net.systemeD.halcyon {
                        var stroke:Shape = new Shape();
             stroke.graphics.lineStyle(1, 0xff0000, 1, false, "normal", CapsStyle.ROUND, JointStyle.ROUND);
 
-                       var l:DisplayObject=map.paint.getPaintSpriteAt(map.paint.maxlayer);
+                       var l:DisplayObject=editableLayer.getPaintSpriteAt(editableLayer.maxlayer);
                        var o:DisplayObject=Sprite(l).getChildAt(3);    // names layer
                        (o as Sprite).addChild(stroke);
                        sprites.push(stroke);
index 5024b23..d400117 100644 (file)
@@ -186,7 +186,6 @@ package net.systemeD.halcyon {
             if (lat> edge_t || lat < edge_b || lon < edge_l || lon > edge_r) {
                 moveMapFromLatLon(lat, lon);
             }
-
                }
 
                // Co-ordinate conversion functions
@@ -228,20 +227,10 @@ package net.systemeD.halcyon {
         */
                public function download():void {
                        this.dispatchEvent(new MapEvent(MapEvent.DOWNLOAD, {minlon:edge_l, maxlon:edge_r, maxlat:edge_t, minlat:edge_b} ));
-                       for (var i:uint=0; i<paintContainer.numChildren; i++) {
+                       for (var i:uint=0; i<paintContainer.numChildren; i++)
                                paintContainer.getChildAt(i).connection.loadBbox(edge_l,edge_r,edge_t,edge_b);
-                       }
                }
 
-               // >>>> REFACTOR: moved to MapPaint:
-        // public function setHighlight(entity:Entity, settings:Object):void {
-        // public function setHighlightOnNodes(way:Way, settings:Object):void {
-               // public function protectWay(way:Way):void {
-               // public function unprotectWay(way:Way):void {
-               // public function limitWayDrawing(way:Way,except:Number=NaN,only:Number=NaN):void {
-               // public function setPurgable(entities:Array, purgable:Boolean):void {
-
-
         // Handle mouse events on ways/nodes
         private var mapController:MapController = null;
 
@@ -270,11 +259,10 @@ package net.systemeD.halcyon {
                }
 
                public function removeLayerByName(name:String):void {
-                       for (var i:uint=0; i<paintContainer.numChildren; i++)
-                               if (paintContainer.getChildAt(i).connection.name==name) {
+                       for (var i:uint=0; i<paintContainer.numChildren; i++) {
+                               if (paintContainer.getChildAt(i).connection.name==name)
                                        paintContainer.removeChildAt(i);
                                        // >>>> REFACTOR: needs to do the equivalent of VectorLayer.blank()
-                               }
                        }
                }
                
@@ -283,6 +271,19 @@ package net.systemeD.halcyon {
                                if (paintContainer.getChildAt(i).connection.name==name) return paintContainer.getChildAt(i);
                        return null;
                }
+               
+               /* Find which layer is editable */
+               public function get editableLayer():MapPaint {
+                       var editableLayer:MapPaint;
+                       for (var i:uint=0; i<paintContainer.numChildren; i++) {
+                               layer=paintContainer.getChildAt(i);
+                               if (!layer.isBackground) {
+                                       if (editableLayer) trace("Multiple editable layers found");
+                                       editableLayer=layer;
+                               }
+                       }
+                       return editableLayer;
+               }
 
                // ------------------------------------------------------------------------------------------
                // Redraw all items, zoom in and out
index 94e60aa..4788e7f 100644 (file)
@@ -19,6 +19,7 @@ package net.systemeD.potlatch2.controller {
     public class ControllerState {
 
         protected var controller:EditController;
+               protected var editableLayer:MapPaint;
         protected var previousState:ControllerState;
 
                protected var _selection:Array=[];
@@ -27,6 +28,7 @@ package net.systemeD.potlatch2.controller {
 
         public function setController(controller:EditController):void {
             this.controller = controller;
+                       editableLayer = controller.map.editableLayer;
         }
 
         public function setPreviousState(previousState:ControllerState):void {
@@ -64,7 +66,7 @@ package net.systemeD.potlatch2.controller {
                        switch (event.keyCode) {
                                case 66:        setSourceTag(); break;                                                                                                  // B - set source tag for current object
                                case 67:        controller.connection.closeChangeset(); break;                                                  // C - close changeset
-                               case 68:        controller.map.paint.alpha=1.3-controller.map.paint.alpha; return null; // D - dim
+                               case 68:        editableLayer.alpha=1.3-editableLayer.alpha; return null;                               // D - dim
                                case 83:        SaveManager.saveChanges(); break;                                                                               // S - save
                                case 84:        controller.tagViewer.togglePanel(); return null;                                                // T - toggle tags panel
                                case 90:        if (!event.shiftKey) { MainUndoStack.getGlobalStack().undo(); return null;}// Z - undo
@@ -125,9 +127,9 @@ package net.systemeD.potlatch2.controller {
                        } else if ( event.type == MouseEvent.MOUSE_UP && focus && map.dragstate!=map.NOT_DRAGGING) {
                                map.mouseUpHandler();   // in case the end-drag is over an EntityUI
                        } else if ( event.type == MouseEvent.ROLL_OVER ) {
-                               controller.map.setHighlight(focus, { hover: true });
+                               editableLayer.setHighlight(focus, { hover: true });
                        } else if ( event.type == MouseEvent.MOUSE_OUT ) {
-                               controller.map.setHighlight(focus, { hover: false });
+                               editableLayer.setHighlight(focus, { hover: false });
             } else if ( event.type == MouseEvent.MOUSE_WHEEL ) {
                 if (event.delta > 0) {
                   map.zoomIn();
index e17299a..739180e 100644 (file)
@@ -95,14 +95,14 @@ package net.systemeD.potlatch2.controller {
         /** Highlight the dragged selection. */
         override public function enterState():void {
                        for each (var entity:Entity in selection) {
-                               controller.map.setHighlight(entity, { selected: true });
+                               editableLayer.setHighlight(entity, { selected: true });
                        }
         }
         
         /** Un-highlight the dragged selection. */
         override public function exitState(newState:ControllerState):void {
                        for each (var entity:Entity in selection) {
-                               controller.map.setHighlight(entity, { selected: false });
+                               editableLayer.setHighlight(entity, { selected: false });
                        }
         }
         /** "DragSelection" */
index 8342154..f53a717 100644 (file)
@@ -35,7 +35,7 @@ package net.systemeD.potlatch2.controller {
         private function addNode(selectedWay:Way,event:MouseEvent):int {
                        // find which other ways are under the mouse
                        var ways:Array=[]; var w:Way;
-                       for each (var wayui:WayUI in controller.map.paint.wayuis) {
+                       for each (var wayui:WayUI in editableLayer.wayuis) {
                                w=wayui.hitTest(event.stageX, event.stageY);
                                if (w && w!=selectedWay) { ways.push(w); }
                        }
@@ -115,17 +115,17 @@ package net.systemeD.potlatch2.controller {
                        originalLat = draggingNode.lat;
                        originalLon = draggingNode.lon;
 
-                       controller.map.setHighlightOnNodes(parentWay, { selectedway: true } );
-                       controller.map.limitWayDrawing(parentWay, draggingIndex);
-                       controller.map.setHighlight(draggingNode, { selected: true } );
-                       controller.map.protectWay(parentWay);
-                       controller.map.limitWayDrawing(parentWay, NaN, draggingIndex);
+                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: true } );
+                       editableLayer.limitWayDrawing(parentWay, draggingIndex);
+                       editableLayer.setHighlight(draggingNode, { selected: true } );
+                       editableLayer.protectWay(parentWay);
+                       editableLayer.limitWayDrawing(parentWay, NaN, draggingIndex);
         }
         override public function exitState(newState:ControllerState):void {
-                       controller.map.unprotectWay(parentWay);
-                       controller.map.limitWayDrawing(parentWay);
-                       controller.map.setHighlightOnNodes(parentWay, { selectedway: false } );
-                       controller.map.setHighlight(draggingNode, { selected: false } );
+                       editableLayer.unprotectWay(parentWay);
+                       editableLayer.limitWayDrawing(parentWay);
+                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: false } );
+                       editableLayer.setHighlight(draggingNode, { selected: false } );
         }
         override public function toString():String {
             return "DragWayNode";
index 71d9872..21aef75 100644 (file)
@@ -43,8 +43,8 @@ package net.systemeD.potlatch2.controller {
                 controller.map.mouseUpHandler(); // in case you're still in the drag-tolerance zone, and mouse up over something.
                                if ( entity == null || isBackground ) { // didn't hit anything: extend the way by one node.
                                        node = createAndAddNode(event, MainUndoStack.getGlobalStack().addAction);
-                    controller.map.setHighlight(node, { selectedway: true });
-                    controller.map.setPurgable([node], false);
+                    editableLayer.setHighlight(node, { selectedway: true });
+                    editableLayer.setPurgable([node], false);
                                        resetElastic(node);
                                        lastClick=node;
                                        controller.updateSelectionUIWithoutTagChange();
@@ -75,9 +75,9 @@ package net.systemeD.potlatch2.controller {
                                                // hit a node, add it to this way and carry on
                                                appendNode(entity as Node, MainUndoStack.getGlobalStack().addAction);
                                                if (focus is Way) {
-                          controller.map.setHighlightOnNodes(focus as Way, { hoverway: false });
+                          editableLayer.setHighlightOnNodes(focus as Way, { hoverway: false });
                         }
-                                               controller.map.setHighlight(entity, { selectedway: true });
+                                               editableLayer.setHighlight(entity, { selectedway: true });
                                                resetElastic(entity as Node);
                                                lastClick=entity;
                                                if (Way(firstSelected).getNode(0)==Way(firstSelected).getLastNode()) {
@@ -101,13 +101,13 @@ package net.systemeD.potlatch2.controller {
                         node = createAndAddNode(event, jnct.push);
                         Way(entity).insertNodeAtClosestPosition(node, true, jnct.push);
                         MainUndoStack.getGlobalStack().addAction(jnct);
-                        controller.map.setHighlight(node, { selectedway: true });
-                        controller.map.setPurgable([node], false);
+                        editableLayer.setHighlight(node, { selectedway: true });
+                        editableLayer.setPurgable([node], false);
                                        }
                                        resetElastic(node);
                                        lastClick=node;
-                                       controller.map.setHighlightOnNodes(entity as Way, { hoverway: false });
-                                       controller.map.setHighlightOnNodes(firstSelected as Way, { selectedway: true });
+                                       editableLayer.setHighlightOnNodes(entity as Way, { hoverway: false });
+                                       editableLayer.setHighlightOnNodes(firstSelected as Way, { selectedway: true });
                                }
                                lastClickTime=new Date();
                        } else if ( event.type == MouseEvent.MOUSE_MOVE && elastic ) {
@@ -121,7 +121,7 @@ package net.systemeD.potlatch2.controller {
                                if (focus is Way && focus!=firstSelected) {
                                        // floating over another way, highlight its nodes
                                        hoverEntity=focus;
-                                       controller.map.setHighlightOnNodes(focus as Way, { hoverway: true });
+                                       editableLayer.setHighlightOnNodes(focus as Way, { hoverway: true });
                                }
                                // set cursor depending on whether we're floating over the start of this way, 
                                // another random node, a possible junction...
@@ -136,7 +136,7 @@ package net.systemeD.potlatch2.controller {
                        } else if ( event.type == MouseEvent.MOUSE_OUT && !isBackground ) {
                                if (focus is Way && entity!=firstSelected) {
                                        hoverEntity=null;
-                                       controller.map.setHighlightOnNodes(focus as Way, { hoverway: false });
+                                       editableLayer.setHighlightOnNodes(focus as Way, { hoverway: false });
                                        // ** We could do with an optional way of calling WayUI.redraw to only do the nodes, which would be a
                                        // useful optimisation.
                                }
@@ -194,7 +194,7 @@ package net.systemeD.potlatch2.controller {
                
                protected function stopDrawing():ControllerState {
                        if ( hoverEntity ) {
-                               controller.map.setHighlightOnNodes(hoverEntity as Way, { hoverway: false });
+                               editableLayer.setHighlightOnNodes(hoverEntity as Way, { hoverway: false });
                                hoverEntity = null;
                        }
 
@@ -243,7 +243,7 @@ package net.systemeD.potlatch2.controller {
                        }
                        // Only actually delete the node if it has no other tags, and is not part of other ways (or part of this way twice)
                        if (node.numParentWays==1 && Way(firstSelected).hasOnceOnly(node) && !node.hasInterestingTags()) {
-                               controller.map.setPurgable([node], true);
+                               editableLayer.setPurgable([node], true);
                                controller.connection.unregisterPOI(node);
                                node.remove(undo.push);
                        }
@@ -260,7 +260,7 @@ package net.systemeD.potlatch2.controller {
             performAction(undo);
 
             if(!node.isDeleted()) { // i.e. was junction with another way (or is now POI)
-              controller.map.setHighlight(node, {selectedway: false});
+              editableLayer.setHighlight(node, {selectedway: false});
             }
             return state;
                }
@@ -309,7 +309,7 @@ package net.systemeD.potlatch2.controller {
                        appendNode(nextNode as Node, MainUndoStack.getGlobalStack().addAction);
                        resetElastic(nextNode as Node);
                        lastClick=nextNode;
-                       controller.map.setHighlight(nextNode, { selectedway: true });
+                       editableLayer.setHighlight(nextNode, { selectedway: true });
 
                        // recentre the map if the new lat/lon is offscreen
                        controller.map.scrollIfNeeded(nextNode.lat,nextNode.lon);
index a6164ee..34e46e3 100644 (file)
@@ -19,7 +19,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            controller.map.setHighlight(marker, { selected: true });
+            editableLayer.setHighlight(marker, { selected: true });
             selection = [marker];
             controller.updateSelectionUI(layer);
             initMarker = marker;
@@ -27,7 +27,7 @@ package net.systemeD.potlatch2.controller {
 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                controller.map.setHighlight(firstSelected, { selected: false });
+                editableLayer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -53,11 +53,11 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectMarker(initMarker);
-                       controller.map.setPurgable(selection,false);
+                       editableLayer.setPurgable(selection,false);
         }
 
         override public function exitState(newState:ControllerState):void {
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index b7c4f0b..2601577 100644 (file)
@@ -19,7 +19,7 @@ package net.systemeD.potlatch2.controller {
 
                        if ( event.type == MouseEvent.MOUSE_DOWN && entity && event.ctrlKey ) {
                                // modify selection
-                               controller.map.setHighlight(entity, { selected: toggleSelection(entity) });
+                               editableLayer.setHighlight(entity, { selected: toggleSelection(entity) });
                                controller.updateSelectionUI();
 
                                if (selectCount>1) { return this; }
@@ -110,16 +110,16 @@ package net.systemeD.potlatch2.controller {
                override public function enterState():void {
                        selection=initSelection.concat();
                        for each (var entity:Entity in selection) {
-                               controller.map.setHighlight(entity, { selected: true, hover: false });
+                               editableLayer.setHighlight(entity, { selected: true, hover: false });
                        }
                        controller.updateSelectionUI();
-                       controller.map.setPurgable(selection,false);
+                       editableLayer.setPurgable(selection,false);
                }
 
                override public function exitState(newState:ControllerState):void {
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
                        for each (var entity:Entity in selection) {
-                               controller.map.setHighlight(entity, { selected: false, hover: false });
+                               editableLayer.setHighlight(entity, { selected: false, hover: false });
                        }
                        selection = [];
                        if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
index 178f2b0..278759d 100644 (file)
@@ -16,7 +16,7 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            controller.map.setHighlight(node, { selected: true });
+            editableLayer.setHighlight(node, { selected: true });
             selection = [node];
             controller.updateSelectionUI();
             initNode = node;
@@ -24,7 +24,7 @@ package net.systemeD.potlatch2.controller {
                 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-                controller.map.setHighlight(firstSelected, { selected: false });
+                editableLayer.setHighlight(firstSelected, { selected: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -60,13 +60,13 @@ package net.systemeD.potlatch2.controller {
 
         override public function enterState():void {
             selectNode(initNode);
-                       controller.map.setPurgable(selection,false);
+                       editableLayer.setPurgable(selection,false);
         }
         override public function exitState(newState:ControllerState):void {
             if(firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
index 94ff889..1324af1 100644 (file)
@@ -76,7 +76,7 @@ package net.systemeD.potlatch2.controller {
                /** Creates the WayUI for the parallel way. */
                override public function enterState():void {
                        selection=[parallelise.parallelWay];
-                       controller.map.paint.createWayUI(firstSelected as Way);
+                       editableLayer.createWayUI(firstSelected as Way);
                        startlon =controller.map.coord2lon(controller.map.mouseX);
                        startlatp=controller.map.coord2latp(controller.map.mouseY);
         }
index b3aadd8..50f02ed 100644 (file)
@@ -34,8 +34,8 @@ package net.systemeD.potlatch2.controller {
         /** Tidy up UI as we transition to a new state without the current selection. */
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-               controller.map.setHighlight(firstSelected, { selected: false, hover: false });
-               controller.map.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
+               editableLayer.setHighlight(firstSelected, { selected: false, hover: false });
+               editableLayer.setHighlightOnNodes(firstSelected as Way, { selectedway: false });
                 selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -70,7 +70,7 @@ package net.systemeD.potlatch2.controller {
                                case 81:  /* Q */           Quadrilateralise.quadrilateralise(firstSelected as Way, MainUndoStack.getGlobalStack().addAction); return this;
                                case 82:  /* R */           repeatTags(firstSelected); return this;
                 case 86:  /* V */           Way(firstSelected).reverseNodes(MainUndoStack.getGlobalStack().addAction); return this;
-                case 89:  /* Y */           Simplify.simplify(firstSelected as Way, controller.map, true); return this;         
+                case 89:  /* Y */           Simplify.simplify(firstSelected as Way, controller.map, true); return this;
                                case 191: /* / */           return cycleWays();
                                case Keyboard.BACKSPACE:        
                                case Keyboard.DELETE:           if (event.shiftKey) { return deleteWay(); } break;
@@ -87,7 +87,7 @@ package net.systemeD.potlatch2.controller {
 
                        if (!wayList) {
                                wayList=[initWay];
-                               for each (var wayui:WayUI in controller.map.paint.wayuis) {
+                               for each (var wayui:WayUI in editableLayer.wayuis) {
                                        var w:Way=wayui.hitTest(clicked.x, clicked.y);
                                        if (w && w!=initWay) { wayList.push(w); }
                                }
@@ -100,7 +100,7 @@ package net.systemeD.potlatch2.controller {
 
                /** Perform deletion of currently selected way. */
                public function deleteWay():ControllerState {
-                       controller.map.setHighlightOnNodes(firstSelected as Way, {selectedway: false});
+                       editableLayer.setHighlightOnNodes(firstSelected as Way, {selectedway: false});
                        selectedWay.remove(MainUndoStack.getGlobalStack().addAction);
                        return new NoSelection();
                }
@@ -109,13 +109,13 @@ package net.systemeD.potlatch2.controller {
         override public function enterState():void {
             if (firstSelected!=initWay) {
                    clearSelection(this);
-                   controller.map.setHighlight(initWay, { selected: true, hover: false });
-                   controller.map.setHighlightOnNodes(initWay, { selectedway: true });
+                   editableLayer.setHighlight(initWay, { selected: true, hover: false });
+                   editableLayer.setHighlightOnNodes(initWay, { selectedway: true });
                    selection = [initWay];
                    controller.updateSelectionUI();
                    initWay.addEventListener(Connection.WAY_REORDERED, updateSelectionUI, false, 0, true);
                        }
-                       controller.map.setPurgable(selection,false);
+                       editableLayer.setPurgable(selection,false);
         }
         /** Officially leave the state, remembering the current way's tags for future repeats. */
         // TODO: tweak this so that repeat tags aren't remembered if you only select a way in order to branch off it. (a la PL1) 
@@ -123,7 +123,7 @@ package net.systemeD.potlatch2.controller {
                        if (firstSelected.hasTags()) {
               controller.clipboards['way']=firstSelected.getTagsCopy();
             }
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
             firstSelected.removeEventListener(Connection.WAY_REORDERED, updateSelectionUI);
             clearSelection(newState);
         }
index 24e7d22..5bb16b0 100644 (file)
@@ -25,9 +25,9 @@ package net.systemeD.potlatch2.controller {
                 return;
 
             clearSelection(this);
-            controller.map.setHighlight(way, { hover: false });
-            controller.map.setHighlight(node, { selected: true });
-            controller.map.setHighlightOnNodes(way, { selectedway: true });
+            editableLayer.setHighlight(way, { hover: false });
+            editableLayer.setHighlight(node, { selected: true });
+            editableLayer.setHighlightOnNodes(way, { selectedway: true });
             selection = [node]; parentWay = way;
             controller.updateSelectionUI();
                        selectedIndex = index; initIndex = index;
@@ -35,9 +35,9 @@ package net.systemeD.potlatch2.controller {
                 
         protected function clearSelection(newState:ControllerState):void {
             if ( selectCount ) {
-               controller.map.setHighlight(parentWay, { selected: false });
-                               controller.map.setHighlight(firstSelected, { selected: false });
-                               controller.map.setHighlightOnNodes(parentWay, { selectedway: false });
+               editableLayer.setHighlight(parentWay, { selected: false });
+                               editableLayer.setHighlight(firstSelected, { selected: false });
+                               editableLayer.setHighlightOnNodes(parentWay, { selectedway: false });
                                selection = [];
                 if (!newState.isSelectionState()) { controller.updateSelectionUI(); }
             }
@@ -106,13 +106,13 @@ package net.systemeD.potlatch2.controller {
 
                override public function enterState():void {
             selectNode(parentWay,initIndex);
-                       controller.map.setPurgable(selection,false);
+                       editableLayer.setPurgable(selection,false);
         }
                override public function exitState(newState:ControllerState):void {
             if (firstSelected.hasTags()) {
               controller.clipboards['node']=firstSelected.getTagsCopy();
             }
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
             clearSelection(newState);
         }
 
@@ -146,8 +146,8 @@ package net.systemeD.potlatch2.controller {
                            if (parentWay.getLastNode() == n) { return this; }
                        }
 
-                       controller.map.setHighlightOnNodes(parentWay, { selectedway: false } );
-                       controller.map.setPurgable([parentWay],true);
+                       editableLayer.setHighlightOnNodes(parentWay, { selectedway: false } );
+                       editableLayer.setPurgable([parentWay],true);
             MainUndoStack.getGlobalStack().addAction(new SplitWayAction(parentWay, ni));
 
                        return new SelectedWay(parentWay);
@@ -162,7 +162,7 @@ package net.systemeD.potlatch2.controller {
                }
                
                public function deleteNode():ControllerState {
-                       controller.map.setPurgable(selection,true);
+                       editableLayer.setPurgable(selection,true);
                        firstSelected.remove(MainUndoStack.getGlobalStack().addAction);
                        return new SelectedWay(parentWay);
                }
@@ -175,8 +175,8 @@ package net.systemeD.potlatch2.controller {
         /** Attempt to either merge the currently selected node with another very nearby node, or failing that,
         *   attach it mid-way along a very nearby way. */
         public function join():ControllerState {
-            var p:Point = new Point(controller.map.lon2coord(Node(firstSelected).lon),
-                                             controller.map.latp2coord(Node(firstSelected).latp));
+                       var p:Point = new Point(controller.map.lon2coord(Node(firstSelected).lon),
+                                               controller.map.latp2coord(Node(firstSelected).latp));
             var q:Point = map.localToGlobal(p);
 
             // First, look for POI nodes in 20x20 pixel box around the current node
@@ -193,7 +193,7 @@ package net.systemeD.potlatch2.controller {
             }
             
             var ways:Array=[]; var w:Way;
-            for each (var wayui:WayUI in controller.map.paint.wayuis) {
+            for each (var wayui:WayUI in editableLayer.wayuis) {
                 w=wayui.hitTest(q.x, q.y);
                 if (w && w!=selectedWay) { 
                 // hit a way, now let's see if we hit a specific node