|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectbibliothek.gui.dock.station.split.AbstractSplitDockGrid<D>
D - the kind of object that represents a Dockablepublic abstract class AbstractSplitDockGrid<D>
A class that provides a grid for representations of Dockables. The grid can
be transformed into a SplitDockTree which has values that would
layout the components as they are in the grid. The algorithms used in this
class can handle overlapping elements and holes, however results are much better
if there are no disturbances in the grid.
There is also a possibility to tell the tree, where dividers should be made.
SplitDockStation.dropTree(SplitDockTree)| Nested Class Summary | |
|---|---|
protected static class |
AbstractSplitDockGrid.Line
Represents a dividing line in the grid. |
protected static class |
AbstractSplitDockGrid.Node<D>
Represents a node in the tree which will be built. |
| Constructor Summary | |
|---|---|
AbstractSplitDockGrid()
Creates a new, empty grid. |
|
AbstractSplitDockGrid(String layout,
Map<Character,D[]> dockables)
Creates a grid by reading a string which represents a grid. The argument layout is a string divided by newline
"\n". |
|
| Method Summary | |
|---|---|
void |
addDockable(double x,
double y,
double width,
double height,
D... dockables)
Adds dockable to the grid. |
void |
addHorizontalDivider(double x1,
double x2,
double y)
Adds a horizonal dividing line. |
void |
addPlaceholders(double x,
double y,
double width,
double height,
Path... placeholders)
Adds placeholders to the grid. |
void |
addVerticalDivider(double x,
double y1,
double y2)
Adds a vertical dividing line. |
protected abstract D[] |
array(int size)
Creates a D-array of length size. |
protected AbstractSplitDockGrid.Line |
bestFittingLine(double x,
double y,
double w,
double h,
boolean horizontal,
double split)
Searches the line that divides the rectangle x, y, width, height
best. |
protected AbstractSplitDockGrid.Node<D> |
combine(AbstractSplitDockGrid.Node<D> a,
AbstractSplitDockGrid.Node<D> b)
Creates a combination of a and b. |
protected double |
diff(AbstractSplitDockGrid.Node<D> a,
AbstractSplitDockGrid.Node<D> b)
Tells whether the two nodes could be merged or not. |
protected void |
fillTree(SplitDockTree<D> tree)
Fills the contents of this grid into tree. |
D[] |
getDockables(double x,
double y,
double width,
double height)
Gets all the dockables that were added
to this grid at location x,y,width,height |
List<GridNode<D>> |
getGridNodes()
Gets all the nodes of this grid. |
protected List<AbstractSplitDockGrid.Line> |
getLines()
Gets a list containing all lines of this grid. |
protected AbstractSplitDockGrid.Node<D> |
getNode(D dockable)
Gets the one node containing dockable. |
protected List<AbstractSplitDockGrid.Node<D>> |
getNodes()
Gets a list containing all nodes of this grid. |
boolean |
isUnpack()
Tells whether unpack(double, double, double, double) is called automatically before adding new Dockables
to this grid. |
protected double |
penalty(double x,
double y,
double w,
double h,
AbstractSplitDockGrid.Line line)
Used by diff
to add a penalty if a line hits a rectangle. |
void |
setPlaceholderMap(double x,
double y,
double width,
double height,
PlaceholderMap map)
Sets the PlaceholderMap map for the items at the given location. |
void |
setSelected(double x,
double y,
double width,
double height,
D dockable)
Marks dockable as selected in the stack of elements that
are on position x, y, width, height. |
void |
setUnpack(boolean unpack)
Whether to automatically call unpack(double, double, double, double) before adding any new Dockables
to this grid. |
protected AbstractSplitDockGrid.Node<D> |
tree()
Transforms the grid into a tree and returns the root. |
protected abstract D[] |
unpack(D dockable)
Unpacks dockable. |
void |
unpack(double x,
double y,
double width,
double height)
Unpacks any existing DockStation at location x,y,width,height. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractSplitDockGrid()
public AbstractSplitDockGrid(String layout,
Map<Character,D[]> dockables)
layout is a string divided by newline
"\n". Every line represents a y-coordinate, the position
of a character in a line represents a x-coordinate. The minimal and
the maximal x- and y-coordinates for a character is searched, and
used to call addDockable,
where the Dockable-array is taken from the Map
dockables.
layout - the layout, a string divided by newlinesdockables - the Dockables to add, only entries whose character is
in the String layout.| Method Detail |
|---|
public void setUnpack(boolean unpack)
unpack(double, double, double, double) before adding any new Dockables
to this grid. Default: true.
unpack - whether to unpack automaticallypublic boolean isUnpack()
unpack(double, double, double, double) is called automatically before adding new Dockables
to this grid.
unpack(double, double, double, double) is calledprotected abstract D[] array(int size)
size.
size - the size of the new array
public void unpack(double x,
double y,
double width,
double height)
DockStation at location x,y,width,height. All children
of all DockStations are removed and re-added as if addDockable(double, double, double, double, Object...)
would have been called multiple times.
x - the x-coordinatey - the y-coordinatewidth - the width, more than 0height - the height, more than 0protected abstract D[] unpack(D dockable)
dockable. Unpacking means converting dockable in something like a DockStation
and returning all the children Dockables.
dockable - the dockable to unpack
dockable or all its children
public D[] getDockables(double x,
double y,
double width,
double height)
added
to this grid at location x,y,width,height
x - the x-coordinatey - the y-coordinatewidth - the width, more than 0height - the height, more than 0
null if there are no dockables at this location
public void addDockable(double x,
double y,
double width,
double height,
D... dockables)
dockable to the grid. The coordinates are not absolute,
only the relative location and size matters. If there are already
dockables at the exact same location, then
the dockables are stacked.
x - the x-coordinatey - the y-coordinatewidth - the width, more than 0height - the height, more than 0dockables - the Dockables to add
public void addPlaceholders(double x,
double y,
double width,
double height,
Path... placeholders)
placeholders to the grid. The coordinates are not absolute,
only the relative location and size matters. If there are already items at the exact same location, then
the new placeholders are just added to them.
x - the x-coordinatey - the y-coordinatewidth - the width, more than 0height - the height, more than 0placeholders - the new placeholders to add
public void setPlaceholderMap(double x,
double y,
double width,
double height,
PlaceholderMap map)
PlaceholderMap map for the items at the given location. The map may be used
if a DockStation is creating during runtime at this location.
x - the x coordinatey - the y coordinatewidth - the width of the elementsheight - the height of the elementsmap - the map, can be null
IllegalArgumentException - if there is no node at x/y/width/height
public void setSelected(double x,
double y,
double width,
double height,
D dockable)
dockable as selected in the stack of elements that
are on position x, y, width, height. This method requires
that add
was called with the exact same coordinates and with dockable.
x - the x coordinatey - the y coordinatewidth - the width of the elementsheight - the height of the elementsdockable - the element to select, not null
IllegalArgumentException - if width or height
are below 0, if dockable is null, if
add
was never called with the arguments
public void addVerticalDivider(double x,
double y1,
double y2)
x - the x-coordinate of the liney1 - the y-coordinate of the first endpointy2 - the y-coordinate of the second endpoint
public void addHorizontalDivider(double x1,
double x2,
double y)
x1 - the x-coordinate of the first endpointx2 - the x-coordinate of the second endpointy - the y-coordinate of the lineprotected void fillTree(SplitDockTree<D> tree)
tree.
tree - the tree to fillprotected List<AbstractSplitDockGrid.Line> getLines()
protected List<AbstractSplitDockGrid.Node<D>> getNodes()
public List<GridNode<D>> getGridNodes()
Ds
and their location.
protected AbstractSplitDockGrid.Node<D> getNode(D dockable)
dockable. This method checks for
equality using the == operation.
dockable - the item to search
null if not foundprotected AbstractSplitDockGrid.Node<D> tree()
null
protected AbstractSplitDockGrid.Node<D> combine(AbstractSplitDockGrid.Node<D> a,
AbstractSplitDockGrid.Node<D> b)
a and b.
a - the first nodeb - the second node
a and b as children
protected double diff(AbstractSplitDockGrid.Node<D> a,
AbstractSplitDockGrid.Node<D> b)
a - the first nodeb - the second node
protected AbstractSplitDockGrid.Line bestFittingLine(double x,
double y,
double w,
double h,
boolean horizontal,
double split)
x, y, width, height
best.
x - the x-coordinate of the rectangley - the y-coordinate of the rectanglew - the width of the rectangleh - the height of the rectanglehorizontal - whether the line should be horizontal or notsplit - the preferred value of AbstractSplitDockGrid.Line.alpha.
null
protected double penalty(double x,
double y,
double w,
double h,
AbstractSplitDockGrid.Line line)
diff
to add a penalty if a line hits a rectangle.
x - the x-coordinate of the rectangley - the y-coordinate of the rectanglew - the width of the rectangleh - the height of the rectangleline - the line which may hit the rectangle
diff.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||