net.sf.jtreemap.swing
Class TreeMapNode

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by net.sf.jtreemap.swing.TreeMapNode
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class TreeMapNode
extends javax.swing.tree.DefaultMutableTreeNode

Node of a JTreeMap.
If the node is a branch, only the label is set.
If the node is a leaf, we need a label, a weight and a value.

You can also use a TreeMapNode in a JTree.

See Also:
Serialized Form
 

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
TreeMapNode(java.lang.String label)
          Constructor for a branch.
TreeMapNode(java.lang.String label, double weight, Value value)
          Constructor for a leaf.
 
Method Summary
 void add(TreeMapNode newChild)
          add a new child to the node.
 TreeMapNode getActiveLeaf(int xParam, int yParam)
          get the active leaf.
static int getBorder()
          Get the max border between two nodes of the same level.
 TreeMapNode getChild(int xParam, int yParam)
          get the first child which fits the position.
 java.util.Vector<TreeMapNode> getChildren()
          get a Vector with the children.
 double getDoubleValue()
          get the double Value.
 int getHeight()
          get the height.
 java.lang.String getLabel()
          get the label.
 java.lang.String getLabelValue()
          get the label of the Value.
 Value getValue()
          get the Value.
 double getWeight()
          get the weight.
 int getWidth()
          get the width.
 int getX()
          get the x-coordinate.
 int getY()
          get the y-coordinate.
static void setBorder(int border)
          Set the max border between two nodes of the same level.
 void setDimension(int xParam, int yParam, int widthParam, int heightParam)
          set the position and the size.
 void setHeight(int height)
          set the height.
 void setLabel(java.lang.String label)
          set the label.
 void setPosition(int xParam, int yParam)
          set the position.
 void setSize(int widthParam, int heightParam)
          set size.
 void setValue(Value value)
          set the Value.
 void setWeight(double weight)
          set the weight of the node and update the parents.
 void setWidth(int width)
          set the width.
 void setX(int x)
          set the x-coordinate.
 void setY(int y)
          set the y-coordinate.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TreeMapNode

public TreeMapNode(java.lang.String label)
Constructor for a branch.

Parameters:
label - label of the branch.

TreeMapNode

public TreeMapNode(java.lang.String label,
                   double weight,
                   Value value)
Constructor for a leaf.

Parameters:
label - label of the leaf.
weight - weight of the leaf (if negative, we take the absolute value).
value - Value associée à la feuille
Method Detail

getBorder

public static int getBorder()
Get the max border between two nodes of the same level.

Returns:
Returns the border.

setBorder

public static void setBorder(int border)
Set the max border between two nodes of the same level.

Parameters:
border - The border to set.

add

public void add(TreeMapNode newChild)
add a new child to the node.

Parameters:
newChild - new child

getActiveLeaf

public TreeMapNode getActiveLeaf(int xParam,
                                 int yParam)
get the active leaf.
null if the passed position is not in this tree.

Parameters:
xParam - x-coordinate
yParam - y-coordinate
Returns:
active leaf

getChild

public TreeMapNode getChild(int xParam,
                            int yParam)
get the first child which fits the position.
null if the passed position is not in this tree.

Parameters:
xParam - x-coordinate
yParam - y-coordinate
Returns:
the first child which fits the position.

getChildren

public java.util.Vector<TreeMapNode> getChildren()
get a Vector with the children.

Returns:
Vector with the children

getHeight

public int getHeight()
get the height.

Returns:
the height

getLabel

public java.lang.String getLabel()
get the label.

Returns:
the label

getLabelValue

public java.lang.String getLabelValue()
get the label of the Value.

Returns:
the label of the Value

getValue

public Value getValue()
get the Value.

Returns:
the value

getDoubleValue

public double getDoubleValue()
get the double Value.

Returns:
the double value

getWeight

public double getWeight()
get the weight.

Returns:
the weight

getWidth

public int getWidth()
get the width.

Returns:
the width

getX

public int getX()
get the x-coordinate.

Returns:
the x-coordinate

getY

public int getY()
get the y-coordinate.

Returns:
the y-coordinate

setDimension

public void setDimension(int xParam,
                         int yParam,
                         int widthParam,
                         int heightParam)
set the position and the size.

Parameters:
xParam - x-coordinate
yParam - y-coordinate
widthParam - the new width
heightParam - the new height

setHeight

public void setHeight(int height)
set the height.

Parameters:
height - la nouvelle valeur de height

setLabel

public void setLabel(java.lang.String label)
set the label.

Parameters:
label - the new label

setPosition

public void setPosition(int xParam,
                        int yParam)
set the position.

Parameters:
xParam - x-coordinate
yParam - y-coordinate

setSize

public void setSize(int widthParam,
                    int heightParam)
set size.

Parameters:
widthParam - the new width
heightParam - the new height

setValue

public void setValue(Value value)
set the Value.

Parameters:
value - the new Value

setWeight

public void setWeight(double weight)
set the weight of the node and update the parents.

Parameters:
weight - the new weight

setWidth

public void setWidth(int width)
set the width.

Parameters:
width - la nouvelle valeur de width

setX

public void setX(int x)
set the x-coordinate.

Parameters:
x - the new x-coordinate

setY

public void setY(int y)
set the y-coordinate.

Parameters:
y - the new y-coordinate