Author: clopes
Date: 2011-09-27 14:14:11 -0700 (Tue, 27 Sep 2011)
New Revision: 26991
Added:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/HandleDragCommand.as
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/ApplicationFacade.as
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
Log:
Added dragstart/dragstop events
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/ApplicationFacade.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/ApplicationFacade.as
2011-09-27 20:47:40 UTC (rev 26990)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/ApplicationFacade.as
2011-09-27 21:14:11 UTC (rev 26991)
@@ -106,6 +106,9 @@
public static const ROLLOUT_EVENT:String = "rollout_event";
public static const ACTIVATE_EVENT:String = "activate_event";
public static const DEACTIVATE_EVENT:String = "deactivate_event";
+ public static const DRAG_START_EVENT:String = "drag_start_event";
+ public static const DRAG_EVENT:String = "drag_event";
+ public static const DRAG_STOP_EVENT:String = "drag_stop_event";
public static const GRAPH_DRAWN:String = "graph_drawn";
public static const GRAPH_DATA_CHANGED:String = "graph_data_changed";
@@ -152,6 +155,9 @@
registerCommand(ROLLOUT_EVENT, HandleHoverCommand);
registerCommand(CLICK_EVENT, HandleClickCommand);
registerCommand(DOUBLE_CLICK_EVENT, HandleClickCommand);
+ registerCommand(DRAG_START_EVENT, HandleDragCommand);
+ registerCommand(DRAG_EVENT, HandleDragCommand);
+ registerCommand(DRAG_STOP_EVENT, HandleDragCommand);
registerCommand(SELECT, SelectCommand);
registerCommand(SELECT_ALL, SelectAllCommand);
registerCommand(DESELECT, DeselectCommand);
Added:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/HandleDragCommand.as
===================================================================
---
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/HandleDragCommand.as
(rev 0)
+++
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/controller/HandleDragCommand.as
2011-09-27 21:14:11 UTC (rev 26991)
@@ -0,0 +1,74 @@
+/*
+ This file is part of Cytoscape Web.
+ Copyright (c) 2009, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Agilent Technologies
+ - Institut Pasteur
+ - Institute for Systems Biology
+ - Memorial Sloan-Kettering Cancer Center
+ - National Center for Integrative Biomedical Informatics
+ - Unilever
+ - University of California San Diego
+ - University of California San Francisco
+ - University of Toronto
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+package org.cytoscapeweb.controller {
+ import flare.vis.data.DataSprite;
+
+ import org.cytoscapeweb.ApplicationFacade;
+ import org.cytoscapeweb.model.converters.ExternalObjectConverter;
+ import org.cytoscapeweb.util.ExternalFunctions;
+ import org.cytoscapeweb.util.Groups;
+ import org.puremvc.as3.interfaces.INotification;
+
+
+ /**
+ * Take the necessary actions after a drag event has started or sttoped.
+ * The target node must be sent as the target of the notification body.
+ */
+ public class HandleDragCommand extends BaseSimpleCommand {
+
+ override public function execute(notification:INotification):void {
+ var body:Object = notification.getBody();
+ var ds:DataSprite;
+
+ if (body != null) {
+ ds = body.target as DataSprite;
+ }
+
+ var action:String = notification.getName();
+ var group:String = Groups.groupOf(ds);
+
+ var type:String = "drag";
+ if (action === ApplicationFacade.DRAG_START_EVENT) type =
"dragstart";
+ else if (action === ApplicationFacade.DRAG_STOP_EVENT) type =
"dragstop";
+ trace(type);
+ // Call external listener:
+ if (extMediator.hasListener(type, group)) {
+ var target:Object = ExternalObjectConverter.toExtElement(ds,
graphProxy.zoom);
+
+ body = { functionName: ExternalFunctions.INVOKE_LISTENERS,
+ argument: { type: type,
+ group: group,
+ target: target } };
+
+ sendNotification(ApplicationFacade.CALL_EXTERNAL_INTERFACE,
body);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified:
cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
===================================================================
--- cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
2011-09-27 20:47:40 UTC (rev 26990)
+++ cytoscapeweb/trunk/cytoscapeweb/src/org/cytoscapeweb/view/GraphMediator.as
2011-09-27 21:14:11 UTC (rev 26991)
@@ -90,7 +90,7 @@
if (_dragControl == null) {
_dragControl = new EventDragControl(NodeSprite);
_dragControl.addEventListener(DragEvent.START,
onDragNodeStart);
- _dragControl.addEventListener(DragEvent.STOP,
onDragNodeEnd);
+ _dragControl.addEventListener(DragEvent.STOP,
onDragNodeStop);
_dragControl.addEventListener(DragEvent.DRAG, onDragNode);
}
@@ -639,10 +639,12 @@
_draggingNode = true;
updateCursor();
}
+
evt.node.removeEventListener(MouseEvent.CLICK, onClickNode);
+ sendNotification(ApplicationFacade.DRAG_START_EVENT, { target:
evt.node });
}
- private function onDragNodeEnd(evt:DragEvent):void { trace("== END
Drag Node");
+ private function onDragNodeStop(evt:DragEvent):void { trace("== STOP
Drag Node");
if (_draggingComponent) vis.hideDragRectangle();
_draggingNode = false;
_draggingComponent = false;
@@ -653,6 +655,8 @@
if (evt.node.hasEventListener(MouseEvent.MOUSE_UP)) {
evt.node.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_UP));
}
+
+ sendNotification(ApplicationFacade.DRAG_STOP_EVENT, { target:
evt.node });
}
private function onDragNode(evt:DragEvent):void {
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.