org.ceryle.graph.tm
Class TNode

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.TNode
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
EditorLayoutPanel.ETNode, IVNode

public class TNode
extends TMNode
implements Comparable

An extension of com.touchgraph.graphlayout.Node for display of a Topic Map node. Additionally, nodes that contain temporal extents may be displayed as a horizontally-oriented timeline. Other Nodes having a temporal extent can be aligned according to the timeline, after turning off TouchGraph's rubber-banding (by fixing the nodes) and hiding their edges or causing them to appear as without horizontal vectors (ie., as vertical lines).

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

If temporal extents have not been set, getStart() and getEnd() return the Date constant TimeLine.TIME_NOT_SET (see TimeLine.TIME_NOT_SET).

Note: that the timeline code is currently commented out.

Since:
JDK1.3
Version:
$Id: TNode.java,v 3.29 2007-06-15 12:09:27 altheim Exp $
Author:
Murray Altheim
See Also:
GraphNode, TMNode, TimeLine

Field Summary
protected  int[] b
           
static Color COLOR_EARMARK
           
static Color COLOR_EARMARK_B
           
static Color COLOR_EARMARK_E
           
static Color COLOR_NEEDLE
           
static Color COLOR_OCCUR_COUNT
           
static Color COLOR_TIMELINE
           
static Color COLOR_TIMELINE_MASK
           
static Color COLOR_TOPIC_BORDER
          The border color of inactive topic nodes.
static Color COLOR_TOPIC_BORDER_OUTLINE
          The outline color of selected topic nodes.
static Color COLOR_TOPIC_BORDER_SELECT
          The border color of selected topic nodes.
static Color COLOR_TOPIC_BORDER_SELECT_MOUSE_OVER
           
static Color COLOR_TOPIC_COMPONENT
          The color of topic nodes whose type indicates that they are document components.
static Color COLOR_TOPIC_COMPONENT_B
           
static Color COLOR_TOPIC_COMPONENT_D
           
static Color COLOR_TOPIC_COMPONENT_MOUSE_OVER
          The color of mouse-over'd document component nodes.
static Color COLOR_TOPIC_COMPONENT_SELECT
          The color of topic nodes' text whose type indicates that they are document components.
static Color COLOR_TOPIC_COMPONENT_TEXT
          The color of topic nodes' text whose type indicates that they are document components.
static Color COLOR_TOPIC_NODE
          The color of topic nodes.
static Color COLOR_TOPIC_NODE_B
           
static Color COLOR_TOPIC_NODE_D
           
static Color COLOR_TOPIC_NODE_FIXED
          The color of fixed topic nodes.
static Color COLOR_TOPIC_NODE_MOUSE_OVER
          The color of mouse-over'd topic nodes.
static Color COLOR_TOPIC_NODE_REM
          The color of a topic nodes marked for removal.
static Color COLOR_TOPIC_NODE_TEXT
          The color of text on topic nodes.
static Color COLOR_TOPIC_NODE_TIMELINE
          The color of timeline nodes.
static Color COLOR_VERNIER_BASE
           
static Color COLOR_VERNIER_DARK
           
static Color COLOR_VERNIER_TINT
           
static Color COLOR_VERNIER_WINDOW
           
static Color COLOR_VERNIER_WINDOW_TINT
           
static boolean colorAsFlag
          A boolean controlling whether custom colors should be painted as a small tab or flag (when true) or as the entire node background (when false).
protected  boolean component
          True if the type of the Topic of this TNode indicates it is a document component.
protected  long endDate
          Temporal end extent stored internally as a long.
protected  Color flag
          The Color tab or 'flag' indicating a color label.
protected  Color flagHilight
           
 boolean ignoreMe
          When true, the TNode is ignored by the layout.
protected  int occurCount
          Topic occurrence count.
 boolean paintOccurrences
          A boolean indicating whether the occurrence count should be displayed.
protected  int[] pox
           
protected  int[] poy
           
 float score
          Topic match score.
protected  long startDate
          Temporal start extent stored internally as a long.
protected static int textHeight
          Default text height, in pixels (default is 16; substitute for fontmetrics).
 int tl_h
          An int storing the calculated width of the Node ('h' is the height).
 int tl_w
          An int storing the calculated width of the Node ('h' is the height).
 
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
TNode(String id)
          Constructor with the required ID id value.
TNode(String id, String label)
          Constructor with the required ID id and label.
TNode(TopicMapObject tmo, Locator locator, String id, String label)
          Primary constructor for a TNode, provided with a TopicMapObject tmo, a Locator locator for the external link, an optional ID String id, and optional String label.
TNode(TopicMapObject tmo, String id, String label)
          Constructor with an Topic topic and Strings for ID id and label.
TNode(Topic topic, String label)
          Constructor with an Topic topic, and a String used as its label.
 
Method Summary
 Color getBackColor()
          Overrides Node's method to return the background color, ignoring fixed status, highlighting or mouseovers.
 Color getFlag()
          Returns the color flag of this node, or null if it has not been set.
 int getHeight()
          Overrides GraphNode's method by returning the calculated height of this TNode.
 Locator getLocator()
          Returns the Locator of this TNode, null if not set.
 Color getPaintBackColor(TGPanel tgPanel)
          Overrides GraphNode's method by highlighting mouseOvers.
 Color getPaintBorderColor(TGPanel tgPanel)
          Overrides GraphNode's method to return the border color of the node, dependent on context.
 Color getPaintTextColor(TGPanel tgPanel)
          Returns the text color of the node, dependent on context.
 int getWidth()
          Overrides GraphNode's method by returning the calculated width of this TNode.
 boolean hasFlag()
          Returns true if the color flag of this node has been set.
 boolean hasLocator()
          Returns true if this TNode has a Locator set.
 boolean hasPopupMenu()
          Returns true if a menu has been set for this TNode.
 boolean isClickInMenu(int x)
          Returns true if there is a popup menu set, and the click position x was in the area of the popupmenu.
 boolean isComponent()
          If the TopicMapObject for this TNode is set, and the associated Topic includes a Locator for the Ceryle PSI for 'component', returns true, otherwise, returns false.
 void paint(Graphics g, TGPanel tgPanel)
          Paints the Node.
 void paintColorFlag(Graphics g, int x, int y)
          Sets the color flag of this TNode to color.
 void paintLinkBody(Graphics g, TGPanel tgPanel)
          Paints the node as either a popup menu node (if a popup is set), or an arrow/link node (if a Locator is set).
 void paintNodeBody(Graphics g, TGPanel tgPanel)
          Overrides GraphNode's method by painting the body of the TNode, along with a timeline scale if scaleViz is true.
 void paintOccurrenceCount(Graphics g, TGPanel tgPanel, int tagX, int tagY)
          Paints a small rectangle displaying the number of topic occurrences.
 void setAsComponent(boolean isComponent)
          Sets the value of the TNode's 'component' boolean.
 void setFixed(boolean fixed)
          Sets the fixed status of this TNode to the boolean fixed.
 void setFixed(boolean fixed, Point p)
          Sets the fixed status of this TNode to the boolean fixed, fixing it at the provided Point p.
 void setFlag(Color color)
          Sets the color flag of this GraphNode to color.
 void setLocator(Locator locator)
          Sets the Locator of this TNode to the provided parameter.
 void setPopupMenu(LinkPopupMenu popupmenu)
          Set the menu for this TNode.
 void setTopicMapObject(TopicMapObject object)
          Overrides TMNode's method of the same name, setting the TopicMapObject reference within this TNode to the TopicMapObject object.
 void showPopupMenu(MouseEvent e)
          Show the popup menu if it has been set for this TNode.
 
Methods inherited from class org.ceryle.graph.tm.TMNode
getTopicMapObject
 
Methods inherited from class org.ceryle.graph.GraphNode
compareTo, getDefaultNodeFont, getHilight, getID, getLabel, getMouseListener, getNodeFont, getVerticalTweak, getVerticalTweak, isHidden, isProvisional, jubble, 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, getEdges, getFixed, getFont, getLocation, getTextColor, getType, hasEdge, intersects, isFixed, isVisible, removeEdge, setBackColor, 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_TOPIC_NODE

public static Color COLOR_TOPIC_NODE
The color of topic nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicNode.


COLOR_TOPIC_NODE_D

public static Color COLOR_TOPIC_NODE_D

COLOR_TOPIC_NODE_B

public static Color COLOR_TOPIC_NODE_B

COLOR_TOPIC_COMPONENT

public static Color COLOR_TOPIC_COMPONENT
The color of topic nodes whose type indicates that they are document components. Ceryle property: http://purl.org/ceryle/prop/#graph-color-component.


COLOR_TOPIC_COMPONENT_D

public static Color COLOR_TOPIC_COMPONENT_D

COLOR_TOPIC_COMPONENT_B

public static Color COLOR_TOPIC_COMPONENT_B

COLOR_TOPIC_COMPONENT_TEXT

public static Color COLOR_TOPIC_COMPONENT_TEXT
The color of topic nodes' text whose type indicates that they are document components. Ceryle property: http://purl.org/ceryle/prop/#graph-color-componentText.


COLOR_TOPIC_COMPONENT_SELECT

public static Color COLOR_TOPIC_COMPONENT_SELECT
The color of topic nodes' text whose type indicates that they are document components. Ceryle property: http://purl.org/ceryle/prop/#graph-color-componentSelect.


COLOR_TOPIC_COMPONENT_MOUSE_OVER

public static Color COLOR_TOPIC_COMPONENT_MOUSE_OVER
The color of mouse-over'd document component nodes. Slightly brighter.


COLOR_TOPIC_BORDER

public static Color COLOR_TOPIC_BORDER
The border color of inactive topic nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicBorder.


COLOR_TOPIC_BORDER_SELECT

public static Color COLOR_TOPIC_BORDER_SELECT
The border color of selected topic nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicBorderSelect.


COLOR_TOPIC_BORDER_SELECT_MOUSE_OVER

public static Color COLOR_TOPIC_BORDER_SELECT_MOUSE_OVER

COLOR_TOPIC_BORDER_OUTLINE

public static Color COLOR_TOPIC_BORDER_OUTLINE
The outline color of selected topic nodes. This is set relative to COLOR_TOPIC_BORDER_SELECT.


COLOR_TOPIC_NODE_MOUSE_OVER

public static Color COLOR_TOPIC_NODE_MOUSE_OVER
The color of mouse-over'd topic nodes. Slightly brighter. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicNodeMouseOver.


COLOR_TOPIC_NODE_REM

public static Color COLOR_TOPIC_NODE_REM
The color of a topic nodes marked for removal. Default is a darker than normal.


COLOR_TOPIC_NODE_FIXED

public static Color COLOR_TOPIC_NODE_FIXED
The color of fixed topic nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicNodeFixed.


COLOR_TOPIC_NODE_TEXT

public static Color COLOR_TOPIC_NODE_TEXT
The color of text on topic nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-topicNodeText.


COLOR_TOPIC_NODE_TIMELINE

public static Color COLOR_TOPIC_NODE_TIMELINE
The color of timeline nodes. Ceryle property: http://purl.org/ceryle/prop/#graph-color-timelineNode.


COLOR_EARMARK

public static Color COLOR_EARMARK

COLOR_EARMARK_B

public static Color COLOR_EARMARK_B

COLOR_EARMARK_E

public static Color COLOR_EARMARK_E

COLOR_OCCUR_COUNT

public static Color COLOR_OCCUR_COUNT

COLOR_NEEDLE

public static Color COLOR_NEEDLE

COLOR_TIMELINE

public static Color COLOR_TIMELINE

COLOR_TIMELINE_MASK

public static Color COLOR_TIMELINE_MASK

COLOR_VERNIER_WINDOW

public static Color COLOR_VERNIER_WINDOW

COLOR_VERNIER_WINDOW_TINT

public static Color COLOR_VERNIER_WINDOW_TINT

COLOR_VERNIER_BASE

public static Color COLOR_VERNIER_BASE

COLOR_VERNIER_TINT

public static Color COLOR_VERNIER_TINT

COLOR_VERNIER_DARK

public static Color COLOR_VERNIER_DARK

textHeight

protected static int textHeight
Default text height, in pixels (default is 16; substitute for fontmetrics).


paintOccurrences

public boolean paintOccurrences
A boolean indicating whether the occurrence count should be displayed.


component

protected boolean component
True if the type of the Topic of this TNode indicates it is a document component.


tl_w

public int tl_w
An int storing the calculated width of the Node ('h' is the height). There's a performance optimization here: in instances where calculating the width or height is performance-intensive, rather than calculate it each time paintNodeBody() is called, the method setSize(Graphics) is called only when size changes may occur, and the width and height (w,h) ints are set at that time. This is currently only used by the class TNode when its TimeScale is visible.


tl_h

public int tl_h
An int storing the calculated width of the Node ('h' is the height). There's a performance optimization here: in instances where calculating the width or height is performance-intensive, rather than calculate it each time paintNodeBody() is called, the method setSize(Graphics) is called only when size changes may occur, and the width and height (w,h) ints are set at that time. This is currently only used by the class TNode when its TimeScale is visible.


occurCount

protected int occurCount
Topic occurrence count.


score

public float score
Topic match score. Used by search engine.


colorAsFlag

public static boolean colorAsFlag
A boolean controlling whether custom colors should be painted as a small tab or flag (when true) or as the entire node background (when false). The default is true.


flag

protected Color flag
The Color tab or 'flag' indicating a color label. If this variable is non-null, it will be used either to colorize a small tab area, or in preference to the default color, depending on mode.


flagHilight

protected Color flagHilight

startDate

protected long startDate
Temporal start extent stored internally as a long.


endDate

protected long endDate
Temporal end extent stored internally as a long.


ignoreMe

public boolean ignoreMe
When true, the TNode is ignored by the layout.


b

protected int[] b

pox

protected int[] pox

poy

protected int[] poy
Constructor Detail

TNode

public TNode(String id)
      throws GraphException
Constructor with the required ID id value. If this TNode is meant to correspond to an XTM topic, its ID should match the ID of the topic.

Throws:
GraphException

TNode

public TNode(String id,
             String label)
      throws GraphException
Constructor with the required ID id and label. If this TNode is meant to correspond to an XTM topic, its ID should match the ID of the topic, though this is not enforced here.

Throws:
GraphException

TNode

public TNode(Topic topic,
             String label)
      throws GraphException
Constructor with an Topic topic, and a String used as its label. The ID of the TNode will be obtained from the Topic object.

Throws:
GraphException

TNode

public TNode(TopicMapObject tmo,
             String id,
             String label)
      throws GraphException
Constructor with an Topic topic and Strings for ID id and label.

Throws:
GraphException
See Also:
Topic

TNode

public TNode(TopicMapObject tmo,
             Locator locator,
             String id,
             String label)
      throws GraphException
Primary constructor for a TNode, provided with a TopicMapObject tmo, a Locator locator for the external link, an optional ID String id, and optional String label. If the TopicMapObject is supplied and it is a Topic, both the ID nor label are ignored, as they are supplied by the Topic. tmo may also be an Occurrence having an external resource reference. If the Locator has a fragment ID, it must match that of the Topic (if the Topic is present) or an exception is thrown.

Throws:
GraphException
Method Detail

setFixed

public void setFixed(boolean fixed)
Sets the fixed status of this TNode to the boolean fixed.

Overrides:
setFixed in class Node

setFixed

public void setFixed(boolean fixed,
                     Point p)
Sets the fixed status of this TNode to the boolean fixed, fixing it at the provided Point p.

Overrides:
setFixed in class TMNode

setTopicMapObject

public void setTopicMapObject(TopicMapObject object)
Overrides TMNode's method of the same name, setting the TopicMapObject reference within this TNode to the TopicMapObject object. This can be set to null. The difference here is that this checks to see if the topic type is "component" (using Ceryle's PSI).

Overrides:
setTopicMapObject in class TMNode
See Also:
TMNode.setTopicMapObject(TopicMapObject)

setAsComponent

public void setAsComponent(boolean isComponent)
Sets the value of the TNode's 'component' boolean. This does not change the bound Topic.


isComponent

public boolean isComponent()
If the TopicMapObject for this TNode is set, and the associated Topic includes a Locator for the Ceryle PSI for 'component', returns true, otherwise, returns false. Note that this will return false if the TopicMapObject has not been set.


setFlag

public void setFlag(Color color)
Sets the color flag of this GraphNode to color. A value of null means no color flag.


hasFlag

public boolean hasFlag()
Returns true if the color flag of this node has been set.


getFlag

public Color getFlag()
Returns the color flag of this node, or null if it has not been set.


getWidth

public int getWidth()
Overrides GraphNode's method by returning the calculated width of this TNode.

Overrides:
getWidth in class GraphNode

getHeight

public int getHeight()
Overrides GraphNode's method by returning the calculated height of this TNode. This takes into account whether or not the scale is visible.

Overrides:
getHeight in class GraphNode

getPaintBorderColor

public Color getPaintBorderColor(TGPanel tgPanel)
Overrides GraphNode's method to return the border color of the node, dependent on context.

Overrides:
getPaintBorderColor in class GraphNode

getPaintBackColor

public Color getPaintBackColor(TGPanel tgPanel)
Overrides GraphNode's method by highlighting mouseOvers.

Overrides:
getPaintBackColor in class GraphNode

getBackColor

public Color getBackColor()
Overrides Node's method to return the background color, ignoring fixed status, highlighting or mouseovers.

Overrides:
getBackColor in class Node

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

isClickInMenu

public boolean isClickInMenu(int x)
Returns true if there is a popup menu set, and the click position x was in the area of the popupmenu. This obviates the need to call hasPopupMenu().


setLocator

public void setLocator(Locator locator)
                throws GraphException
Sets the Locator of this TNode to the provided parameter. A null value disables the link function.

Throws:
GraphException

hasLocator

public boolean hasLocator()
Returns true if this TNode has a Locator set.


getLocator

public Locator getLocator()
Returns the Locator of this TNode, null if not set.


hasPopupMenu

public boolean hasPopupMenu()
Returns true if a menu has been set for this TNode.


setPopupMenu

public void setPopupMenu(LinkPopupMenu popupmenu)
Set the menu for this TNode. This can be reset by setting it null.


showPopupMenu

public void showPopupMenu(MouseEvent e)
Show the popup menu if it has been set for this TNode.


paint

public void paint(Graphics g,
                  TGPanel tgPanel)
Paints the Node. Overrides TG's method to paint various alterations of the normal node, depending on set features.

Overrides:
paint in class GraphNode

paintNodeBody

public void paintNodeBody(Graphics g,
                          TGPanel tgPanel)
Overrides GraphNode's method by painting the body of the TNode, along with a timeline scale if scaleViz is true.

Overrides:
paintNodeBody in class GraphNode

paintColorFlag

public void paintColorFlag(Graphics g,
                           int x,
                           int y)
Sets the color flag of this TNode to color. A value of null means no color flag.


paintOccurrenceCount

public void paintOccurrenceCount(Graphics g,
                                 TGPanel tgPanel,
                                 int tagX,
                                 int tagY)
Paints a small rectangle displaying the number of topic occurrences.


paintLinkBody

public void paintLinkBody(Graphics g,
                          TGPanel tgPanel)
Paints the node as either a popup menu node (if a popup is set), or an arrow/link node (if a Locator is set). This is not the most efficient code, but these links are usually pretty rare.



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