cytoscape.editor.event
Class BasicNetworkEditEventHandler

java.lang.Object
  extended bycytoscape.editor.event.NetworkEditEventAdapter
      extended bycytoscape.editor.event.BasicNetworkEditEventHandler
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, cytoscape.data.attr.MultiHashMapListener, phoebe.PhoebeCanvasDropListener
Direct Known Subclasses:
PaletteNetworkEditEventHandler

public class BasicNetworkEditEventHandler
extends NetworkEditEventAdapter
implements java.awt.event.ActionListener, cytoscape.data.attr.MultiHashMapListener

The BasicNetworkEditEventHandler class provides specialized methods defining the behavior of the basic Cytoscape editor provided in Cytoscape 2.2. The behavior is defined in terms of how the event handler responds to mouse events, drag/drop events, and button press events.

Version:
1.0
Author:
Allan Kuchinsky
See Also:
revised: 04/15/2006 to integrate with Cytoscape 2.3 renderer Phase 1: switch underlying node identification and edge drawing code Phase 2: remove dependencies upon Piccolo

Field Summary
static java.lang.String DEFAULT_EDGE
           
static java.lang.String DEFAULT_NODE
           
static java.lang.String EDGE_TYPE
          CytoscapeAttribute: EDGE_TYPE
 boolean handlingEdgeDrop
          flag that indicates whether we are currently in the process of handling a dropped edge TODO: handling dropped edges should probably be moved to the PaletteNetworkEditEventHandler
static java.lang.String NODE_TYPE
          CytoscapeAttribute: NODE_TYPE
 
Constructor Summary
BasicNetworkEditEventHandler()
           
BasicNetworkEditEventHandler(CytoscapeEditor caller)
           
BasicNetworkEditEventHandler(CytoscapeEditor caller, cytoscape.view.CyNetworkView view)
           
 
Method Summary
 void allAttributeValuesRemoved(java.lang.String objectKey, java.lang.String attributeName)
           
 void attributeValueAssigned(java.lang.String objectKey, java.lang.String attributeName, java.lang.Object[] keyIntoValue, java.lang.Object oldAttributeValue, java.lang.Object newAttributeValue)
          MultiHashMapListener methods
 void attributeValueRemoved(java.lang.String objectKey, java.lang.String attributeName, java.lang.Object[] keyIntoValue, java.lang.Object attributeValue)
           
 void beginEdge(java.awt.geom.Point2D location, giny.view.NodeView nv)
          begin drawing an edge from the input point
 cytoscape.CyNode createNode(java.awt.geom.Point2D location)
          create a new node at the point where mouse was pressed
 cytoscape.CyEdge finishEdge(java.awt.geom.Point2D location, giny.view.NodeView target)
          finish edge on node containing input pointf
 CytoscapeEditor get_caller()
           
 ding.view.InnerCanvas getCanvas()
           
 java.lang.String getEdgeAttributeName()
           
 java.lang.String getEdgeAttributeValue()
           
 java.awt.geom.Point2D getNextPoint()
           
 giny.view.NodeView getNode()
           
 java.lang.String getNodeAttributeName()
           
 java.lang.String getNodeAttributeValue()
           
 java.awt.geom.Point2D getStartPoint()
           
 ding.view.DGraphView getView()
           
 boolean isEdgeStarted()
           
 boolean isHandlingEdgeDrop()
           
 void keyTyped(java.awt.event.KeyEvent e)
          processed keyTypedEvents, in particular use of ESC key to interupt edge drawing
 void mouseDragged(java.awt.event.MouseEvent e)
          begin or continue drawing an edge as mouse is dragged
 void mouseEntered(java.awt.event.MouseEvent e)
          if hovering over a node, then highlight the node by temporarily inverting its selection
 void mouseExited(java.awt.event.MouseEvent e)
          revert temporary node highlighting that was done upon MouseEnter
 void mouseMoved(java.awt.event.MouseEvent e)
          updates rendering of edge if an edge is under construction
 void mousePressed(java.awt.event.MouseEvent e)
          The mousePressed() method is at the heart of the basic Cytoscape editor.
 void set_caller(CytoscapeEditor _caller)
           
 void setEdgeAttributeName(java.lang.String edgeAttributeName)
           
 void setEdgeAttributeValue(java.lang.String edgeAttributeValue)
           
 void setEdgeStarted(boolean edgeStarted)
          set the flag that indicates whether an edge is under construction
 void setHandlingEdgeDrop(boolean handlingEdgeDrop)
           
 void setNextPoint(java.awt.geom.Point2D nextPoint)
           
 void setNode(giny.view.NodeView node)
           
 void setNodeAttributeName(java.lang.String nodeAttributeName)
           
 void setNodeAttributeValue(java.lang.String nodeAttributeValue)
           
 void setStartPoint(java.awt.geom.Point2D startPoint)
           
 void setView(ding.view.DGraphView view)
           
 void start(ding.view.DGraphView view)
          starts up the event handler on the input network view adds an input event listener to the view's canvas
 void stop()
          stops the event handler by removing the input event listener from the canvas this is called when the user switches between editors
 void updateEdge()
          updates the rubberbanded edge line as the mouse is moved, works in Canvas coordinates
 
Methods inherited from class cytoscape.editor.event.NetworkEditEventAdapter
actionPerformed, itemDropped, keyPressed, keyReleased, mouseClicked, mouseReleased
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.awt.event.ActionListener
actionPerformed
 

Field Detail

NODE_TYPE

public static final java.lang.String NODE_TYPE
CytoscapeAttribute: NODE_TYPE

See Also:
Constant Field Values

EDGE_TYPE

public static final java.lang.String EDGE_TYPE
CytoscapeAttribute: EDGE_TYPE

See Also:
Constant Field Values

DEFAULT_NODE

public static final java.lang.String DEFAULT_NODE
See Also:
Constant Field Values

DEFAULT_EDGE

public static final java.lang.String DEFAULT_EDGE
See Also:
Constant Field Values

handlingEdgeDrop

public boolean handlingEdgeDrop
flag that indicates whether we are currently in the process of handling a dropped edge TODO: handling dropped edges should probably be moved to the PaletteNetworkEditEventHandler

Constructor Detail

BasicNetworkEditEventHandler

public BasicNetworkEditEventHandler()

BasicNetworkEditEventHandler

public BasicNetworkEditEventHandler(CytoscapeEditor caller)
Parameters:
caller -

BasicNetworkEditEventHandler

public BasicNetworkEditEventHandler(CytoscapeEditor caller,
                                    cytoscape.view.CyNetworkView view)
Parameters:
caller -
view -
Method Detail

getCanvas

public ding.view.InnerCanvas getCanvas()
Overrides:
getCanvas in class NetworkEditEventAdapter
Returns:
the current canvas

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
The mousePressed() method is at the heart of the basic Cytoscape editor.

Control-clicking at a position on the canvas creates a node with default label in that position.

Control-clicking on a node on the canvas starts an edge with source at that node. Move the cursor and a rubber-banded line follows the cursor. As the cursor passes over another node, that node is highlighted and the rubber-banded line will snap to a connection point on that second node. Control-click the mouse again and the connection is established.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class NetworkEditEventAdapter
Parameters:
e - inputEvent for mouse pressed
See Also:
BasicCytoscapeEditor

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
processed keyTypedEvents, in particular use of ESC key to interupt edge drawing

Specified by:
keyTyped in interface java.awt.event.KeyListener
Overrides:
keyTyped in class NetworkEditEventAdapter

beginEdge

public void beginEdge(java.awt.geom.Point2D location,
                      giny.view.NodeView nv)
begin drawing an edge from the input point

Parameters:
location - works in Canvas coordinates

finishEdge

public cytoscape.CyEdge finishEdge(java.awt.geom.Point2D location,
                                   giny.view.NodeView target)
finish edge on node containing input pointf

Parameters:
location - works in Canvas coordinates

createNode

public cytoscape.CyNode createNode(java.awt.geom.Point2D location)
create a new node at the point where mouse was pressed

Parameters:
location - point of mouse press (in Canvas coordinates)

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
updates rendering of edge if an edge is under construction

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Overrides:
mouseMoved in class NetworkEditEventAdapter

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
if hovering over a node, then highlight the node by temporarily inverting its selection

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class NetworkEditEventAdapter

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
revert temporary node highlighting that was done upon MouseEnter

Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class NetworkEditEventAdapter

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
begin or continue drawing an edge as mouse is dragged

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Overrides:
mouseDragged in class NetworkEditEventAdapter

updateEdge

public void updateEdge()
updates the rubberbanded edge line as the mouse is moved, works in Canvas coordinates

Overrides:
updateEdge in class NetworkEditEventAdapter

attributeValueAssigned

public void attributeValueAssigned(java.lang.String objectKey,
                                   java.lang.String attributeName,
                                   java.lang.Object[] keyIntoValue,
                                   java.lang.Object oldAttributeValue,
                                   java.lang.Object newAttributeValue)
MultiHashMapListener methods

Specified by:
attributeValueAssigned in interface cytoscape.data.attr.MultiHashMapListener
Overrides:
attributeValueAssigned in class NetworkEditEventAdapter

attributeValueRemoved

public void attributeValueRemoved(java.lang.String objectKey,
                                  java.lang.String attributeName,
                                  java.lang.Object[] keyIntoValue,
                                  java.lang.Object attributeValue)
Specified by:
attributeValueRemoved in interface cytoscape.data.attr.MultiHashMapListener
Overrides:
attributeValueRemoved in class NetworkEditEventAdapter

allAttributeValuesRemoved

public void allAttributeValuesRemoved(java.lang.String objectKey,
                                      java.lang.String attributeName)
Specified by:
allAttributeValuesRemoved in interface cytoscape.data.attr.MultiHashMapListener
Overrides:
allAttributeValuesRemoved in class NetworkEditEventAdapter

isEdgeStarted

public boolean isEdgeStarted()
Returns:
flag indicating whether an edge is under construction

setEdgeStarted

public void setEdgeStarted(boolean edgeStarted)
set the flag that indicates whether an edge is under construction

Parameters:
edgeStarted -

getNextPoint

public java.awt.geom.Point2D getNextPoint()
Returns:
Returns the nextPoint.

setNextPoint

public void setNextPoint(java.awt.geom.Point2D nextPoint)
Parameters:
nextPoint - The nextPoint to set

getNode

public giny.view.NodeView getNode()
Returns:
Returns the node.

setNode

public void setNode(giny.view.NodeView node)
Parameters:
node - The node to set.

getStartPoint

public java.awt.geom.Point2D getStartPoint()
Returns:
Returns the startPoint.

setStartPoint

public void setStartPoint(java.awt.geom.Point2D startPoint)
Parameters:
startPoint - The startPoint to set.

getView

public ding.view.DGraphView getView()
Overrides:
getView in class NetworkEditEventAdapter
Returns:
Returns the view.

setView

public void setView(ding.view.DGraphView view)
Overrides:
setView in class NetworkEditEventAdapter
Parameters:
view - The view to set.

isHandlingEdgeDrop

public boolean isHandlingEdgeDrop()
Returns:
Returns the flag that indicates whether we are handling the drop of an edge onto the canvas TODO: move edge drop handling into PaletteNetworkEditEventHandler

setHandlingEdgeDrop

public void setHandlingEdgeDrop(boolean handlingEdgeDrop)
Parameters:
handlingEdgeDrop - sets the flag that indicates whether we are handling the drop of an edge onto the canvas

start

public void start(ding.view.DGraphView view)
starts up the event handler on the input network view adds an input event listener to the view's canvas

Overrides:
start in class NetworkEditEventAdapter
Parameters:
view - a Cytoscape network view

stop

public void stop()
stops the event handler by removing the input event listener from the canvas this is called when the user switches between editors

Overrides:
stop in class NetworkEditEventAdapter

getEdgeAttributeValue

public java.lang.String getEdgeAttributeValue()
Returns:
Returns the edgeAttributeValue.

setEdgeAttributeValue

public void setEdgeAttributeValue(java.lang.String edgeAttributeValue)
Parameters:
edgeAttributeValue - The edgeAttributeValue to set.

getNodeAttributeName

public java.lang.String getNodeAttributeName()
Returns:
Returns the nodeAttributeName.

setNodeAttributeName

public void setNodeAttributeName(java.lang.String nodeAttributeName)
Parameters:
nodeAttributeName - The nodeAttributeName to set.

getEdgeAttributeName

public java.lang.String getEdgeAttributeName()
Returns:
Returns the edgeAttributeName.

setEdgeAttributeName

public void setEdgeAttributeName(java.lang.String edgeAttributeName)
Parameters:
edgeAttributeName - The edgeAttributeName to set.

getNodeAttributeValue

public java.lang.String getNodeAttributeValue()
Returns:
Returns the nodeAttributeValue.

setNodeAttributeValue

public void setNodeAttributeValue(java.lang.String nodeAttributeValue)
Parameters:
nodeAttributeValue - The nodeAttributeValue to set.

get_caller

public CytoscapeEditor get_caller()
Overrides:
get_caller in class NetworkEditEventAdapter
Returns:
Returns the _caller.

set_caller

public void set_caller(CytoscapeEditor _caller)
Overrides:
set_caller in class NetworkEditEventAdapter
Parameters:
_caller - The _caller to set.