org.globus.cog.gui.grapheditor.canvas
Class AbstractCanvas

java.lang.Object
  extended by org.globus.cog.gui.grapheditor.canvas.AbstractCanvas
All Implemented Interfaces:
ActionListener, PropertyChangeListener, EventListener, GraphCanvas, GraphComponentWrapperListener, EventConsumer, GraphListener
Direct Known Subclasses:
EchoCanvas, GenericCanvas, ProjectCanvas, TaskCanvas

public abstract class AbstractCanvas
extends Object
implements GraphCanvas, ActionListener, GraphComponentWrapperListener, EventConsumer, PropertyChangeListener, GraphListener


Constructor Summary
AbstractCanvas()
           
AbstractCanvas(NodeComponent owner)
           
 
Method Summary
 void actionPerformed(ActionEvent e)
           
 void addCanvasEventListener(CanvasEventListener listener)
          Adds a listener that can be used to receive various notification events about the state of the canvas
 void addComponent(GraphComponent c)
          Adds a graph component to the graph
 void addEdge(EdgeComponent ec)
          Adds an edge to this canvas
 void addEdge(EdgeComponent ec, NodeComponent from, NodeComponent to)
           
protected  void addEdge(EdgeComponent ec, Object fromId, Object toId)
           
 void addEdgeType(EdgeComponent edge)
          Adds an edge prototype to this canvas
 void addNode(NodeComponent nc)
          Adds a node to this canvas
 void addNodeType(NodeComponent node)
          Adds a prototype node to this canvas
 void addPropertyChangeListener(PropertyChangeListener l)
          Adds a property change listener to the listeners list.
 void addStatusEventListener(StatusEventListener listener)
           
 GraphComponent createComponent(String type)
          Allows the automatic creation of a graph component based on the requested type.
 EdgeComponent createEdge(String type)
          A specialized method for createComponent that only creates edges.
 NodeComponent createNode(String type)
          A specialized method for createComponent that only creates nodes.
 void event(EventObject e)
           
 void fireCanvasEvent(CanvasEvent e)
           
 void firePropertyChange(PropertyChangeEvent e)
          Fires a PropertyChangeEvent on behalf of this canvas
 void fireStatusEvent(StatusEvent e)
           
 GraphInterface getGraph()
           
 NodeComponent getOwner()
           
 StatusManager getStatusManager()
          Each canvas can have a status manager that can be used to represent various pieces of information pertaining to outcomes of various actions performed on the canvas or its descendants.
 List getSupportedEdges()
          This method is used to define the valid edge types that can appear within this canvas.
 List getSupportedNodes()
          This method is used to define the valid node types that can appear within this canvas.
 void graphChanged(GraphChangedEvent e)
           
 void graphComponentEvent(GraphComponentWrapperEvent e)
           
 void invalidate()
          Notifies the canvas about changes in its sub-components that may require the re-evaluation of the state of the canvas object, most notably a re-rendering of the canvas.
 CanvasRenderer newRenderer()
          Creates a new renderer for this canvas using the current target
 CanvasRenderer newRenderer(String target)
          Creates a new renderer for this canvas using the specified target
 void propertyChange(PropertyChangeEvent e)
           
 void removeCanvasEventListener(CanvasEventListener listener)
          Removes a previously added listener
 void removeComponent(GraphComponent c)
          Removes a component from the graph.
 void removeEdgeType(Class edge)
           
 void removeNodeType(Class node)
           
 void removePropertyChangeListener(PropertyChangeListener l)
          Removes a listener.
 void removeStatusEventListener(StatusEventListener listener)
           
protected  void setClassRendererClass(Class cls)
           
protected  void setClassRendererClass(Class cls, String target)
           
 void setEventsActive(boolean eventsActive)
           
 void setGraph(GraphInterface graph)
          sets the graph that is to be displayed/edited by this canvas
 void setInstanceRendererClass(Class cls)
           
 void setInstanceRendererClass(Class cls, String target)
           
 void setOwner(NodeComponent owner)
          Sets the value of the owner of this canvas
 void setPropagateEvents(boolean v)
          Determines whether node events are being propagated to the listeners for this canvas
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractCanvas

public AbstractCanvas(NodeComponent owner)

AbstractCanvas

public AbstractCanvas()
Method Detail

setInstanceRendererClass

public void setInstanceRendererClass(Class cls,
                                     String target)

setInstanceRendererClass

public void setInstanceRendererClass(Class cls)

setClassRendererClass

protected void setClassRendererClass(Class cls)

setClassRendererClass

protected void setClassRendererClass(Class cls,
                                     String target)

newRenderer

public CanvasRenderer newRenderer()
Description copied from interface: GraphCanvas
Creates a new renderer for this canvas using the current target

Specified by:
newRenderer in interface GraphCanvas

newRenderer

public CanvasRenderer newRenderer(String target)
Description copied from interface: GraphCanvas
Creates a new renderer for this canvas using the specified target

Specified by:
newRenderer in interface GraphCanvas

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener l)
Adds a property change listener to the listeners list. The listener will be notified of any property changes on this canvas. If propagateEvents is also set (@see setPropagateEvents) , the listener will also be notified of property changes for nodes contained in this canvas. If the listener was added previously, it will not be added again. In other words, at most one instance of a listener can be present in the listener list.

Parameters:
l - the listener to be added to the list

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener l)
Removes a listener.

Parameters:
l - the listener to be removed

firePropertyChange

public void firePropertyChange(PropertyChangeEvent e)
Fires a PropertyChangeEvent on behalf of this canvas

Parameters:
e - the event to be fired

propertyChange

public void propertyChange(PropertyChangeEvent e)
Specified by:
propertyChange in interface PropertyChangeListener

actionPerformed

public void actionPerformed(ActionEvent e)
Specified by:
actionPerformed in interface ActionListener

event

public void event(EventObject e)
Specified by:
event in interface EventConsumer

setGraph

public void setGraph(GraphInterface graph)
Description copied from interface: GraphCanvas
sets the graph that is to be displayed/edited by this canvas

Specified by:
setGraph in interface GraphCanvas

getGraph

public GraphInterface getGraph()
Specified by:
getGraph in interface GraphCanvas
Returns:
the graph of this canvas

createComponent

public GraphComponent createComponent(String type)
Description copied from interface: GraphCanvas
Allows the automatic creation of a graph component based on the requested type. The method should consult the list of supported nodes and edges and return a new graph component accordingly. The component should be uninitialized and it should not be added to the graph in order to allow proper initialization by the requesting object.

Specified by:
createComponent in interface GraphCanvas
Parameters:
type - the requested type
Returns:
the new component

addComponent

public void addComponent(GraphComponent c)
Description copied from interface: GraphCanvas
Adds a graph component to the graph

Specified by:
addComponent in interface GraphCanvas

addEdge

protected void addEdge(EdgeComponent ec,
                       Object fromId,
                       Object toId)

removeComponent

public void removeComponent(GraphComponent c)
Description copied from interface: GraphCanvas
Removes a component from the graph. It will also remove other components if neccessary. For example, removing a node, will also cause the removal of incident edges.

Specified by:
removeComponent in interface GraphCanvas

addNode

public void addNode(NodeComponent nc)
Adds a node to this canvas

Parameters:
nc - node to be added

addEdge

public void addEdge(EdgeComponent ec)
Adds an edge to this canvas

Parameters:
ec - the edge to be added

addEdge

public void addEdge(EdgeComponent ec,
                    NodeComponent from,
                    NodeComponent to)

createNode

public NodeComponent createNode(String type)
Description copied from interface: GraphCanvas
A specialized method for createComponent that only creates nodes.

Specified by:
createNode in interface GraphCanvas
Returns:

createEdge

public EdgeComponent createEdge(String type)
Description copied from interface: GraphCanvas
A specialized method for createComponent that only creates edges.

Specified by:
createEdge in interface GraphCanvas
Returns:

getSupportedNodes

public List getSupportedNodes()
Description copied from interface: GraphCanvas
This method is used to define the valid node types that can appear within this canvas.

Specified by:
getSupportedNodes in interface GraphCanvas
Returns:
A list of node components that are valid for this canvas

getSupportedEdges

public List getSupportedEdges()
Description copied from interface: GraphCanvas
This method is used to define the valid edge types that can appear within this canvas.

Specified by:
getSupportedEdges in interface GraphCanvas
Returns:

addNodeType

public void addNodeType(NodeComponent node)
Adds a prototype node to this canvas

Parameters:
node -

removeNodeType

public void removeNodeType(Class node)

addEdgeType

public void addEdgeType(EdgeComponent edge)
Adds an edge prototype to this canvas

Parameters:
edge -

removeEdgeType

public void removeEdgeType(Class edge)

graphComponentEvent

public void graphComponentEvent(GraphComponentWrapperEvent e)
Specified by:
graphComponentEvent in interface GraphComponentWrapperListener

getOwner

public NodeComponent getOwner()
Specified by:
getOwner in interface GraphCanvas
Returns:
the node that owns this canvas

setOwner

public void setOwner(NodeComponent owner)
Description copied from interface: GraphCanvas
Sets the value of the owner of this canvas

Specified by:
setOwner in interface GraphCanvas

setPropagateEvents

public void setPropagateEvents(boolean v)
Determines whether node events are being propagated to the listeners for this canvas

Parameters:
v -

getStatusManager

public StatusManager getStatusManager()
Description copied from interface: GraphCanvas
Each canvas can have a status manager that can be used to represent various pieces of information pertaining to outcomes of various actions performed on the canvas or its descendants. This method returns the status manager of this canvas.

Specified by:
getStatusManager in interface GraphCanvas

addCanvasEventListener

public void addCanvasEventListener(CanvasEventListener listener)
Description copied from interface: GraphCanvas
Adds a listener that can be used to receive various notification events about the state of the canvas

Specified by:
addCanvasEventListener in interface GraphCanvas

removeCanvasEventListener

public void removeCanvasEventListener(CanvasEventListener listener)
Description copied from interface: GraphCanvas
Removes a previously added listener

Specified by:
removeCanvasEventListener in interface GraphCanvas

fireCanvasEvent

public void fireCanvasEvent(CanvasEvent e)
Specified by:
fireCanvasEvent in interface GraphCanvas

addStatusEventListener

public void addStatusEventListener(StatusEventListener listener)
Specified by:
addStatusEventListener in interface GraphCanvas

removeStatusEventListener

public void removeStatusEventListener(StatusEventListener listener)
Specified by:
removeStatusEventListener in interface GraphCanvas

fireStatusEvent

public void fireStatusEvent(StatusEvent e)
Specified by:
fireStatusEvent in interface GraphCanvas

invalidate

public void invalidate()
Description copied from interface: GraphCanvas
Notifies the canvas about changes in its sub-components that may require the re-evaluation of the state of the canvas object, most notably a re-rendering of the canvas.

Specified by:
invalidate in interface GraphCanvas

setEventsActive

public void setEventsActive(boolean eventsActive)
Specified by:
setEventsActive in interface GraphCanvas

graphChanged

public void graphChanged(GraphChangedEvent e)
Specified by:
graphChanged in interface GraphListener