bibliothek.gui.dock.station.split
Class SplitDockTree<D>

java.lang.Object
  extended by bibliothek.gui.dock.station.split.SplitDockTree<D>
Type Parameters:
D - the kind of object representing a Dockable
Direct Known Subclasses:
DockableSplitDockTree, PerspectiveSplitDockTree

public abstract class SplitDockTree<D>
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.
Each node in a SplitDockStation has a unique identifier. This SplitDockTree class allows to set this identifier either through SplitDockTree.Key.setNodeId(long) or through the non-complex methods (the methods that create only one new key).

Author:
Benjamin Sigg

Nested Class Summary
 class SplitDockTree.Key
          A key that represents either a node or a leaf.
 
Constructor Summary
SplitDockTree()
           
 
Method Summary
 D[] array(D dockable)
          Creates an array around dockable.
abstract  D[] array(int size)
          Creates a new array of size size for objects of type D.
 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.
 D[] getDockables()
          Gets a list of all Dockables that are known to this tree.
 D[] 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.
 PlaceholderMap getPlaceholderMap(SplitDockTree.Key key)
          Gets the placeholder information of the child DockStation of key.
 Path[] getPlaceholders(SplitDockTree.Key key)
          Gets the placeholders which are associated with key
 SplitDockTree.Key getRight(SplitDockTree.Key key)
          Gets the right element of the node key.
 SplitDockTree.Key getRoot()
          Gets the root of the tree.
 D 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(D left, D right)
          Adds two elements horizontally.
 SplitDockTree.Key horizontal(D left, D 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.
 SplitDockTree.Key horizontal(SplitDockTree.Key left, SplitDockTree.Key right, double divider, long nodeId)
          Adds two elements horizontally.
 SplitDockTree.Key horizontal(SplitDockTree.Key left, SplitDockTree.Key right, double divider, Path[] placeholders, PlaceholderMap placeholderMap, long nodeId)
          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.
 boolean isPlaceholder(SplitDockTree.Key key)
          Tells whether key contains placeholders
 SplitDockTree.Key put(D... dockables)
          Creates a key for the set dockables.
 SplitDockTree.Key put(D[] dockables, D selected)
          Creates a key for the set dockables.
 SplitDockTree.Key put(D[] dockables, D selected, long nodeId)
          Creates a key for the set dockables.
 SplitDockTree.Key put(D[] dockables, D selected, Path[] placeholders, PlaceholderMap placeholderMap, long nodeId)
          Creates a key for the set of dockables or the set of placeholders.
 SplitDockTree.Key put(D dockable, long nodeId)
          Creates a key for the leaf dockable.
 SplitDockTree.Key put(Path[] placeholders, PlaceholderMap placeholderMap)
          Creates a key for a placeholder leaf.
 SplitDockTree.Key put(Path[] placeholders, PlaceholderMap placeholderMap, long nodeId)
          Creates a key for a placeholder leaf.
 SplitDockTree.Key root(D dockable)
          Sets dockable as root, and returns a key to the root.
 SplitDockTree<D> root(SplitDockTree.Key key)
          Sets key as the root of the tree.
 String toString()
           
 SplitDockTree.Key unroot()
          Removes the root of this tree.
 SplitDockTree.Key vertical(D top, D bottom)
          Adds two elements vertically.
 SplitDockTree.Key vertical(D top, D 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.
 SplitDockTree.Key vertical(SplitDockTree.Key top, SplitDockTree.Key bottom, double divider, long nodeId)
          Adds two elements vertically.
 SplitDockTree.Key vertical(SplitDockTree.Key top, SplitDockTree.Key bottom, double divider, Path[] placeholders, PlaceholderMap placeholderMap, long nodeId)
          Adds two elements vertically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SplitDockTree

public SplitDockTree()
Method Detail

array

public abstract D[] array(int size)
Creates a new array of size size for objects of type D.

Parameters:
size - the size of the array
Returns:
the new array

array

public D[] array(D dockable)
Creates an array around dockable.

Parameters:
dockable - the element that should be put into an array
Returns:
the array of length 1

root

public SplitDockTree.Key root(D 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<D> 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(D dockable,
                             long nodeId)
Creates a key for the leaf dockable.

Parameters:
dockable - the element for which a key is requested
nodeId - the unique identifier for this node, can be -1
Returns:
the new key

put

public SplitDockTree.Key put(D... 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(D[] dockables,
                             D 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

put

public SplitDockTree.Key put(D[] dockables,
                             D selected,
                             long nodeId)
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
nodeId - a unique identifier for this node, may be -1
Returns:
the new key

put

public SplitDockTree.Key put(Path[] placeholders,
                             PlaceholderMap placeholderMap)
Creates a key for a placeholder leaf.

Parameters:
placeholders - the placeholders to store
placeholderMap - placeholder information of a child DockStation
Returns:
the new key

put

public SplitDockTree.Key put(Path[] placeholders,
                             PlaceholderMap placeholderMap,
                             long nodeId)
Creates a key for a placeholder leaf.

Parameters:
placeholders - the placeholders to store
placeholderMap - placeholder information of a child DockStation
nodeId - the unique identifier of the new node, can be -1
Returns:
the new key

put

public SplitDockTree.Key put(D[] dockables,
                             D selected,
                             Path[] placeholders,
                             PlaceholderMap placeholderMap,
                             long nodeId)
Creates a key for the set of dockables or the set of placeholders.

Parameters:
dockables - the elements for which a key is requested
selected - the element that should be selected, can be null
placeholders - the placeholders for which a key is requested
placeholderMap - placeholder information of a child DockStation
nodeId - a unique identifier for this node, may be -1
Returns:
the new key

horizontal

public SplitDockTree.Key horizontal(D left,
                                    D 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(D left,
                                    D 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

horizontal

public SplitDockTree.Key horizontal(SplitDockTree.Key left,
                                    SplitDockTree.Key right,
                                    double divider,
                                    long nodeId)
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.
nodeId - a unique identifier for this node, may be -1
Returns:
a key of the combination of the two elements

horizontal

public SplitDockTree.Key horizontal(SplitDockTree.Key left,
                                    SplitDockTree.Key right,
                                    double divider,
                                    Path[] placeholders,
                                    PlaceholderMap placeholderMap,
                                    long nodeId)
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.
placeholders - placeholders that are associated with this nodes
placeholderMap - placeholder information of a child DockStation
nodeId - a unique identifier for this node, may be -1
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(D top,
                                  D 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(D top,
                                  D 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

vertical

public SplitDockTree.Key vertical(SplitDockTree.Key top,
                                  SplitDockTree.Key bottom,
                                  double divider,
                                  long nodeId)
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.
nodeId - a unique identifier for this node, may be -1
Returns:
a key of the combination of the two elements

vertical

public SplitDockTree.Key vertical(SplitDockTree.Key top,
                                  SplitDockTree.Key bottom,
                                  double divider,
                                  Path[] placeholders,
                                  PlaceholderMap placeholderMap,
                                  long nodeId)
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.
placeholders - placeholders that are associated with this node
placeholderMap - placeholder information of a child DockStation
nodeId - a unique identifier for this node, may be -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

isPlaceholder

public boolean isPlaceholder(SplitDockTree.Key key)
Tells whether key contains placeholders

Parameters:
key - some node or leaf
Returns:
true if there are placeholders

getPlaceholders

public Path[] getPlaceholders(SplitDockTree.Key key)
Gets the placeholders which are associated with key

Parameters:
key - some node or leaf
Returns:
the placeholders, can be null

getPlaceholderMap

public PlaceholderMap getPlaceholderMap(SplitDockTree.Key key)
Gets the placeholder information of the child DockStation of key.

Parameters:
key - some node or leaf
Returns:
the placeholder information, can be null

getDockables

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

Returns:
the list of elements

getDockables

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

Parameters:
key - the leaf
Returns:
the elements, can be null

getSelected

public D 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

toString

public String toString()
Overrides:
toString in class Object