bibliothek.gui.dock.facile.station.split
Class LockedResizeLayoutManager<T>

java.lang.Object
  extended by bibliothek.gui.dock.facile.station.split.DelegatingSplitLayoutManager
      extended by bibliothek.gui.dock.facile.station.split.LockedResizeLayoutManager<T>
Type Parameters:
T - the type of the temporary data this manager works with
All Implemented Interfaces:
SplitLayoutManager
Direct Known Subclasses:
CLockedResizeLayoutManager

public abstract class LockedResizeLayoutManager<T>
extends DelegatingSplitLayoutManager

A SplitLayoutManager that can lock the size of some Dockables during resize. This class is intended to be subclassed.

Author:
Benjamin Sigg

Constructor Summary
LockedResizeLayoutManager()
          Creates a new manager using the DefaultSplitLayoutManager as delegate.
LockedResizeLayoutManager(SplitLayoutManager delegate)
          Creates a new manager.
 
Method Summary
protected  ResizeElement<T> asyncToElement(ResizeElement<T> parent, SplitNode node)
          Called by toElement(ResizeElement, SplitNode), tries to create a ResizeElement out of node in an environment where race conditions are possible.
 ConflictResolver<T> getConflictResolver()
          Gets the policy that tells how two ResizeRequests are merged.
abstract  ResizeRequest getRequest(T t, Leaf leaf)
          Gets the size request that changes the size of leaf such that it has a valid size again.
protected  boolean hasTreeChanged(Root root)
          Tells whether the current operation happens because the tree has changed (e.g.
protected  boolean isResize(Root root)
          Tells whether the current operation is a resize operation.
abstract  T prepareResize(Leaf leaf)
          Called before the resize takes place, subclasses might store some properties.
 void setConflictResolver(ConflictResolver<T> conflictResolver)
          Sets the ConflictResolver that will determine how to merge ResizeRequests and how to resolve conflicts.
 ResizeElement<T> toElement(ResizeElement<T> parent, SplitNode node)
          Transforms a SplitNode into the matching kind of ResizeElement.
 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.
 void updateBoundsLocked(Root root, double x, double y, double factorW, double factorH)
          Updates the bounds of root and all its children and does consider all ResizeRequest.
 
Methods inherited from class bibliothek.gui.dock.facile.station.split.DelegatingSplitLayoutManager
calculateDivider, install, prepareDrop, prepareMove, uninstall, validateDivider, validatePutInfo, willMakeFullscreen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LockedResizeLayoutManager

public LockedResizeLayoutManager()
Creates a new manager using the DefaultSplitLayoutManager as delegate.


LockedResizeLayoutManager

public LockedResizeLayoutManager(SplitLayoutManager delegate)
Creates a new manager.

Parameters:
delegate - the base functionality
Method Detail

setConflictResolver

public void setConflictResolver(ConflictResolver<T> conflictResolver)
Sets the ConflictResolver that will determine how to merge ResizeRequests and how to resolve conflicts.

Parameters:
conflictResolver - the new policy, not null

getConflictResolver

public ConflictResolver<T> getConflictResolver()
Gets the policy that tells how two ResizeRequests are merged.

Returns:
the policy

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
Overrides:
updateBounds in class DelegatingSplitLayoutManager
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.

isResize

protected boolean isResize(Root root)
Tells whether the current operation is a resize operation. The locked sizes will only be respected if the operation is a resize operation.

Parameters:
root - the item that is going to be updated
Returns:
whether a resize operation is in progress

hasTreeChanged

protected boolean hasTreeChanged(Root root)
Tells whether the current operation happens because the tree has changed (e.g. a leaf has been added or removed). This method is only called if isResize(Root) already returned false.

Parameters:
root - the item that is going to be updated
Returns:
whether the tree has changed

updateBoundsLocked

public void updateBoundsLocked(Root root,
                               double x,
                               double y,
                               double factorW,
                               double factorH)
Updates the bounds of root and all its children and does consider all ResizeRequest.

Parameters:
root - the root element of a tree to update
x - the left coordinate of root
y - the top coordinate of root
factorW - a factor all x-coordinates have to be multiplied with in order to get the pixel coordinates
factorH - a factor all y-coordinates have to be multiplied with in order to get the pixel coordinates

getRequest

public abstract ResizeRequest getRequest(T t,
                                         Leaf leaf)
Gets the size request that changes the size of leaf such that it has a valid size again.

Parameters:
t - the data that was created in prepareResize(Leaf) or null
leaf - the leaf which size is not yet valid.
Returns:
the preferred size or null

prepareResize

public abstract T prepareResize(Leaf leaf)
Called before the resize takes place, subclasses might store some properties.

Parameters:
leaf - some leaf
Returns:
some temporary data that gets forwarded to getRequest(Object, Leaf), can be null

toElement

public ResizeElement<T> toElement(ResizeElement<T> parent,
                                  SplitNode node)
Transforms a SplitNode into the matching kind of ResizeElement. The subtree of node is transformed as well.

Parameters:
parent - the parent of the new element
node - some root, node, leaf or null
Returns:
some root, node, leaf or null

asyncToElement

protected ResizeElement<T> asyncToElement(ResizeElement<T> parent,
                                          SplitNode node)
Called by toElement(ResizeElement, SplitNode), tries to create a ResizeElement out of node in an environment where race conditions are possible. This is a best effort method, callers should check the result using the method ResizeElement.isValid().

Parameters:
parent - the parent of the new element
node - some root, node, leaf or null
Returns:
some root, node, leaf or null