cytoscape.editor.editors
Class BasicCytoscapeEditor

java.lang.Object
  extended bycytoscape.editor.editors.BasicCytoscapeEditor
All Implemented Interfaces:
CytoscapeEditor, ding.view.EdgeContextMenuListener, java.util.EventListener, cytoscape.data.FlagEventListener, ding.view.NodeContextMenuListener
Direct Known Subclasses:
DefaultCytoscapeEditor, SimpleBioMoleculeEditor, SimpleBioPAX_Editor

public class BasicCytoscapeEditor
extends java.lang.Object
implements CytoscapeEditor, cytoscape.data.FlagEventListener, ding.view.NodeContextMenuListener, ding.view.EdgeContextMenuListener

The BasicCytoscapeEditor provides base level graph editing functionality for Cytoscape, in particular the base level methods for adding nodes, edges, and context menu items.

Provides an "Edit => Connect Selected Nodes" menu item that, when chosen, creates a clique amongst the selected nodes.

Provides accelerators for modeless addition of nodes and edges. Control-clicking at a position on the canvas creates a node with default label in that position. The default label appears in an editable text field, so the user can edit its name immediately by just beginning to type. Hit ENTER or click (or control-click) anywhere outside the field, and the edited field is assigned as the label for the node. 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.

Provides functionality for deleting selected nodes and edges and an undo/redo framework for deletion of nodes and edges

Version:
1.0
Author:
Allan Kuchinsky, Agilent Technologies
See Also:
BasicNetworkEditEventHandler

Field Summary
static java.lang.String BIOPAX_NAME_ATTRIBUTE
          Cytoscape Attribute: BioPAX Name.
 
Constructor Summary
BasicCytoscapeEditor()
           
 
Method Summary
 cytoscape.CyEdge addEdge(giny.model.Node node_1, giny.model.Node node_2, java.lang.String attribute, java.lang.Object attribute_value)
          wrapper for adding an edge in Cytoscape.
 cytoscape.CyEdge addEdge(giny.model.Node node_1, giny.model.Node node_2, java.lang.String attribute, java.lang.Object attribute_value, boolean create)
          wrapper for adding an edge in Cytoscape.
 cytoscape.CyEdge addEdge(giny.model.Node node_1, giny.model.Node node_2, java.lang.String attribute, java.lang.Object attribute_value, boolean create, java.lang.String edgeType)
          wrapper for adding an edge in Cytoscape.
 cytoscape.CyEdge addEdge(giny.model.Node node_1, giny.model.Node node_2, java.lang.String attribute, java.lang.Object attribute_value, java.lang.String edgeType)
          wrapper for adding an edge in Cytoscape.
 void addEdgeContextMenuItems(giny.view.EdgeView edgeView, javax.swing.JPopupMenu menu)
           
 cytoscape.CyNode addNode(java.lang.String nodeName)
          wrapper for adding a node in Cytoscape.
 cytoscape.CyNode addNode(java.lang.String nodeName, java.lang.String nodeType)
          wrapper for adding a node in Cytoscape.
 cytoscape.CyNode addNode(java.lang.String nodeName, java.lang.String attribute, java.lang.String value)
          wrapper for adding a node in Cytoscape.
 cytoscape.CyNode addNode(java.lang.String nodeName, java.lang.String attribute, java.lang.String value, java.awt.geom.Point2D location)
          wrapper for adding a node in Cytoscape.
 void addNodeContextMenuItems(giny.view.NodeView nodeView, javax.swing.JPopupMenu menu)
           
 void buildVisualStyle()
          build the visualStyle for this editor this code should be overidden by more specialized editors that programmatically create a visual style
 void deleteEdge(cytoscape.CyEdge edge)
          Deletes (hides) an edge from the current network
 void deleteNode(giny.model.Node node)
          Deletes (hides) a node from the current network
 void disableControls(java.util.List args)
          sets controls invisible when editor type is switched
 void enableControls(java.util.List args)
          sets controls visible when editor type is switched back to this editor
 java.lang.String getControllingEdgeAttribute()
           
 java.lang.String getControllingNodeAttribute()
           
 java.lang.String getEditorName()
          gets the name (type) of this editor
 NetworkEditEventAdapter getNetworkEditEventAdapter()
           
 void initializeControls(java.util.List args)
          specialized initialization code for editor, called by CytoscapeEditorManager when a new editor is built, should be overridden
 boolean menuItemExists(javax.swing.JPopupMenu menu, java.lang.String label)
           
 void onFlagEvent(cytoscape.data.FlagEvent e)
          respond to flagging of a Node.
 void setControllingEdgeAttribute(java.lang.String controllingEdgeAttribute)
           
 void setControllingNodeAttribute(java.lang.String controllingNodeAttribute)
           
 void setEditorName(java.lang.String editorName)
          sets the name (type) for this editor
 void setNetworkEditEventAdapter(NetworkEditEventAdapter adapter)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIOPAX_NAME_ATTRIBUTE

public static final java.lang.String BIOPAX_NAME_ATTRIBUTE
Cytoscape Attribute: BioPAX Name.

See Also:
Constant Field Values
Constructor Detail

BasicCytoscapeEditor

public BasicCytoscapeEditor()
Method Detail

addNode

public cytoscape.CyNode addNode(java.lang.String nodeName,
                                java.lang.String attribute,
                                java.lang.String value,
                                java.awt.geom.Point2D location)
wrapper for adding a node in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor. this method will ensure that the node added is unique. If it finds that there is an existing node for nodeName, it will attempt to generate a new, unique, nodeName by extending the nodeName argument with a randomly generated extension.

Specified by:
addNode in interface CytoscapeEditor
Parameters:
nodeName - the name of the node to be created. This will be used as a unique identifier for the node.
attribute - a defining property for the node, that can be used in conjunction with the Visual Mapper to assign visual characteristics to different types of nodes. Also can be used, by the canvas when handling a dropped item, to distinguish between nodes and edges, so should be set to something like "NodeType".
value - the value of the attribute for this node. This can be used in conjunction with the Visual Mapper to assign visual characteristics to different types of nodes, for example to assign a violet diamond shape to a 'smallMolecule' node type.
location - the position at which to add the node
Returns:
the CyNode that has been either reused or created.

onFlagEvent

public void onFlagEvent(cytoscape.data.FlagEvent e)
respond to flagging of a Node. Does nothing right now.

Specified by:
onFlagEvent in interface cytoscape.data.FlagEventListener

addNodeContextMenuItems

public void addNodeContextMenuItems(giny.view.NodeView nodeView,
                                    javax.swing.JPopupMenu menu)
Specified by:
addNodeContextMenuItems in interface ding.view.NodeContextMenuListener

menuItemExists

public boolean menuItemExists(javax.swing.JPopupMenu menu,
                              java.lang.String label)

addEdgeContextMenuItems

public void addEdgeContextMenuItems(giny.view.EdgeView edgeView,
                                    javax.swing.JPopupMenu menu)
Specified by:
addEdgeContextMenuItems in interface ding.view.EdgeContextMenuListener

addNode

public cytoscape.CyNode addNode(java.lang.String nodeName,
                                java.lang.String attribute,
                                java.lang.String value)
wrapper for adding a node in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor. this method will ensure that the node added is unique. If it finds that there is an existing node for nodeName, it will attempt to generate a new, unique, nodeName by extending the nodeName argument with a randomly generated extension.

Specified by:
addNode in interface CytoscapeEditor
Parameters:
nodeName - the name of the node to be created. This will be used as a unique identifier for the node.
attribute - a defining property for the node, that can be used in conjunction with the Visual Mapper to assign visual characteristics to different types of nodes. Also can be used, by the canvas when handling a dropped item, to distinguish between nodes and edges, so should be set to something like "NodeType".
value - the value of the attribute for this node. This can be used in conjunction with the Visual Mapper to assign visual characteristics to different types of nodes, for example to assign a violet diamond shape to a 'smallMolecule' node type.
Returns:
the CyNode that has been either reused or created.

addNode

public cytoscape.CyNode addNode(java.lang.String nodeName,
                                java.lang.String nodeType)
wrapper for adding a node in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor.

Specified by:
addNode in interface CytoscapeEditor
Parameters:
nodeName - the name of the node to be created. This will be used as a unique identifier for the node.
nodeType - the value of the 'NodeType' attribute for this node. This can be used in conjunction with the Visual Mapper to assign visual characteristics to different types of nodes. Also can be used, by the canvas when handling, a dropped item, to distinguish between nodes and edges.
Returns:
the CyNode that has been either reused or created.

addNode

public cytoscape.CyNode addNode(java.lang.String nodeName)
wrapper for adding a node in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor. This form of addNode() will create a node in all cases, whether it previously exists or not.

Specified by:
addNode in interface CytoscapeEditor
Parameters:
nodeName - the name of the node to be created. This will be used as a unique identifier for the node.
Returns:
the CyNode that has been either reused or created.

addEdge

public cytoscape.CyEdge addEdge(giny.model.Node node_1,
                                giny.model.Node node_2,
                                java.lang.String attribute,
                                java.lang.Object attribute_value,
                                boolean create,
                                java.lang.String edgeType)
wrapper for adding an edge in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor.

Specified by:
addEdge in interface CytoscapeEditor
Parameters:
node_1 - Node at one end of the edge
node_2 - Node at the other end of the edge
attribute - the attribute of the edge to be searched, a common one is Semantics.INTERACTION
attribute_value - a value for the attribute, like "pp" or "default"
create - if true, then create an edge if one does not already exist. Otherwise, return the edge if it already exists.
edgeType - a value for the "EdgeType" attribute assigned to the edge. This can be used in conjunction with the Visual Mapper.
Returns:
the CyEdge that has either been reused or created

addEdge

public cytoscape.CyEdge addEdge(giny.model.Node node_1,
                                giny.model.Node node_2,
                                java.lang.String attribute,
                                java.lang.Object attribute_value)
wrapper for adding an edge in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor. This version always creates an edge, whether or not one already exists.

Specified by:
addEdge in interface CytoscapeEditor
Parameters:
node_1 - Node at one end of the edge
node_2 - Node at the other end of the edge
attribute - the attribute of the edge to be searched, a common one is Semantics.INTERACTION
attribute_value - a value for the attribute, like "pp" or "default"
Returns:
the CyEdge that has been created

addEdge

public cytoscape.CyEdge addEdge(giny.model.Node node_1,
                                giny.model.Node node_2,
                                java.lang.String attribute,
                                java.lang.Object attribute_value,
                                java.lang.String edgeType)
wrapper for adding an edge in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor. This version always creates an edge, whether or not one already exists.

Specified by:
addEdge in interface CytoscapeEditor
Parameters:
node_1 - Node at one end of the edge
node_2 - Node at the other end of the edge
attribute - the attribute of the edge to be searched, a common one is Semantics.INTERACTION
attribute_value - a value for the attribute, like "pp" or "default"
edgeType - a value for the "EdgeType" attribute assigned to the edge. This can be used in conjunction with the Visual Mapper.
Returns:
the CyEdge that has been created

addEdge

public cytoscape.CyEdge addEdge(giny.model.Node node_1,
                                giny.model.Node node_2,
                                java.lang.String attribute,
                                java.lang.Object attribute_value,
                                boolean create)
wrapper for adding an edge in Cytoscape. This is intended to be called by the CytoscapeEditor in lieu of making direct modifications to the Cytoscape model. Thus, it provides an insulating level of abstraction between the CytoscapeEditor and the Cytoscape implementation, allowing for portability and extensibility of the editor.

Specified by:
addEdge in interface CytoscapeEditor
Parameters:
node_1 - Node at one end of the edge
node_2 - Node at the other end of the edge
attribute - the attribute of the edge to be searched, a common one is Semantics.INTERACTION
attribute_value - a value for the attribute, like "pp" or "default"
create - if true, then create an edge if one does not already exist. Otherwise, return the edge if it already exists.
Returns:
the CyEdge that has either been reused or created

deleteNode

public void deleteNode(giny.model.Node node)
Deletes (hides) a node from the current network

Specified by:
deleteNode in interface CytoscapeEditor
Parameters:
node - the node to be deleted

deleteEdge

public void deleteEdge(cytoscape.CyEdge edge)
Deletes (hides) an edge from the current network

Specified by:
deleteEdge in interface CytoscapeEditor
Parameters:
edge - the edge to be deleted

buildVisualStyle

public void buildVisualStyle()
build the visualStyle for this editor this code should be overidden by more specialized editors that programmatically create a visual style

Specified by:
buildVisualStyle in interface CytoscapeEditor

initializeControls

public void initializeControls(java.util.List args)
specialized initialization code for editor, called by CytoscapeEditorManager when a new editor is built, should be overridden

Specified by:
initializeControls in interface CytoscapeEditor
Parameters:
args - an arbitrary list of arguments passed to initialization routine. Not used in this editor

disableControls

public void disableControls(java.util.List args)
sets controls invisible when editor type is switched

Specified by:
disableControls in interface CytoscapeEditor
Parameters:
args - args an arbitrary list of arguments (not used in this editor)

enableControls

public void enableControls(java.util.List args)
sets controls visible when editor type is switched back to this editor

Specified by:
enableControls in interface CytoscapeEditor
Parameters:
args - args an arbitrary list of arguments (not used in this editor) *

getEditorName

public java.lang.String getEditorName()
gets the name (type) of this editor

Specified by:
getEditorName in interface CytoscapeEditor
Returns:
the editorName.

setEditorName

public void setEditorName(java.lang.String editorName)
sets the name (type) for this editor

Specified by:
setEditorName in interface CytoscapeEditor
Parameters:
editorName - the editorName to set.

getControllingEdgeAttribute

public java.lang.String getControllingEdgeAttribute()
Specified by:
getControllingEdgeAttribute in interface CytoscapeEditor
Returns:
the name of the attribute used to determine edge shapes on palette this is the same as the controllingEdgeAttribute for mapping of visual style to edge line type, target arrow

setControllingEdgeAttribute

public void setControllingEdgeAttribute(java.lang.String controllingEdgeAttribute)
Specified by:
setControllingEdgeAttribute in interface CytoscapeEditor
Parameters:
controllingEdgeAttribute - the name of the attribute used to determine edge shapes on palette this is the same as the controllingEdgeAttribute for mapping of visual style to edge line type, target arrow

getControllingNodeAttribute

public java.lang.String getControllingNodeAttribute()
Specified by:
getControllingNodeAttribute in interface CytoscapeEditor
Returns:
the name of the attribute used to determine Node shapes on palette this is the same as the controllingNodeAttribute for mapping of visual style to Node shape and color

setControllingNodeAttribute

public void setControllingNodeAttribute(java.lang.String controllingNodeAttribute)
Specified by:
setControllingNodeAttribute in interface CytoscapeEditor
Parameters:
controllingNodeAttribute - the name of the attribute used to determine Node shapes on palette this is the same as the controllingNodeAttribute for mapping of visual style to Node shape and color

getNetworkEditEventAdapter

public NetworkEditEventAdapter getNetworkEditEventAdapter()
Specified by:
getNetworkEditEventAdapter in interface CytoscapeEditor
Returns:
the network event handler that is associated with this editor

setNetworkEditEventAdapter

public void setNetworkEditEventAdapter(NetworkEditEventAdapter adapter)
Specified by:
setNetworkEditEventAdapter in interface CytoscapeEditor
Parameters:
adapter - the network event handler that is associated with this editor