bibliothek.gui.dock.station.split
Class DefaultSplitLayoutManager

java.lang.Object
  extended by bibliothek.gui.dock.station.split.DefaultSplitLayoutManager
All Implemented Interfaces:
SplitLayoutManager
Direct Known Subclasses:
LbSplitLayoutManager

public class DefaultSplitLayoutManager
extends Object
implements SplitLayoutManager

The default implementation of SplitLayoutManager.

Author:
Benjamin Sigg

Constructor Summary
DefaultSplitLayoutManager()
           
 
Method Summary
 void calculateDivider(SplitDockStation station, PutInfo putInfo, Leaf origin)
          Calculates the value a divider should have if the Dockable of putInfo is added alongside of origin.
protected  PutInfo calculateSideSnap(SplitDockStation station, int x, int y, Leaf leaf, Dockable drop)
          Calculates where to add a Dockable if the mouse is outside this station.
 void install(SplitDockStation station)
          Called by a SplitDockStation when this manager will be used by the station.
 PutInfo prepareDrop(SplitDockStation station, int x, int y, int titleX, int titleY, boolean checkOverrideZone, Dockable dockable)
          Call forwarded from DockStation.prepareDrop.
 PutInfo prepareMove(SplitDockStation station, int x, int y, int titleX, int titleY, boolean checkOverrideZone, Dockable dockable)
          Call forwarded from DockStation.prepareMove.
 void uninstall(SplitDockStation station)
          Called by a SplitDockStation which used this manager and no longer does.
 void updateBounds(Root root, double x, double y, double factorW, double factorH)
          Called when the bounds of all DockableDisplayer of a station have to be updated.
protected  double validateDivider(SplitDockStation station, double divider, Dimension minimumLeft, Dimension minimumRight, SplitDockStation.Orientation orientation, double width, double height)
          Tests whether the specified divider-value is legal or not.
 double validateDivider(SplitDockStation station, double divider, Node node)
          Tests whether the specified divider-value is legal or not.
 PutInfo validatePutInfo(SplitDockStation station, PutInfo putInfo)
          Checks whether info is valid or not.
 Dockable willMakeFullscreen(SplitDockStation station, Dockable dockable)
          Called before the station changes its fullscreen-Dockable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultSplitLayoutManager

public DefaultSplitLayoutManager()
Method Detail

install

public void install(SplitDockStation station)
Description copied from interface: SplitLayoutManager
Called by a SplitDockStation when this manager will be used by the station.

Specified by:
install in interface SplitLayoutManager
Parameters:
station - the invoking station

uninstall

public void uninstall(SplitDockStation station)
Description copied from interface: SplitLayoutManager
Called by a SplitDockStation which used this manager and no longer does.

Specified by:
uninstall in interface SplitLayoutManager
Parameters:
station - the invoking station

willMakeFullscreen

public Dockable willMakeFullscreen(SplitDockStation station,
                                   Dockable dockable)
Description copied from interface: SplitLayoutManager
Called before the station changes its fullscreen-Dockable.

Specified by:
willMakeFullscreen in interface SplitLayoutManager
Parameters:
station - the invoking station
dockable - the element which the station wants to make fullscreen, can be null
Returns:
the element which the station will made fullscreen, must either be a child of station or null.

prepareDrop

public PutInfo prepareDrop(SplitDockStation station,
                           int x,
                           int y,
                           int titleX,
                           int titleY,
                           boolean checkOverrideZone,
                           Dockable dockable)
Description copied from interface: SplitLayoutManager
Call forwarded from DockStation.prepareDrop. This method calculates where to drop a new Dockable.

Specified by:
prepareDrop in interface SplitLayoutManager
Parameters:
station - the calling station
x - the x-coordinate of the mouse on the screen
y - the y-coordinate of the mouse on the screen
titleX - the location of the title or x if no title is grabbed
titleY - the location of the title or y if no title is grabbed
checkOverrideZone - whether to respect the override zone of the parent
dockable - the element that might be dropped
Returns:
where to drop dockable or null if the element should not be dropped

prepareMove

public PutInfo prepareMove(SplitDockStation station,
                           int x,
                           int y,
                           int titleX,
                           int titleY,
                           boolean checkOverrideZone,
                           Dockable dockable)
Description copied from interface: SplitLayoutManager
Call forwarded from DockStation.prepareMove. This method calculates where to move a Dockable of station.

Specified by:
prepareMove in interface SplitLayoutManager
Parameters:
station - the calling station
x - the x-coordinate of the mouse on the screen
y - the y-coordinate of the mouse on the screen
titleX - the location of the title or x if no title is grabbed
titleY - the location of the title or y if no title is grabbed
checkOverrideZone - whether to respect the override zone of the parent
dockable - the element that might be dropped
Returns:
where to drop dockable or null if the element should not be dropped

calculateSideSnap

protected PutInfo calculateSideSnap(SplitDockStation station,
                                    int x,
                                    int y,
                                    Leaf leaf,
                                    Dockable drop)
Calculates where to add a Dockable if the mouse is outside this station.

Parameters:
station - the station onto which drop might be dropped
x - The x-coordinate of the mouse
y - The y-coordinate of the mouse
leaf - The leaf which was the old parent of the moved Dockable or null
drop - the element that will be dropped
Returns:
The preferred location or null

calculateDivider

public void calculateDivider(SplitDockStation station,
                             PutInfo putInfo,
                             Leaf origin)
Description copied from interface: SplitLayoutManager
Calculates the value a divider should have if the Dockable of putInfo is added alongside of origin. The result has to be stored directly in putInfo.

Specified by:
calculateDivider in interface SplitLayoutManager
Parameters:
station - the station for which the calculation has to be done
putInfo - the new child of the station
origin - a leaf of this station or null

validateDivider

public double validateDivider(SplitDockStation station,
                              double divider,
                              Node node)
Description copied from interface: SplitLayoutManager
Tests whether the specified divider-value is legal or not.

Specified by:
validateDivider in interface SplitLayoutManager
Parameters:
station - the station for which the divider is calculated
divider - the value of a divider on a Node
node - the Node for which the test is performed
Returns:
a legal value as near as possible to divider

validateDivider

protected double validateDivider(SplitDockStation station,
                                 double divider,
                                 Dimension minimumLeft,
                                 Dimension minimumRight,
                                 SplitDockStation.Orientation orientation,
                                 double width,
                                 double height)
Tests whether the specified divider-value is legal or not.

Parameters:
station - the station for which the divider is intended
divider - the value of a divider on a Node
minimumLeft - the minimal number of pixels on the left or top side of the divider
minimumRight - the minimal number of pixels on the right or bottom side of the divider
orientation - the orientation of the divider
width - the relative width of the base (in respect to the size of this station)
height - the relative height of the base (in respect to the size of this station)
Returns:
a legal value as near as possible to divider

validatePutInfo

public PutInfo validatePutInfo(SplitDockStation station,
                               PutInfo putInfo)
Description copied from interface: SplitLayoutManager
Checks whether info is valid or not.

Specified by:
validatePutInfo in interface SplitLayoutManager
Parameters:
station - the station for which info will be used
putInfo - the preferred drop location
Returns:
a valid PutInfo, info or null.

updateBounds

public void updateBounds(Root root,
                         double x,
                         double y,
                         double factorW,
                         double factorH)
Description copied from interface: SplitLayoutManager
Called when the bounds of all DockableDisplayer of a station have to be updated. Subclasses normally can just call Root.updateBounds(double, double, double, double, double, double, boolean) with width and height set to 1.0.

Specified by:
updateBounds in interface SplitLayoutManager
Parameters:
root - the root of a tree of Dockables
x - the left bound
y - the top bound
factorW - a factor with which all x-coordinates have to be multiplied in order to get coordinates in pixels. 0 if the basic station has no size.
factorH - a factor with which all y-coordinates have to be multiplied in order to get coordinates in pixels. 0 if the basic station has no size.