org.ceryle.graph.tm
Class ANode

java.lang.Object
  extended by com.touchgraph.graphlayout.Node
      extended by org.ceryle.graph.GraphNode
          extended by org.ceryle.graph.tm.TMNode
              extended by org.ceryle.graph.tm.ANode
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
EditorLayoutPanel.EANode

public class ANode
extends TMNode

Extends TMNode acting as an Association Node (or A-Node) in a topic map graph.

For binary associations, the 'to' and 'from' TNodes can be set for directedness. The method isDirected() returns true when both are set. If more than two edges are connected to this ANode, isDirected() should return false (this must be managed external to the ANode by nulling one or both of the to and from references).

Because ANodes are meant to represent topic map associations (in this case, Association objects), constructors including Associations use those objects' IDs as the ANode IDs so that retrieving a specific Association from the topic map processor or the ANode representing that association is a matter of referencing either within the topic map or graph (resp.) using the same ID value.

Since:
JDK1.3
Version:
$Id: ANode.java,v 3.7 2007-06-15 12:09:26 altheim Exp $
Author:
Murray Altheim

Field Summary
static Color COLOR_ASSOC_BORDER
          The border color of inactive association nodes.
static Color COLOR_ASSOC_BORDER_SELECT
          The border color of selected association nodes.
static Color COLOR_ASSOC_INSTANCEOF
          The color of instance-of association nodes.
static Color COLOR_ASSOC_NODE
          The color of association nodes.
static Color COLOR_ASSOC_NODE_FIXED
          The color of fixed association nodes.
static Color COLOR_ASSOC_NODE_MOUSE_OVER
          The color of mouse-over'd association nodes.
static Color COLOR_ASSOC_NODE_REM
          The color of an association nodes marked for removal.
static Color COLOR_ASSOC_NODE_SELECT
          The color of selected association nodes.
static Color COLOR_ASSOC_NODE_TEXT
          The color of text on association nodes.
static Color COLOR_ASSOC_SUBCLASSOF
          The color of subclass association nodes.
static Color COLOR_ASSOC_TEMPLATE
          The color of association template nodes, i.e., the type of association.
 
Fields inherited from class org.ceryle.graph.GraphNode
COLOR_BORDER_DRAG, COLOR_BORDER_FIXED, COLOR_BORDER_INACTIVE, COLOR_BORDER_MOUSE_OVER, COLOR_DEFAULT_NODE, COLOR_FIXED_NODE, COLOR_HILIGHTED_NODE, COLOR_NEW_LOCAL_NODE, COLOR_NODE_DOWNSTREAM, COLOR_NODE_REMOVAL, COLOR_NODE_TEXT, COLOR_NODE_UPSTREAM, COLOR_PROVISIONAL, COLOR_SELECT_NODE, COLOR_SELECT_NODE_B, COLOR_SELECT_NODE_D, COLOR_SMALL_TAG, COLOR_TRANSLUCENT_GRAY, defaultMargin, Ellipsis, fontMetrics, h, hidden, hilight, hMargin, m_listener, maxHeight, maxLabelLength, maxWidth, minHeight, minWidth, outlined, provisional, rel_angle, sortCaseSensitive, STROKE_OUTLINE, STROKE_PROVISIONAL, use3D, vMargin, w
 
Fields inherited from class com.touchgraph.graphlayout.Node
BACK_DEFAULT_COLOR, BACK_FIXED_COLOR, BACK_HILIGHT_COLOR, BACK_SELECT_COLOR, backColor, BORDER_DRAG_COLOR, BORDER_INACTIVE_COLOR, BORDER_MOUSE_OVER_COLOR, DEFAULT_TYPE, drawx, drawy, dx, dy, edges, fixed, font, justMadeLocal, lbl, markedForRemoval, massfade, repulsion, simpleDraw, SMALL_TAG_FONT, TEXT_COLOR, TEXT_FONT, textColor, typ, TYPE_CIRCLE, TYPE_ELLIPSE, TYPE_RECTANGLE, TYPE_ROUNDRECT, visible, visibleEdgeCnt, x, y
 
Constructor Summary
ANode(Association assoc)
          Constructor with an Association assoc.
ANode(Association assoc, String label)
          Constructor with an Association assoc and a String label.
ANode(String id)
          Constructor with the required ID id value.
ANode(String id, String label)
          Constructor with the required ID id and label.
 
Method Summary
 GraphEdge getEdgeForTNode(TNode tnode)
          Return the edge connecting this ANode to the TNode tnode.
 Iterator getEdges()
          Overrides getEdges() in Node, returning the Edges of this ANode, null if none have been set.
 Edge getFrom()
          Returns the 'from' Edge of this ANode, null if it has not been set.
 TNode getOtherEnd(TNode n)
          Returns the other end of this ANode provided with one end, throwing a GraphException if direction is not set.
 Iterator getOtherEnds(TNode n)
          Returns an Iterator over the "other ends" (i.e., all TNodes connected to this ANode) provided with one end.
 Color getPaintBackColor(TGPanel tgPanel)
          Overrides Node's method.
 Color getPaintBorderColor(TGPanel tgPanel)
          Returns the border color of the node, dependent on context.
 Color getPaintTextColor(TGPanel tgPanel)
          Returns the text color of the node, dependent on context.
 Edge getTo()
          Returns the 'from' Edge of this ANode, null if it has not been set.
 boolean isConnected(TNode n)
          Returns true if the provided TNode n is connected to this ANode.
 boolean isDirected()
          Returns whether or not this ANode is binary directed, ie., whether the TNode references to and from have been set (ie., if both getTo() and getFrom() return non-null values).
 void setFrom(Edge edge)
          Set the 'from' Edge of this ANode.
 void setTo(Edge edge)
          Set the 'to' Edge of this ANode.
 
Methods inherited from class org.ceryle.graph.tm.TMNode
getTopicMapObject, setFixed, setTopicMapObject
 
Methods inherited from class org.ceryle.graph.GraphNode
compareTo, getDefaultNodeFont, getHeight, getHilight, getID, getLabel, getMouseListener, getNodeFont, getVerticalTweak, getVerticalTweak, getWidth, isHidden, isProvisional, jubble, paint, paintNodeBody, paintProvisional, paintSimple, paintSmallTag, setAlternateFont, setHidden, setHilight, setMargin, setMaximumLabelLength, setMouseListener, setNodeTagFont, setNodeTextFont, setProvisional, setSize, setVerticalTweak, toString
 
Methods inherited from class com.touchgraph.graphlayout.Node
addEdge, containsPoint, containsPoint, deleteEdges, edgeAt, edgeCount, edgeNum, getBackColor, getFixed, getFont, getLocation, getTextColor, getType, hasEdge, intersects, isFixed, isVisible, removeEdge, setBackColor, setFixed, setFont, setID, setLabel, setLocation, setLocation, setNodeBackDefaultColor, setNodeBackFixedColor, setNodeBackHilightColor, setNodeBackSelectColor, setNodeBorderDragColor, setNodeBorderInactiveColor, setNodeBorderMouseOverColor, setNodeTextColor, setNodeType, setTextColor, setType, setVisible, visibleEdgeCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

COLOR_ASSOC_NODE

public static Color COLOR_ASSOC_NODE
The color of association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocNode.


COLOR_ASSOC_NODE_SELECT

public static Color COLOR_ASSOC_NODE_SELECT
The color of selected association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocNodeSelect.


COLOR_ASSOC_BORDER

public static Color COLOR_ASSOC_BORDER
The border color of inactive association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocBorder.


COLOR_ASSOC_BORDER_SELECT

public static Color COLOR_ASSOC_BORDER_SELECT
The border color of selected association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocBorderSelect.


COLOR_ASSOC_NODE_MOUSE_OVER

public static Color COLOR_ASSOC_NODE_MOUSE_OVER
The color of mouse-over'd association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocNodeMouseOver.


COLOR_ASSOC_NODE_REM

public static Color COLOR_ASSOC_NODE_REM
The color of an association nodes marked for removal. Default is darker than normal.


COLOR_ASSOC_NODE_FIXED

public static Color COLOR_ASSOC_NODE_FIXED
The color of fixed association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocNodeFixed.


COLOR_ASSOC_NODE_TEXT

public static Color COLOR_ASSOC_NODE_TEXT
The color of text on association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocNodeText.


COLOR_ASSOC_INSTANCEOF

public static Color COLOR_ASSOC_INSTANCEOF
The color of instance-of association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-instanceOfAssoc.


COLOR_ASSOC_SUBCLASSOF

public static Color COLOR_ASSOC_SUBCLASSOF
The color of subclass association nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-subclassOfAssoc.


COLOR_ASSOC_TEMPLATE

public static Color COLOR_ASSOC_TEMPLATE
The color of association template nodes, i.e., the type of association. Ceryle property: http://purl.org/ceryle/prop/#graph-color-assocTemplate.

Constructor Detail

ANode

public ANode(String id)
      throws GraphException
Constructor with the required ID id value. The label will be taken from the ID. If this ANode is meant to correspond to an XTM association, its ID should match the ID of the association.

Throws:
GraphException

ANode

public ANode(String id,
             String label)
      throws GraphException
Constructor with the required ID id and label. If this ANode is meant to correspond to an XTM association, its ID should match the ID of the association.

Throws:
GraphException

ANode

public ANode(Association assoc)
      throws GraphException
Constructor with an Association assoc. This assumes the ANode ID and label will be taken from the Association's ID value.

Throws:
GraphException

ANode

public ANode(Association assoc,
             String label)
      throws GraphException
Constructor with an Association assoc and a String label. This assumes the ANode ID will be taken from the Association.

Throws:
GraphException
Method Detail

isDirected

public boolean isDirected()
Returns whether or not this ANode is binary directed, ie., whether the TNode references to and from have been set (ie., if both getTo() and getFrom() return non-null values).


setFrom

public void setFrom(Edge edge)
Set the 'from' Edge of this ANode.


getFrom

public Edge getFrom()
Returns the 'from' Edge of this ANode, null if it has not been set.


setTo

public void setTo(Edge edge)
Set the 'to' Edge of this ANode.


getTo

public Edge getTo()
Returns the 'from' Edge of this ANode, null if it has not been set.


getEdgeForTNode

public GraphEdge getEdgeForTNode(TNode tnode)
Return the edge connecting this ANode to the TNode tnode. Returns null if the TNode is not connected to this ANode.


getEdges

public Iterator getEdges()
Overrides getEdges() in Node, returning the Edges of this ANode, null if none have been set.

Because on ANodes, to and from references may be set instead of adding them to the edges registry, if the registry is empty to and from are checked and an Iterator returned if either reference is non-null.

Overrides:
getEdges in class Node

getOtherEnd

public TNode getOtherEnd(TNode n)
                  throws GraphException
Returns the other end of this ANode provided with one end, throwing a GraphException if direction is not set. Direction is only valid with directed binary associations, eg.:
         T1----from----A1----to----T2
 
 

Where n = T1, returns T2.
Where n = T2, returns T1.

Non-TNodes are ignored.

Throws:
GraphException - if the association is not directed, or if n is not a connected node in this association

isConnected

public boolean isConnected(TNode n)
                    throws GraphException
Returns true if the provided TNode n is connected to this ANode. Edge direction is ignored.

Throws:
GraphException

getOtherEnds

public Iterator getOtherEnds(TNode n)
                      throws GraphException
Returns an Iterator over the "other ends" (i.e., all TNodes connected to this ANode) provided with one end. This pays no attention to edge direction. If there are no connected edges, returns null.

Throws:
GraphException

getPaintBackColor

public Color getPaintBackColor(TGPanel tgPanel)
Overrides Node's method.

Overrides:
getPaintBackColor in class GraphNode

getPaintBorderColor

public Color getPaintBorderColor(TGPanel tgPanel)
Returns the border color of the node, dependent on context. This overrides the method in com.touchgraph.graphlayout.Node.

Overrides:
getPaintBorderColor in class GraphNode

getPaintTextColor

public Color getPaintTextColor(TGPanel tgPanel)
Returns the text color of the node, dependent on context. This overrides the method in com.touchgraph.graphlayout.Node.

Overrides:
getPaintTextColor in class Node


The Ceryle Project. Copyright ©2001-2007 Murray Altheim, All Rights Reserved. See LICENSE included with distribution.