1 package net.systemeD.potlatch2.controller {
3 import net.systemeD.potlatch2.EditController;
4 import net.systemeD.halcyon.connection.*;
5 import net.systemeD.halcyon.Map;
6 import net.systemeD.halcyon.Globals;
8 public class NoSelection extends ControllerState {
10 public function NoSelection() {
13 override public function processMouseEvent(event:MouseEvent, entity:Entity):ControllerState {
14 var focus:Entity = getTopLevelFocusEntity(entity);
16 if ( event.type == MouseEvent.MOUSE_DOWN ) {
17 if ( entity is Way ) {
18 return new SelectedWay(focus as Way);
19 } else if ( focus is Node ) {
20 return new DragPOINode(entity as Node,event,false);
21 } else if ( entity is Node && focus is Way ) {
22 return new DragWayNode(focus as Way,entity as Node,event,false);
24 } else if (event.type==MouseEvent.MOUSE_UP && focus==null && map.dragstate!=map.DRAGGING) {
25 map.dragstate=map.NOT_DRAGGING;
26 var undo:CompositeUndoableAction = new CompositeUndoableAction("Begin way");
27 var startNode:Node = controller.connection.createNode(
29 controller.map.coord2lat(event.localY),
30 controller.map.coord2lon(event.localX), undo.push);
31 var way:Way = controller.connection.createWay({}, [startNode], undo.push);
32 MainUndoStack.getGlobalStack().addAction(undo);
33 return new DrawWay(way, true, false);
34 } else if ( event.type == MouseEvent.ROLL_OVER ) {
35 controller.map.setHighlight(focus, { hover: true });
36 } else if ( event.type == MouseEvent.MOUSE_OUT ) {
37 controller.map.setHighlight(focus, { hover: false });
38 } else if ( event.type == MouseEvent.MOUSE_DOWN ) {
43 public static function getTopLevelFocusEntity(entity:Entity):Entity {
44 if ( entity is Node ) {
45 for each (var parent:Entity in entity.parentWays) {
49 } else if ( entity is Way ) {
56 override public function enterState():void {
57 Globals.vars.root.addDebug("**** -> "+this);
59 override public function exitState():void {
60 Globals.vars.root.addDebug("**** <- "+this);
62 override public function toString():String {