bibliothek.gui.dock.station.split
Class Root

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

public class Root
extends SplitNode

The root of the tree that represents the internal structure of a SplitDockStation.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.station.split.SplitNode
height, width, x, y
 
Constructor Summary
Root(SplitDockAccess access)
          Creates a new root.
 
Method Summary
 void evolve(SplitDockTree.Key key)
          Creates or replaces children according to the values found in key.
 SplitNode getChild()
          Gets the child of this root.
 Node getDividerNode(int x, int y)
          Gets the Node whose divider area contains the point x/y.
 double getHeightFactor()
          Gets the factor which has to be multiplied with a relative y coordinate or height to get their size in pixel.
 Insets getInsets()
          Gets the insets which will be free from any Component.
 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, Dockable drop)
          Gets the preferred operation when dragging the Dockable drop to the location x/y.
 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.
protected  Root getRoot()
          Gets the root of the tree in which this node is
 double getWidthFactor()
          Gets the factor which has to be multiplied with relative x coordinates and widths to get their size in pixel.
 SplitNode read(Map<Integer,Dockable> children, DataInputStream in)
          Reads an earlier written node from the stream in.
 void setChild(SplitNode child)
          Sets the child of this root.
 SplitDockTree.Key submit(SplitDockTree tree)
          Writes the contents of this node into tree.
 void updateBounds()
          Updates all locations and sizes of the Components which are in the structure of this tree.
 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.
 void write(Map<Dockable,Integer> children, DataOutputStream out)
          Writes the structure of the subtree with this as root into out.
 
Methods inherited from class bibliothek.gui.dock.station.split.SplitNode
above, create, getAccess, getBounds, getHeight, getParent, getSize, getWidth, getX, getY, intersection, readChild, relativeSidePut, setParent, writeChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Root

public Root(SplitDockAccess access)
Creates a new root.

Parameters:
access - the access to internal methods of the SplitDockStation, must not be null
Method Detail

setChild

public void setChild(SplitNode child)
Sets the child of this root. Every root has only one child.

Parameters:
child - the child of the root, can be null

getChild

public SplitNode getChild()
Gets the child of this root.

Returns:
the child or null
See Also:
setChild(SplitNode)

getRoot

protected Root getRoot()
Description copied from class: SplitNode
Gets the root of the tree in which this node is

Overrides:
getRoot in class SplitNode
Returns:
the root

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

updateBounds

public void updateBounds()
Updates all locations and sizes of the Components which are in the structure of this tree.


getWidthFactor

public double getWidthFactor()
Gets the factor which has to be multiplied with relative x coordinates and widths to get their size in pixel.

Returns:
the horizontal stretch factor

getHeightFactor

public double getHeightFactor()
Gets the factor which has to be multiplied with a relative y coordinate or height to get their size in pixel.

Returns:
the vertical stretch factor

getPut

public PutInfo getPut(int x,
                      int y,
                      Dockable drop)
Gets the preferred operation when dragging the Dockable drop to the location x/y.

Parameters:
x - the x-coordinate of the mouse
y - the y-coordinate of the mouse
drop - the Dockable which will be dropped
Returns:
where to trop the Dockable or null

getInsets

public Insets getInsets()
Gets the insets which will be free from any Component.

Returns:
the insets

evolve

public void evolve(SplitDockTree.Key key)
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

submit

public SplitDockTree.Key submit(SplitDockTree tree)
Description copied from class: SplitNode
Writes the contents of this node into tree.

Specified by:
submit in class SplitNode
Parameters:
tree - the tree to write into
Returns:
the key of this node

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

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

write

public void write(Map<Dockable,Integer> children,
                  DataOutputStream out)
           throws IOException
Description copied from class: SplitNode
Writes the structure of the subtree with this as root into out.

Specified by:
write in class SplitNode
Parameters:
children - a map that contains for every Dockable an id. This id will be written into out to represent the Dockable.
out - the stream to fill
Throws:
IOException - if the stream throws an exception

read

public SplitNode read(Map<Integer,Dockable> children,
                      DataInputStream in)
               throws IOException
Description copied from class: SplitNode
Reads an earlier written node from the stream in.

Specified by:
read in class SplitNode
Parameters:
children - a map of substitutions for ids that are found in the stream.
in - the source
Returns:
the newly created node
Throws:
IOException - if the stream throws an exception
See Also:
SplitNode.write(Map, DataOutputStream)