|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.station.split.AbstractSplitDockGrid<D>
D
- the kind of object that represents a Dockable
public 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 . |
protected List<AbstractSplitDockGrid.Line> |
getLines()
Gets a list containing all lines of this grid. |
protected List<AbstractSplitDockGrid.Node<D>> |
getNodes()
Gets a list containing all nodes of 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 . |
protected AbstractSplitDockGrid.Node<D> |
tree()
Transforms the grid into a tree and returns the root. |
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 |
---|
protected abstract D[] array(int size)
size
.
size
- the size of the new array
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 Dockable
s to addpublic 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 addpublic 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 argumentspublic 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 endpointpublic 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()
protected 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 childrenprotected 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 |