bibliothek.gui.dock.common
Class CGrid

java.lang.Object
  extended by bibliothek.gui.dock.common.CGrid

public class CGrid
extends Object

A CGrid is a mechanism to layout a set of CDockable on a SplitDockStation like the one used in the center of the CContentArea or on the CWorkingArea. CGrids also can register new CDockables to a CControl.

Usage:
A CGrid consists of a set of entries where each entry consists of a set of CDockables and a rectangle (position= x/y, size=width/height). The rectangle tells where the CDockables and how big they are compared to the other entries.
A client first fills a CGrid with such entries. Then the client calls CGridArea.deploy(CGrid), CWorkingArea.deploy(CGrid) or toTree(). This triggers the CGrid to convert its entries into a tree of Dockables. This tree can then be given to a SplitDockStation. The CGrid can be trashed after it created the tree - changes to the grid will not be forwarded to the tree.

If the CGrid was created using the constructor CGrid(CControl), then the method CControl.addDockable(SingleCDockable) or CControl.addDockable(MultipleCDockable) is called for any new CDockable.

Author:
Benjamin Sigg

Constructor Summary
CGrid()
          Deprecated. Use CGrid(CControl) with an argument of null instead. This method may be removed in a future release.
CGrid(CControl control)
          Creates a new grid.
 
Method Summary
 void add(double x, double y, double width, double height, CDockable... dockables)
          Adds a new set of CDockables to this grid.
 void addHorizontalDivider(double x1, double x2, double y)
          Informs this grid about a horizontal divider that should be inserted into the layout.
 void addMulti(double x, double y, double width, double height, String... identifiers)
          Adds some placeholders for MultipleCDockables to this CGrid.
 void addPlaceholders(double x, double y, double width, double height, Path... placeholders)
          Adds some placeholders to this CGrid.
 void addSingle(double x, double y, double width, double height, String... identifiers)
          Adds some placeholders for SingleCDockables to this CGrid.
 void addVerticalDivider(double x, double y1, double y2)
          Informs this grid about a vertical divider that should be inserted into the layout.
 void select(double x, double y, double width, double height, CDockable dockable)
          Marks dockable as beeing selected in the stack that has the boundaries of x, y, width, height.
 DockableSplitDockTree toTree()
          Creates and returns a tree which contains the CommonDockables of this CGrid.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CGrid

@Deprecated
public CGrid()
Deprecated. Use CGrid(CControl) with an argument of null instead. This method may be removed in a future release.

Creates a new grid.


CGrid

public CGrid(CControl control)
Creates a new grid. If CDockables is not null, then new CDockables will be registered at control. While a value of null is valid, for most clients a non-null value will be the better choice. Please note that some methods will not work if control is null.

Parameters:
control - the control where this grid should register new CDockables, should not be null for most clients
Method Detail

toTree

public DockableSplitDockTree toTree()
Creates and returns a tree which contains the CommonDockables of this CGrid. The branches of the tree are put in a way, that the boundaries of the CommonDockables are respected as good as possible.

Returns:
the contents of this grid as tree

add

public void add(double x,
                double y,
                double width,
                double height,
                CDockable... dockables)
Adds a new set of CDockables to this grid. The CDockables are also added to the CControl of this CGrid.

Parameters:
x - the x-coordinate of the dockables
y - the y-coordinate of the dockables
width - the width of the dockables
height - the height of the dockables
dockables - a list of SingleCDockables and MultipleCDockables.

addSingle

public void addSingle(double x,
                      double y,
                      double width,
                      double height,
                      String... identifiers)
Adds some placeholders for SingleCDockables to this CGrid. This method does not make any checks concerning the validity of the placeholders, the placeholders will however be checked once the CGrid is deployed.
This method will assume that the CPlaceholderStrategy is installed and use the method CPlaceholderStrategy.getSingleDockablePlaceholder(String)
Please note that placeholders are always placed after the real existing CDockables, if order is important then clients must use a CControlPerspective to create the layout. to convert the identifiers into placeholders.

Parameters:
x - the x-coordinate of the dockables
y - the y-coordinate of the dockables
width - the width of the dockables
height - the height of the dockables
identifiers - the identifiers that would be returned by SingleCDockable.getUniqueId()
Throws:
IllegalStateException - if this CGrid does not have access to the a CControl

addMulti

public void addMulti(double x,
                     double y,
                     double width,
                     double height,
                     String... identifiers)
Adds some placeholders for MultipleCDockables to this CGrid. This method does not make any checks concerning the validity of the placeholders, the placeholders will however be checked once the CGrid is deployed.
This method will assume that the CPlaceholderStrategy is installed and use the method CPlaceholderStrategy.getMultipleDockablePlaceholder(String) to convert the identifiers into placeholders.
Please note that placeholders are always placed after the real existing CDockables, if order is important then clients must use a CControlPerspective to create the layout.

Parameters:
x - the x-coordinate of the dockables
y - the y-coordinate of the dockables
width - the width of the dockables
height - the height of the dockables
identifiers - the identifiers that are used when calling CControl.addDockable(String, MultipleCDockable)
Throws:
IllegalStateException - if this CGrid does not have access to the a CControl

addPlaceholders

public void addPlaceholders(double x,
                            double y,
                            double width,
                            double height,
                            Path... placeholders)
Adds some placeholders to this CGrid. This method does not make any checks concerning the validity of the placeholders, the placeholders will however be checked once the CGrid is deployed.
Please note that placeholders are always placed after the real existing CDockables, if order is important then clients must use a CControlPerspective to create the layout.

Parameters:
x - the x-coordinate of the dockables
y - the y-coordinate of the dockables
width - the width of the dockables
height - the height of the dockables
placeholders - the list of new placeholders

select

public void select(double x,
                   double y,
                   double width,
                   double height,
                   CDockable dockable)
Marks dockable as beeing selected in the stack that has the boundaries of x, y, width, height.

Parameters:
x - the x coordinate of the stack
y - the y coordinate of the stack
width - the width of the stack
height - the height of the stack
dockable - the element to select, not null
Throws:
IllegalArgumentException - if dockable is not registered at location x/y/width/height

addHorizontalDivider

public void addHorizontalDivider(double x1,
                                 double x2,
                                 double y)
Informs this grid about a horizontal divider that should be inserted into the layout. There are no guarantees that the divider really is inserted.

Parameters:
x1 - the first x coordinate of the divider
x2 - the second x coordinate of the divider
y - the y coordinate of the divider

addVerticalDivider

public void addVerticalDivider(double x,
                               double y1,
                               double y2)
Informs this grid about a vertical divider that should be inserted into the layout. There are no guarantees that the divider really is inserted.

Parameters:
x - the x coordinate of the divider
y1 - the first y coordinate of the divider
y2 - the second y coordinate of the divider