bibliothek.gui.dock.station.split
Class Leaf

java.lang.Object
  extended by bibliothek.gui.dock.station.split.SplitNode
      extended by bibliothek.gui.dock.station.split.Leaf

public class Leaf
extends SplitNode

Represents a leaf in the tree that is the structure of a SplitDockStation. A leaf also represents a single Dockable which is shown on the owner-station.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.station.split.SplitNode
height, width, x, y
 
Constructor Summary
Leaf(SplitDockAccess access)
          Creates a new leaf.
Leaf(SplitDockAccess access, DockableDisplayer displayer)
          Creates a new leaf.
 
Method Summary
 void evolve(SplitDockTree.Key key, boolean checkValidity)
          Creates or replaces children according to the values found in key.
 DockableDisplayer getDisplayer()
          Gets the displayer of this leaf.
 Node getDividerNode(int x, int y)
          Gets the Node whose divider area contains the point x/y.
 Dockable getDockable()
          Gets the Dockable which is shown on the displayer of this leaf.
 Leaf getLeaf(Dockable dockable)
          Gets the leaf which represents dockable.
 Dimension getMinimumSize()
          Gets the minimal size of this node.
 PutInfo getPut(int x, int y, double factorW, double factorH, Dockable drop)
          Determines where to drop the Dockable drop if the mouse is at location x/y.
 boolean insert(SplitDockPathProperty property, int depth, Dockable dockable)
          If there are elements left in property, then the next node is to be read and the insert-method of the matching child to be called.
If there are no children, then dockable has to be inserted as new child.
Otherwise this element is to be replaced by a node containing this and the a leaf with dockable.
Subclasses may wary this scheme in order to optimize or to find a better place for the dockable.
 boolean isInOverrideZone(int x, int y, double factorW, double factorH)
          Tells whether the coordinates x/y lie inside the override-zone of the SplitDockStation or not.
 void replace(SplitNode old, SplitNode child)
          Replaces a child of this node by child.
 void setDisplayer(DockableDisplayer displayer)
          Sets the displayer whose size and location will be determined by this leaf.
<N> N
submit(SplitTreeFactory<N> factory)
          Writes the contents of this node into a new tree create by factory.
 void updateBounds(double x, double y, double width, double height, double factorW, double factorH)
          Updates the bounds of this node.
 void visit(SplitNodeVisitor visitor)
          Invokes one of the methods of the visitor for every child in the subtree with this as root.
 
Methods inherited from class bibliothek.gui.dock.station.split.SplitNode
above, create, create, getAccess, getBounds, getHeight, getParent, getRoot, getSize, getWidth, getX, getY, intersection, relativeSidePut, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Leaf

public Leaf(SplitDockAccess access)
Creates a new leaf.

Parameters:
access - the access to the private functions of the owning SplitDockStation

Leaf

public Leaf(SplitDockAccess access,
            DockableDisplayer displayer)
Creates a new leaf.

Parameters:
access - the access to the private functions of the owning SplitDockStation
displayer - the displayer whose size and location will be determined by this leaf.
Method Detail

getMinimumSize

public Dimension getMinimumSize()
Description copied from class: SplitNode
Gets the minimal size of this node.

Specified by:
getMinimumSize in class SplitNode
Returns:
the minimal size in pixel

setDisplayer

public void setDisplayer(DockableDisplayer displayer)
Sets the displayer whose size and location will be determined by this leaf.

Parameters:
displayer - the displayer, must not be null

replace

public void replace(SplitNode old,
                    SplitNode child)
Description copied from class: SplitNode
Replaces a child of this node by child.

Specified by:
replace in class SplitNode
Parameters:
old - the old child
child - the replacement for old

getDisplayer

public DockableDisplayer getDisplayer()
Gets the displayer of this leaf.

Returns:
the displayer
See Also:
setDisplayer(DockableDisplayer)

getDockable

public Dockable getDockable()
Gets the Dockable which is shown on the displayer of this leaf.

Returns:
the Dockable

updateBounds

public void updateBounds(double x,
                         double y,
                         double width,
                         double height,
                         double factorW,
                         double factorH)
Description copied from class: SplitNode
Updates the bounds of this node. If the node represents a Component, then the bounds of the component have to be updated as well.

Overrides:
updateBounds in class SplitNode
Parameters:
x - the relative x-coordinate
y - the relative y-coordinate
width - the relative width of the node
height - the relative height of the node
factorW - a factor to be multiplied with x and width to get the size of the node in pixel
factorH - a factor to be multiplied with y and height to get the size of the node in pixel

getPut

public PutInfo getPut(int x,
                      int y,
                      double factorW,
                      double factorH,
                      Dockable drop)
Description copied from class: SplitNode
Determines where to drop the Dockable drop if the mouse is at location x/y.

Specified by:
getPut in class SplitNode
Parameters:
x - the x-coordinate of the mouse
y - the y-coordinate of the mouse
factorW - a factor to be multiplied with the relative x and width to get the size in pixel.
factorH - a factor to be multiplied with the relative y and height to get the size in pixel.
drop - the Dockable which will be dropped
Returns:
where to drop the dockable or null if the dockable can't be dropped

isInOverrideZone

public boolean isInOverrideZone(int x,
                                int y,
                                double factorW,
                                double factorH)
Description copied from class: SplitNode
Tells whether the coordinates x/y lie inside the override-zone of the SplitDockStation or not.

Specified by:
isInOverrideZone in class SplitNode
Parameters:
x - the x-coordinate of the mouse
y - the y-coordinate of the mouse
factorW - a factor to be multiplied with the relative x and width to get the size in pixel.
factorH - a factor to be multiplied with the relative y and height to get the size in pixel.
Returns:
true if the station should not allow child-stations to make a drop when the mouse is at x/y

evolve

public void evolve(SplitDockTree.Key key,
                   boolean checkValidity)
Description copied from class: SplitNode
Creates or replaces children according to the values found in key.

Specified by:
evolve in class SplitNode
Parameters:
key - the key to read
checkValidity - whether to ensure that all new Dockables are acceptable or not.

insert

public boolean insert(SplitDockPathProperty property,
                      int depth,
                      Dockable dockable)
Description copied from class: SplitNode
If there are elements left in property, then the next node is to be read and the insert-method of the matching child to be called.
If there are no children, then dockable has to be inserted as new child.
Otherwise this element is to be replaced by a node containing this and the a leaf with dockable.
Subclasses may wary this scheme in order to optimize or to find a better place for the dockable.

Specified by:
insert in class SplitNode
Parameters:
property - a list of nodes
depth - the index of the node that corresponds to this
dockable - the element to insert
Returns:
true if the element was inserted, false otherwise

submit

public <N> N submit(SplitTreeFactory<N> factory)
Description copied from class: SplitNode
Writes the contents of this node into a new tree create by factory.

Specified by:
submit in class SplitNode
Type Parameters:
N - the type of element the factory will create
Parameters:
factory - the factory transforming the elements of the tree into a new form.
Returns:
the representation of this node

getLeaf

public Leaf getLeaf(Dockable dockable)
Description copied from class: SplitNode
Gets the leaf which represents dockable.

Specified by:
getLeaf in class SplitNode
Parameters:
dockable - the Dockable whose leaf is searched
Returns:
the leaf or null if no leaf was found

getDividerNode

public Node getDividerNode(int x,
                           int y)
Description copied from class: SplitNode
Gets the Node whose divider area contains the point x/y. Only searches in the subtree with this node as root.

Specified by:
getDividerNode in class SplitNode
Parameters:
x - the x-coordinate
y - the y-coordinate
Returns:
the Node containing the point, if no Node was found, null is returned

visit

public void visit(SplitNodeVisitor visitor)
Description copied from class: SplitNode
Invokes one of the methods of the visitor for every child in the subtree with this as root.

Specified by:
visit in class SplitNode
Parameters:
visitor - the visitor