prolog.treeview
Class Node

java.lang.Object
  |
  +--prolog.treeview.Node
Direct Known Subclasses:
RootNode

public class Node
extends java.lang.Object

the node class implements a node storing a object as value. this class also contains a static renderer map mapping a Class to a renderer. So the node knows how to render the content.


Field Summary
protected  java.util.List childs
          list of all childs of this node
protected  java.lang.Object content
          the user content stored in this node
protected static INodeRenderer defaultRenderer
          is the default renderer used when no renderer was found in the renderer map
protected static java.util.Map gvNodeRendererMap
          static node renderer map, key is a node object's class and value is the INodeRenderer
protected  Node parent
          the parent node of this node
protected  java.awt.Rectangle rect
          the nodes layout in the tree space
 
Constructor Summary
Node()
          constructor
Node(Node parent)
          constructor
Node(java.lang.String userString)
          constructor - the userString will become the node's user object
 
Method Summary
 void addChild(Node node)
          adds a child node to this node
protected  boolean fireTreeChanged()
          relayouts and repaints the tree
 void genXml(java.io.Writer out)
          generates a xml representation of this object
 java.awt.Point getCenter()
          returns the point in the center of this node in tree space
 java.awt.Point getCenterBottom()
          returns the point in the middle+bottom of this node in tree space
 java.awt.Point getCenterTop()
          returns the point in the middle+top of this node in tree space
 Node getChild(int index)
          return the node at the specified index
 int getChildCount()
          returns the number of childs direct of this node
 java.util.Iterator getChilds()
          returns a iterator over all childs
 java.lang.Object getContent()
          return the content of this map
static INodeRenderer getDefaultRenderer()
          returns the default rederer used to render unknown content.
 java.awt.Dimension getDimension()
          calculates the dimension this node requires in tree space
 int getMaximalHeight()
          recursive method calculating the height of this node and all childs required for rendering.
 int getMaximalWidth()
          recursive method calculating the with this node requires for rendering
 Node getParent()
          returns the parent of this node
 java.awt.Rectangle getRect()
          returns the rect of this node in tree space
static INodeRenderer getRenderer(java.lang.Class key)
          returns a renderer (if one was found) from the renderer map
 RootNode getRoot()
          returns the root of this node
 Tree getTree()
          returns the tree this node is contained in
 boolean hasChild(Node node)
          returns true if the given node is a direct child of this node
 void paint(java.awt.Graphics2D g)
          paints this node and all recursive childs
 void paintLine(java.awt.Graphics2D g)
          paints all lines between all recursive childs
 void recursiveDimensionUpdate()
          recaltulates and caches the space required by the renderer to render this node.
static void registerRenderer(java.lang.Class key, INodeRenderer renderer)
          registers a INodeRenderer for a specified Node content
 void removeChild(Node node)
          removes the specified child node from this node
 void setContent(java.lang.Object content)
          sets the content of this map
 void setParent(Node parent)
          sets the parent of this node
 java.lang.String toString()
          returns a string representation of this object
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

gvNodeRendererMap

protected static java.util.Map gvNodeRendererMap
static node renderer map, key is a node object's class and value is the INodeRenderer

defaultRenderer

protected static INodeRenderer defaultRenderer
is the default renderer used when no renderer was found in the renderer map

rect

protected java.awt.Rectangle rect
the nodes layout in the tree space

childs

protected java.util.List childs
list of all childs of this node

parent

protected Node parent
the parent node of this node

content

protected java.lang.Object content
the user content stored in this node
Constructor Detail

Node

public Node()
constructor

Node

public Node(java.lang.String userString)
constructor - the userString will become the node's user object
Parameters:
s -  

Node

public Node(Node parent)
constructor
Parameters:
parent -  
Method Detail

getParent

public Node getParent()
returns the parent of this node

setParent

public void setParent(Node parent)
sets the parent of this node

getContent

public java.lang.Object getContent()
return the content of this map

setContent

public void setContent(java.lang.Object content)
sets the content of this map

addChild

public void addChild(Node node)
adds a child node to this node

removeChild

public void removeChild(Node node)
removes the specified child node from this node

getChildCount

public int getChildCount()
returns the number of childs direct of this node

hasChild

public boolean hasChild(Node node)
returns true if the given node is a direct child of this node

getChild

public Node getChild(int index)
return the node at the specified index

getChilds

public java.util.Iterator getChilds()
returns a iterator over all childs

getRoot

public RootNode getRoot()
returns the root of this node

getTree

public Tree getTree()
returns the tree this node is contained in

getRect

public java.awt.Rectangle getRect()
returns the rect of this node in tree space

paint

public void paint(java.awt.Graphics2D g)
paints this node and all recursive childs

paintLine

public void paintLine(java.awt.Graphics2D g)
paints all lines between all recursive childs

getDimension

public java.awt.Dimension getDimension()
calculates the dimension this node requires in tree space

recursiveDimensionUpdate

public void recursiveDimensionUpdate()
recaltulates and caches the space required by the renderer to render this node.

getCenter

public java.awt.Point getCenter()
returns the point in the center of this node in tree space

getCenterTop

public java.awt.Point getCenterTop()
returns the point in the middle+top of this node in tree space

getCenterBottom

public java.awt.Point getCenterBottom()
returns the point in the middle+bottom of this node in tree space

toString

public java.lang.String toString()
returns a string representation of this object
Overrides:
toString in class java.lang.Object

fireTreeChanged

protected boolean fireTreeChanged()
relayouts and repaints the tree

genXml

public void genXml(java.io.Writer out)
            throws java.io.IOException
generates a xml representation of this object

registerRenderer

public static void registerRenderer(java.lang.Class key,
                                    INodeRenderer renderer)
registers a INodeRenderer for a specified Node content
Parameters:
key -  
renderer -  

getRenderer

public static INodeRenderer getRenderer(java.lang.Class key)
returns a renderer (if one was found) from the renderer map
Parameters:
key -  
Returns:
 

getDefaultRenderer

public static INodeRenderer getDefaultRenderer()
returns the default rederer used to render unknown content.

getMaximalHeight

public int getMaximalHeight()
recursive method calculating the height of this node and all childs required for rendering.

getMaximalWidth

public int getMaximalWidth()
recursive method calculating the with this node requires for rendering