net.sf.jtreemap.ktreemap
Class TreeMapNode

java.lang.Object
  extended by net.sf.jtreemap.ktreemap.TreeMapNode

public class TreeMapNode
extends java.lang.Object

Node of a KTreeMap.
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.

 

Constructor Summary
TreeMapNode(java.lang.Object value)
          Constructor for a branch
TreeMapNode(java.lang.Object value, double weight)
          Constructor for a leaf.
 
Method Summary
 void add(TreeMapNode newChild)
          add a new child to the node.
 TreeMapNode getActiveLeaf(int x, int y)
          get the active leaf.
 TreeMapNode getActiveLeaf(org.eclipse.swt.graphics.Point position)
          get the active leaf.
static int getBorder()
          Get the max border between two nodes of the same level.
 org.eclipse.swt.graphics.Rectangle getBounds()
           
 TreeMapNode getChild(int x, int y)
          get the first child which fits the position.
 TreeMapNode getChild(org.eclipse.swt.graphics.Point position)
          get the first child which fits the position.
 java.util.List<TreeMapNode> getChildren()
          get a List with the children.
 int getHeight()
          get the height.
 TreeMapNode getParent()
           
 java.lang.Object 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.
 boolean isLeaf()
           
static void setBorder(int border)
          Set the max border between two nodes of the same level.
 void setBounds(org.eclipse.swt.graphics.Rectangle bounds)
          set the position and the size.
 void setHeight(int height)
          set the height.
protected  void setParent(TreeMapNode parent)
           
 void setPosition(int x, int y)
          set the position.
 void setSize(int width, int height)
          set size.
 void setValue(java.lang.Object 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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TreeMapNode

public TreeMapNode(java.lang.Object value)
Constructor for a branch

Parameters:
value - value of the TreeMapNode

TreeMapNode

public TreeMapNode(java.lang.Object value,
                   double weight)
Constructor for a leaf.

Parameters:
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 x,
                                 int y)
get the active leaf.
null if the passed position is not in this tree.

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

getActiveLeaf

public TreeMapNode getActiveLeaf(org.eclipse.swt.graphics.Point position)
get the active leaf.
null if the passed position is not in this tree.

Parameters:
position - position
Returns:
active leaf

getBounds

public org.eclipse.swt.graphics.Rectangle getBounds()
Returns:
the bounds of the KTreeMap

getChild

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

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

getChild

public TreeMapNode getChild(org.eclipse.swt.graphics.Point position)
get the first child which fits the position.
null if the passed position is not in this tree.

Parameters:
position - position
Returns:
the first child which fits the position.

getChildren

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

Returns:
List with the children

getHeight

public int getHeight()
get the height.

Returns:
the height

getValue

public java.lang.Object getValue()
get the Value.

Returns:
the 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

isLeaf

public boolean isLeaf()
Returns:
true if the TreeMapNode is a leaf

setBounds

public void setBounds(org.eclipse.swt.graphics.Rectangle bounds)
set the position and the size.

Parameters:
bounds - bounds

setHeight

public void setHeight(int height)
set the height.

Parameters:
height - la nouvelle valeur de height

setPosition

public void setPosition(int x,
                        int y)
set the position.

Parameters:
x - x-coordinate
y - y-coordinate

setSize

public void setSize(int width,
                    int height)
set size.

Parameters:
width - the new width
height - the new height

setValue

public void setValue(java.lang.Object 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

getParent

public TreeMapNode getParent()
Returns:
the parent

setParent

protected void setParent(TreeMapNode parent)
Parameters:
parent - the parent to set