torero.gui
Class NodeWrapper

java.lang.Object
  |
  +--torero.gui.NodeWrapper

public class NodeWrapper
extends Object

Node Objects used by and with MyTreeUI. It encapsulates the TreeNode Object for compatability with the standard JTree class. Note that there are many protected methods wbich are designed to do the communication with the MyTreeUI. Caution: it does not make sense to call them from another place! The actual implementation assumes, that the TreeModel contains only GrammarNode objects.

See Also:
MyTreeUI, TreeUI, JTree

Method Summary
protected  void calcLineCache()
          Calls the the attribute-routing algorithm recursively on all nodes beyound this node.
 Dimension calcPrefSize(TreeCellRenderer tcr, JTree tree)
          Calculates and sets the prefered size of this node and all it's children, by calling calcPrefSizeX() on itself.
protected  int calcTree()
          Calculates the x and y position for nodes and the needed height for the whole tree, this value is returned.
protected  void collapse()
          Set the nodes expanded flag to false.
protected  void expand()
          Set's the node's expanded flag.
 NodeWrapper getChild(int pos)
          The child at positions pos is returned.
 Iterator getChildList()
          The children of this node are returned.
 int getChildPos(NodeWrapper child)
          The child's positions is returned.
 int getChildSize()
          The number of children is returned.
 TreeNode getInner()
          Get the encapsulated TreeNode object.
 NodeWrapper getNodeAt(int mx, int my)
          Returns the NodeWrapper at the position mx, my [absolute screen coordinates].
 NodeWrapper getParent()
           
 Dimension getpSize()
          Get the preferred size of this node.
static TreePath getWrapperTreePath(TreePath tp, NodeWrapper root)
          Compute the Treepath consisting of NodeWrappers for a given TreePath of TreeNodes.
 int getX()
          Get the x coordinate of this node.
 int getY()
          Get the y coordinate of this node.
 boolean isexpanded()
          See if the node is expanded.
static NodeWrapper mkRootNodeWrapper(TreeNode nodeNchilds)
          A tree of TreeNodes is given - it generates a encapsulating tree (of NodeWrappers) for it.
static NodeWrapper mkSubTree(TreeNode nodeNchilds, NodeWrapper subroot)
          Same as mkRootNodeWrapper - only for subtrees that do not start from the root.
protected  void paintTree(Graphics g, JTree tree, CellRendererPane crp, TreeCellRenderer tcr, TreeSelectionModel tsm)
          Paints this node and (recursively) all nodes beyound this node.
protected  void resetline()
          Only for testing, not used,
protected  void RouteSimple2(Attribute destAttrib, SrcAtt source)
          A attributeconnection - routingalgorithm, only for testing, it is not used.
protected  void RouteSimple3(Attribute destAttrib, SrcAtt source)
          A attributeconnection - routingalgorithm, only for testing, it is not used.
protected  void RouteSimple4(Attribute destAttrib, SrcAtt source)
          A attributeconnection - routingalgorithm, only for testing, it is not used.
protected  void RouteSimple5(Attribute destAttrib, SrcAtt source)
          The attributeconnection - routingalgorithm used.
protected  void RouteTrivial(Attribute destAttrib, SrcAtt source)
          A attributeconnection - routingalgorithm, only for testing, it is not used.
 void testcalcPrefSize()
          Only for testing, never used.
protected  void toggleEvent()
          If the node was expanded it is collapsed and vice versa.
 String toString()
          Only for testing an debugging purpose.
static void treeNodesChanged(TreeModelEvent e, NodeWrapper root)
          Not implememted.
protected static void treeNodesInserted(TreeModelEvent e, NodeWrapper root)
          Tell the NodeWrapper that a TreeNode was inserted.
protected static void treeNodesRemoved(TreeModelEvent e, NodeWrapper root)
          Tell the NodeWrapper that a TreeNode was removed.
protected static void treeStructureChanged(TreeModelEvent e, NodeWrapper root)
          Tell the NodeWrapper that the tree has completeley changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

resetline

protected void resetline()
Only for testing, not used,

mkRootNodeWrapper

public static NodeWrapper mkRootNodeWrapper(TreeNode nodeNchilds)
A tree of TreeNodes is given - it generates a encapsulating tree (of NodeWrappers) for it.
Parameters:
nodeNchilds - root node of the given tree with childs.
Returns:
the root of the encapsulating tree.

mkSubTree

public static NodeWrapper mkSubTree(TreeNode nodeNchilds,
                                    NodeWrapper subroot)
Same as mkRootNodeWrapper - only for subtrees that do not start from the root.

treeNodesChanged

public static void treeNodesChanged(TreeModelEvent e,
                                    NodeWrapper root)
Not implememted.

treeNodesInserted

protected static void treeNodesInserted(TreeModelEvent e,
                                        NodeWrapper root)
Tell the NodeWrapper that a TreeNode was inserted.
Parameters:
e - the TreeNodeEvent that occurred, exact position (and other info) can be derived from it.
root - node of the tree.

treeNodesRemoved

protected static void treeNodesRemoved(TreeModelEvent e,
                                       NodeWrapper root)
Tell the NodeWrapper that a TreeNode was removed.
Parameters:
e - the TreeNodeEvent that occurred, exact position (and other info) can be derived from it.
root - node of the tree.

treeStructureChanged

protected static void treeStructureChanged(TreeModelEvent e,
                                           NodeWrapper root)
Tell the NodeWrapper that the tree has completeley changed. All Nodes beyond the given node (spezified by the Event e), are disposed and regenerated.
Parameters:
e - the TreeNodeEvent that occurred, exact position (and other info) can be derived from it.
root - the root node (unchanged) of the changed subtree.

getChildList

public Iterator getChildList()
The children of this node are returned.
Returns:
an iterator over this' children.

getChild

public NodeWrapper getChild(int pos)
The child at positions pos is returned. Uses the LinkedList's get() method.
Parameters:
pos -  
Returns:
the root of the encapsulating tree.
See Also:
LinkedList

getChildPos

public int getChildPos(NodeWrapper child)
The child's positions is returned. Uses the LinkedList's indexOf() method.
Parameters:
child -  
Returns:
position of the given child.
See Also:
LinkedList

getChildSize

public int getChildSize()
The number of children is returned. Uses the LinkedList's size() method.
Returns:
number of children.
See Also:
LinkedList

getParent

public NodeWrapper getParent()
Returns:
parent node of this node, null if this is the root node.

getWrapperTreePath

public static TreePath getWrapperTreePath(TreePath tp,
                                          NodeWrapper root)
Compute the Treepath consisting of NodeWrappers for a given TreePath of TreeNodes.
Parameters:
tp - given treepath
root - of NodeWrapper Tree
Returns:
a new contructed treepath object.
See Also:
LinkedList

calcPrefSize

public Dimension calcPrefSize(TreeCellRenderer tcr,
                              JTree tree)
Calculates and sets the prefered size of this node and all it's children, by calling calcPrefSizeX() on itself. (Location x y is not computed here, this is done in calcX).

calcLineCache

protected void calcLineCache()
Calls the the attribute-routing algorithm recursively on all nodes beyound this node. Call this method only on the root node.

RouteTrivial

protected void RouteTrivial(Attribute destAttrib,
                            SrcAtt source)
A attributeconnection - routingalgorithm, only for testing, it is not used.

RouteSimple2

protected void RouteSimple2(Attribute destAttrib,
                            SrcAtt source)
A attributeconnection - routingalgorithm, only for testing, it is not used.

RouteSimple3

protected void RouteSimple3(Attribute destAttrib,
                            SrcAtt source)
A attributeconnection - routingalgorithm, only for testing, it is not used.

RouteSimple4

protected void RouteSimple4(Attribute destAttrib,
                            SrcAtt source)
A attributeconnection - routingalgorithm, only for testing, it is not used.

RouteSimple5

protected void RouteSimple5(Attribute destAttrib,
                            SrcAtt source)
The attributeconnection - routingalgorithm used.

testcalcPrefSize

public void testcalcPrefSize()
Only for testing, never used.

paintTree

protected void paintTree(Graphics g,
                         JTree tree,
                         CellRendererPane crp,
                         TreeCellRenderer tcr,
                         TreeSelectionModel tsm)
Paints this node and (recursively) all nodes beyound this node. Call this method only on the root node.
Parameters:
g - the graphics object of the JTree.
tree - the JTree
crp - the CellRendererPane of the MyTreeUI.
tcr - the TreeCellRenderer to be used.
tsm - the TreeSelectionModel of the Jtree
See Also:
JTree

calcTree

protected int calcTree()
Calculates the x and y position for nodes and the needed height for the whole tree, this value is returned. It calls calcTreeX() on its children. Use this method on the root node. Make sure that calcPrefSize() was called on the root node before! Make sure that calcLineCache() was called on the root node before, if this is an attributed grammar.

getNodeAt

public NodeWrapper getNodeAt(int mx,
                             int my)
Returns the NodeWrapper at the position mx, my [absolute screen coordinates]. Call this method only on the root node!
Parameters:
mx, - my coordinates
Returns:
the nodewrapper node at the giben position or null if there is no node.

getX

public int getX()
Get the x coordinate of this node.
Returns:
the x coordinate [absolute sreen coordinates in pixel] of this node.

getY

public int getY()
Get the y coordinate of this node.
Returns:
the y coordinate [absolute sreen coordinates in pixel] of this node.

getpSize

public Dimension getpSize()
Get the preferred size of this node.
Returns:
the preferred Size of this node.

toString

public String toString()
Only for testing an debugging purpose. Generates a textual representation of a node and from all of it's children.
Overrides:
toString in class Object

getInner

public TreeNode getInner()
Get the encapsulated TreeNode object.
Returns:
the encapsulated TreeNode object.

expand

protected void expand()
Set's the node's expanded flag.

isexpanded

public boolean isexpanded()
See if the node is expanded.
Returns:
true if the node is expanded.

collapse

protected void collapse()
Set the nodes expanded flag to false.

toggleEvent

protected void toggleEvent()
If the node was expanded it is collapsed and vice versa.