ptolemy.vergil.basic
Class LocatableNodeController

java.lang.Object
  extended bydiva.graph.BasicNodeController
      extended byptolemy.vergil.basic.LocatableNodeController
All Implemented Interfaces:
NodeController
Direct Known Subclasses:
NamedObjController

public class LocatableNodeController
extends BasicNodeController

This node controller provides interaction techniques for nodes that are locations. This is common when the node has some concept of its graphical location, but does not know about the figure that it is associated with. This class provides the connection between the figure's notion of location and the node's concept of location.

When nodes are drawn, they are automatically placed at the coordinate given by the location. A LocatableNodeDragInteractor is used to update the location of the node as the figure moves.

Since:
Ptolemy II 2.0
Version:
$Id: LocatableNodeController.java,v 1.26.2.2 2004/07/19 04:43:54 cxh Exp $
Author:
Steve Neuendorffer
Accepted Rating:
Red (johnr)
Proposed Rating:
Red (eal)

Field Summary
static java.awt.Color CLASS_ELEMENT_HIGHLIGHT_COLOR
           
 
Constructor Summary
LocatableNodeController(GraphController controller)
          Create an instance associated with the specified graph controller.
 
Method Summary
protected  void _drawChildren(java.lang.Object node)
          Render the children of the specified node.
protected  boolean _hide(java.lang.Object node)
          In this base class, return true if the specified node contains an attribute named "_hide".
protected  Figure _renderNode(java.lang.Object node)
          Render the specified node.
 void addNode(java.lang.Object node, double x, double y)
          Add a node to this graph editor and render it at the given location.
 Figure drawNode(java.lang.Object node)
          Draw the node at its location.
 double[] getLocation(java.lang.Object node)
          Return the desired location of this node.
 boolean hasLocation(java.lang.Object node)
          Return true if the node is associated with a desired location.
 void locateFigure(java.lang.Object node)
          Move the node's figure to the location specified in the node's semantic object, if that object is an instance of Locatable.
 void setLocation(java.lang.Object node, double[] location)
          Set the desired location of this node.
 void setSnapResolution(double resolution)
          Specify the snap resolution.
 
Methods inherited from class diva.graph.BasicNodeController
addNode, addNode, addNode, clearNode, drawNode, getController, getNodeInteractor, getNodeRenderer, removeNode, setNodeInteractor, setNodeRenderer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_ELEMENT_HIGHLIGHT_COLOR

public static java.awt.Color CLASS_ELEMENT_HIGHLIGHT_COLOR
Constructor Detail

LocatableNodeController

public LocatableNodeController(GraphController controller)
Create an instance associated with the specified graph controller.

Parameters:
controller - The graph controller.
Method Detail

addNode

public void addNode(java.lang.Object node,
                    double x,
                    double y)
Add a node to this graph editor and render it at the given location.

Specified by:
addNode in interface NodeController
Overrides:
addNode in class BasicNodeController

drawNode

public Figure drawNode(java.lang.Object node)
Draw the node at its location. This overrides the base class to assign a location to the object.

Specified by:
drawNode in interface NodeController
Overrides:
drawNode in class BasicNodeController

getLocation

public double[] getLocation(java.lang.Object node)
Return the desired location of this node. Throw an exception if the node does not have a desired location.


hasLocation

public boolean hasLocation(java.lang.Object node)
Return true if the node is associated with a desired location. In this base class, return true if the the node's semantic object is an instance of Locatable.


locateFigure

public void locateFigure(java.lang.Object node)
Move the node's figure to the location specified in the node's semantic object, if that object is an instance of Locatable. If the semantic object is not a location, then do nothing. If the figure associated with the semantic object is an instance of TerminalFigure, then modify the location to ensure that the connect site snaps to grid.

Parameters:
node - The object to locate.

setLocation

public void setLocation(java.lang.Object node,
                        double[] location)
                 throws IllegalActionException
Set the desired location of this node. Throw an exception if the node can not be given a desired location.

Throws:
IllegalActionException - Not thrown in this base class.

setSnapResolution

public void setSnapResolution(double resolution)
Specify the snap resolution. The default snap resolution is 5.0.

Parameters:
resolution - The snap resolution.

_drawChildren

protected void _drawChildren(java.lang.Object node)
Render the children of the specified node. This overrides the base class to do nothing if the node contains an attribute named "_hide".

Overrides:
_drawChildren in class BasicNodeController
Parameters:
node - The node with children to render.

_renderNode

protected Figure _renderNode(java.lang.Object node)
Render the specified node. This overrides the base class to return an invisible figure if the node contains an attribute named "_hide". This overrides the base class to assign a location and to highlight the node if it is an inherited object, and hence cannot be deleted.

Overrides:
_renderNode in class BasicNodeController
Parameters:
node - The node to render.

_hide

protected boolean _hide(java.lang.Object node)
In this base class, return true if the specified node contains an attribute named "_hide". Derived classes can override this method to provide more sophisticated methods of choosing which nodes to display.