net.sf.jtreemap.swing
Class SplitStrategy

java.lang.Object
  extended by net.sf.jtreemap.swing.SplitStrategy
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
SplitByNumber, SplitBySlice, SplitBySortedWeight, SplitByWeight, SplitSquarified

public abstract class SplitStrategy
extends java.lang.Object
implements java.io.Serializable

Abtract class with the method which split the elements of a JTreeMap.

The split is done by dichotomy. We split the elements in 2 groups with a defined strategy (for example : take care of the weight of the elements)

See Also:
Serialized Form
 

Constructor Summary
SplitStrategy()
           
 
Method Summary
 void calculatePositions(TreeMapNode root)
          calculate the positions for all the elements of the root.
protected  void calculatePositionsRec(int x0, int y0, int w0, int h0, double weight0, java.util.Vector<TreeMapNode> v)
           
protected  void sortVector(java.util.Vector<TreeMapNode> v)
          Sort the elements by descending weight.
abstract  void splitElements(java.util.Vector<TreeMapNode> v, java.util.Vector<TreeMapNode> v1, java.util.Vector<TreeMapNode> v2)
          split the elements of a JTreeMap.
 double sumWeight(java.util.Vector<TreeMapNode> v)
          Sum the weight of elements.
protected  void workOutWeight(java.util.Vector<TreeMapNode> v1, java.util.Vector<TreeMapNode> v2, java.util.Vector<TreeMapNode> vClone, double sumWeight)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitStrategy

public SplitStrategy()
Method Detail

calculatePositions

public void calculatePositions(TreeMapNode root)
calculate the positions for all the elements of the root.

Parameters:
root - the root to calculate

splitElements

public abstract void splitElements(java.util.Vector<TreeMapNode> v,
                                   java.util.Vector<TreeMapNode> v1,
                                   java.util.Vector<TreeMapNode> v2)
split the elements of a JTreeMap.

Parameters:
v - Vector with the elements to split (arg IN)
v1 - first Vector of the split (arg OUT)
v2 - second Vector of the split (arg OUT)

sumWeight

public double sumWeight(java.util.Vector<TreeMapNode> v)
Sum the weight of elements.
You can override this method if you want to apply a coef on the weights or to cancel the effect of weight on the strategy.

Parameters:
v - Vector with the elements to sum
Returns:
the sum of the weight of elements

calculatePositionsRec

protected void calculatePositionsRec(int x0,
                                     int y0,
                                     int w0,
                                     int h0,
                                     double weight0,
                                     java.util.Vector<TreeMapNode> v)

sortVector

protected void sortVector(java.util.Vector<TreeMapNode> v)
Sort the elements by descending weight.

Parameters:
v - Vector with the elements to be sorted

workOutWeight

protected void workOutWeight(java.util.Vector<TreeMapNode> v1,
                             java.util.Vector<TreeMapNode> v2,
                             java.util.Vector<TreeMapNode> vClone,
                             double sumWeight)