bibliothek.gui.dock.station.split
Class SplitDockTree

java.lang.Object
  extended by bibliothek.gui.dock.station.split.SplitDockTree

public class SplitDockTree
extends Object

Represents the internal tree of a SplitDockStation. Can be used to exchange the tree of a SplitDockStation. Every node or leaf is represented through a SplitDockTree.Key. Client code may use these keys to read data, or create new branches of the tree.

Author:
Benjamin Sigg

Nested Class Summary
 class SplitDockTree.Key
          A key that represents either a node or a leaf.
 
Constructor Summary
SplitDockTree()
           
 
Method Summary
 SplitDockTree.Key getBottom(SplitDockTree.Key key)
          Gets the bottom element of the node key.
 double getDivider(SplitDockTree.Key key)
          Gets the divider of the node key.
 Dockable[] getDockables()
          Gets a list of all Dockables that are known to this tree.
 Dockable[] getDockables(SplitDockTree.Key key)
          Gets the elements that are represented by the leaf key.
 SplitDockTree.Key getLeft(SplitDockTree.Key key)
          Gets the left element of the node key.
 SplitDockTree.Key getRight(SplitDockTree.Key key)
          Gets the right element of the node key.
 SplitDockTree.Key getRoot()
          Gets the root of the tree.
 Dockable getSelected(SplitDockTree.Key key)
          Gets the element that is selected in this leaf.
 SplitDockTree.Key getTop(SplitDockTree.Key key)
          Gets the top element of the node key.
 SplitDockTree.Key horizontal(Dockable left, Dockable right)
          Adds two elements horizontally.
 SplitDockTree.Key horizontal(Dockable left, Dockable right, double divider)
          Adds two elements horizontally.
 SplitDockTree.Key horizontal(SplitDockTree.Key left, SplitDockTree.Key right)
          Adds two elements horizontally.
 SplitDockTree.Key horizontal(SplitDockTree.Key left, SplitDockTree.Key right, double divider)
          Adds two elements horizontally.
 boolean isDockable(SplitDockTree.Key key)
          Tells whether key represents a leaf or not.
 boolean isHorizontal(SplitDockTree.Key key)
          Tells whether the node key represents a horizontal or a vertical node.
 boolean isNode(SplitDockTree.Key key)
          Tells whether key represents a node or not.
 SplitDockTree.Key put(Dockable... dockables)
          Creates a key for the set dockables.
 SplitDockTree.Key put(Dockable[] dockables, Dockable selected)
          Creates a key for the set dockables.
 SplitDockTree.Key root(Dockable dockable)
          Sets dockable as root, and returns a key to the root.
 SplitDockTree root(SplitDockTree.Key key)
          Sets key as the root of the tree.
 SplitDockTree.Key unroot()
          Removes the root of this tree.
 SplitDockTree.Key vertical(Dockable top, Dockable bottom)
          Adds two elements vertically.
 SplitDockTree.Key vertical(Dockable top, Dockable bottom, double divider)
          Adds two elements vertically.
 SplitDockTree.Key vertical(SplitDockTree.Key top, SplitDockTree.Key bottom)
          Adds two elements vertically.
 SplitDockTree.Key vertical(SplitDockTree.Key top, SplitDockTree.Key bottom, double divider)
          Adds two elements vertically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SplitDockTree

public SplitDockTree()
Method Detail

root

public SplitDockTree.Key root(Dockable dockable)
Sets dockable as root, and returns a key to the root.

Parameters:
dockable - the new root
Returns:
the key to the root

unroot

public SplitDockTree.Key unroot()
Removes the root of this tree.

Returns:
the old root;

root

public SplitDockTree root(SplitDockTree.Key key)
Sets key as the root of the tree. The root must not have a parent.

Parameters:
key - the key which will be the root, null is not allowed.
Returns:
this

put

public SplitDockTree.Key put(Dockable... dockables)
Creates a key for the set dockables.

Parameters:
dockables - the elements for which a key is requested
Returns:
the new key

put

public SplitDockTree.Key put(Dockable[] dockables,
                             Dockable selected)
Creates a key for the set dockables.

Parameters:
dockables - the elements for which a key is requested
selected - the element that should be selected, can be null
Returns:
the new key

horizontal

public SplitDockTree.Key horizontal(Dockable left,
                                    Dockable right)
Adds two elements horizontally.

Parameters:
left - the left element
right - the right element
Returns:
a key of the combination of the two elements

horizontal

public SplitDockTree.Key horizontal(Dockable left,
                                    Dockable right,
                                    double divider)
Adds two elements horizontally.

Parameters:
left - the left element
right - the right element
divider - how much space the first element gets in respect to the second element. Must be between 0 and 1.
Returns:
a key of the combination of the two elements

horizontal

public SplitDockTree.Key horizontal(SplitDockTree.Key left,
                                    SplitDockTree.Key right)
Adds two elements horizontally.

Parameters:
left - the left element
right - the right element
Returns:
a key of the combination of the two elements

horizontal

public SplitDockTree.Key horizontal(SplitDockTree.Key left,
                                    SplitDockTree.Key right,
                                    double divider)
Adds two elements horizontally.

Parameters:
left - the left element
right - the right element
divider - how much space the first element gets in respect to the second element. Must be between 0 and 1.
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(Dockable top,
                                  Dockable bottom)
Adds two elements vertically.

Parameters:
top - the top element
bottom - the bottom element
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(Dockable top,
                                  Dockable bottom,
                                  double divider)
Adds two elements vertically.

Parameters:
top - the top element
bottom - the bottom element
divider - how much space the first element gets in respect to the second element. Must be between 0 and 1.
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(SplitDockTree.Key top,
                                  SplitDockTree.Key bottom)
Adds two elements vertically.

Parameters:
top - the top element
bottom - the bottom element
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(SplitDockTree.Key top,
                                  SplitDockTree.Key bottom,
                                  double divider)
Adds two elements vertically.

Parameters:
top - the top element
bottom - the bottom element
divider - how much space the first element gets in respect to the second element. Must be between 0 and 1.
Returns:
a key of the combination of the two elements

getRoot

public SplitDockTree.Key getRoot()
Gets the root of the tree.

Returns:
the root, can be null

isDockable

public boolean isDockable(SplitDockTree.Key key)
Tells whether key represents a leaf or not.

Parameters:
key - the key to test
Returns:
true if key is a leaf

isNode

public boolean isNode(SplitDockTree.Key key)
Tells whether key represents a node or not.

Parameters:
key - the key to test
Returns:
true if key is a node

getDockables

public Dockable[] getDockables()
Gets a list of all Dockables that are known to this tree.

Returns:
the list of elements

getDockables

public Dockable[] getDockables(SplitDockTree.Key key)
Gets the elements that are represented by the leaf key.

Parameters:
key - the leaf
Returns:
the elements

getSelected

public Dockable getSelected(SplitDockTree.Key key)
Gets the element that is selected in this leaf.

Parameters:
key - the leaf
Returns:
the selected element, can be null

isHorizontal

public boolean isHorizontal(SplitDockTree.Key key)
Tells whether the node key represents a horizontal or a vertical node.

Parameters:
key - the node
Returns:
true if the elements are laid out horizontally, false if the are vertically

getLeft

public SplitDockTree.Key getLeft(SplitDockTree.Key key)
Gets the left element of the node key.

Parameters:
key - the node
Returns:
the left element

getRight

public SplitDockTree.Key getRight(SplitDockTree.Key key)
Gets the right element of the node key.

Parameters:
key - the node
Returns:
the right element

getTop

public SplitDockTree.Key getTop(SplitDockTree.Key key)
Gets the top element of the node key.

Parameters:
key - the node
Returns:
the top element

getBottom

public SplitDockTree.Key getBottom(SplitDockTree.Key key)
Gets the bottom element of the node key.

Parameters:
key - the node
Returns:
the bottom element

getDivider

public double getDivider(SplitDockTree.Key key)
Gets the divider of the node key.

Parameters:
key - the node
Returns:
the divider, a number between 0 and 1