|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.station.split.SplitDockGrid
public class SplitDockGrid
A class that provides a grid for 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.
toTree()
,
SplitDockStation.dropTree(SplitDockTree)
Nested Class Summary | |
---|---|
protected static class |
SplitDockGrid.Line
Represents a dividing line in the grid. |
protected static class |
SplitDockGrid.Node
Represents a node in the tree which will be built. |
Constructor Summary | |
---|---|
SplitDockGrid()
Creates a new, empty grid. |
|
SplitDockGrid(String layout,
Map<Character,Dockable[]> dockables)
Creates a grid by reading a string which represents a grid. |
Method Summary | |
---|---|
void |
addDockable(double x,
double y,
double width,
double height,
Dockable... dockables)
Adds dockable to the grid. |
void |
addHorizontalDivider(double x1,
double x2,
double y)
Adds a horizonal dividing line. |
void |
addVerticalDivider(double x,
double y1,
double y2)
Adds a vertical dividing line. |
protected SplitDockGrid.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 SplitDockGrid.Node |
combine(SplitDockGrid.Node a,
SplitDockGrid.Node b)
Creates a combination of a and b . |
protected double |
diff(SplitDockGrid.Node a,
SplitDockGrid.Node b)
Tells whether the two nodes could be merged or not. |
protected List<SplitDockGrid.Line> |
getLines()
Gets a list containing all lines of this grid. |
protected List<SplitDockGrid.Node> |
getNodes()
Gets a list containing all nodes of this grid. |
protected double |
penalty(double x,
double y,
double w,
double h,
SplitDockGrid.Line line)
Used by diff
to calculate add a penalty if a line hits a rectangle. |
void |
setSelected(double x,
double y,
double width,
double height,
Dockable dockable)
Marks dockable as selected in the stack of elements that
are on position x, y, width, height . |
SplitDockTree |
toTree()
Converts the current grid into a tree. |
protected SplitDockGrid.Node |
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 SplitDockGrid()
public SplitDockGrid(String layout, Map<Character,Dockable[]> 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 addDockable(double x, double y, double width, double height, Dockable... 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 setSelected(double x, double y, double width, double height, Dockable 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 linepublic SplitDockTree toTree()
SplitDockStation.dropTree(SplitDockTree)
protected List<SplitDockGrid.Line> getLines()
protected List<SplitDockGrid.Node> getNodes()
protected SplitDockGrid.Node tree()
null
protected SplitDockGrid.Node combine(SplitDockGrid.Node a, SplitDockGrid.Node b)
a
and b
.
a
- the first nodeb
- the second node
a
and b
as childrenprotected double diff(SplitDockGrid.Node a, SplitDockGrid.Node b)
a
- the first nodeb
- the second node
protected SplitDockGrid.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 SplitDockGrid.Line.alpha
.
null
protected double penalty(double x, double y, double w, double h, SplitDockGrid.Line line)
diff
to calculate 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 |