|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object bibliothek.gui.dock.station.split.SplitNode
public abstract class SplitNode
The internal representation of a SplitDockStation
is a tree. The subclasses of SplitNode build this tree.
Field Summary | |
---|---|
protected double |
height
Bounds of this node on the station |
protected double |
width
Bounds of this node on the station |
protected double |
x
Bounds of this node on the station |
protected double |
y
Bounds of this node on the station |
Constructor Summary | |
---|---|
protected |
SplitNode(SplitDockAccess access,
long id)
Creates a new SplitNode. |
Method Summary | ||
---|---|---|
static boolean |
above(double x1,
double y1,
double x2,
double y2,
double x,
double y)
Calculates whether the point x/y lies above
the line going through x1/y1 and x2/y2 . |
|
void |
addPlaceholder(Path placeholder)
Stores an additional placeholder in this node. |
|
protected Leaf |
create(Dockable dockable,
long id)
Creates a leaf for dockable . |
|
protected SplitNode |
create(SplitDockTree.Key key,
boolean checkValidity,
Map<Leaf,Dockable> linksToSet)
Creates a new node using the contents of key . |
|
Leaf |
createLeaf(long id)
Creates a new Leaf |
|
Node |
createNode(long id)
Creates a new Node . |
|
Placeholder |
createPlaceholder(long id)
Creates a new Placeholder calling SplitDockAccess.createPlaceholder(long) |
|
void |
delete(boolean shrink)
Removes this node from its parent, if there is a parent. |
|
protected void |
ensureIdUnique()
Recursively visits all children of this SplitNode and ensures that no
node has the same unique id. |
|
protected void |
ensureIdUniqueAsync()
Schedules a call to ensureIdUnique() of the Root node. |
|
abstract void |
evolve(SplitDockTree.Key key,
boolean checkValidity,
Map<Leaf,Dockable> linksToSet)
Creates or replaces children according to the values found in key . |
|
protected SplitDockAccess |
getAccess()
Gets access to the owner-station |
|
Rectangle |
getBounds()
Gets the size and location of this node in pixel where the point 0/0 is equal to the point 0/0 on the owner-station. |
|
abstract SplitNode |
getChild(int location)
Gets the child at location . |
|
abstract int |
getChildLocation(SplitNode child)
Gets the location of a child. |
|
abstract Node |
getDividerNode(int x,
int y)
Gets the Node whose divider area contains the point x/y. |
|
double |
getHeight()
Gets the relative height of this node in relation to the owner-station. |
|
long |
getId()
Gets the (hopefully) unique id of this node. |
|
abstract Leaf |
getLeaf(Dockable dockable)
Gets the leaf which represents dockable . |
|
abstract int |
getMaxChildrenCount()
Gets the maximal number of children this node can have. |
|
abstract Dimension |
getMinimumSize()
Gets the minimal size of this node. |
|
SplitNode |
getParent()
Gets the parent of this node. |
|
PlaceholderMap |
getPlaceholderMap()
Gets placeholder information of a child DockStation . |
|
SplitNode |
getPlaceholderNode(Path placeholder)
Searches and returns the first SplitNode which contains placeholder . |
|
Path[] |
getPlaceholders()
Gets all the keys that are stored in this placeholder |
|
abstract Dimension |
getPreferredSize()
Gets the preferred size of this node. |
|
abstract PutInfo |
getPut(int x,
int y,
double factorW,
double factorH,
Dockable drop)
Determines where to drop the Dockable drop
if the mouse is at location x/y. |
|
Root |
getRoot()
Gets the root of the tree in which this node is |
|
Dimension |
getSize()
Gets the size of this node in pixel. |
|
SplitDockStation |
getStation()
Gets the station this node belongs to. |
|
int |
getTotalChildrenCount()
Counts the total number of children of this node, the total number of children is the total number of nodes and leafes in the tree below this node, excluding this node. |
|
abstract SplitNode |
getVisible()
Gets the root of a subtree such that the root is visible and such that the is the uppermost visible node. |
|
double |
getWidth()
Gets the relative width of this node in relation to the owner-station. |
|
double |
getX()
Gets the relative x-coordinate of this node on the owner-station. |
|
double |
getY()
Gets the relative y-coordinate of this node on the owner-station. |
|
boolean |
hasPlaceholder(Path placeholder)
Tells whether this node contains placeholder . |
|
boolean |
hasPlaceholders()
Tells whether this node is associated with at least one placeholder. |
|
abstract boolean |
insert(SplitDockPathProperty property,
int depth,
Dockable dockable)
If there are elements left in property , then the next node
is to be read and the insert -method of the matching child
to be called.If there are no children, then dockable has to be inserted
as new child.Otherwise this element is to be replaced by a node containing this and the a leaf with dockable .Subclasses may wary this scheme in order to optimize or to find a better place for the dockable . |
|
abstract boolean |
insert(SplitDockPlaceholderProperty property,
Dockable dockable)
Recursively searches for a node or leaf that uses the placeholder specified by property and inserts the dockable there. |
|
double |
intersection(SplitDockProperty property)
Calculates how much of the rectangle given by the property lies inside this node and how much of this node lies in the rectangle. |
|
abstract boolean |
isInOverrideZone(int x,
int y,
double factorW,
double factorH)
Tells whether the coordinates x/y lie inside the override-zone of the SplitDockStation or not. |
|
abstract boolean |
isOfUse()
Tells whether this node still has any use or can safely be removed from the tree |
|
abstract boolean |
isVisible()
Tells whether this node (or one of this children) contains element that are visible to the user. |
|
void |
movePlaceholderMap(SplitNode destination)
Moves the current PlaceholderMap to destination , overriding
its old value. |
|
PutInfo.Put |
relativeSidePut(double kx,
double ky)
Calculates on which side of the node the point kx/ky lies. |
|
boolean |
removePlaceholder(Path placeholder)
Removes a placeholder from this node. |
|
void |
removePlaceholders(Set<Path> placeholders)
Removes all placeholders in placeholders from this node |
|
void |
replace(SplitNode node)
Replaces this node with node . |
|
void |
setBounds(double x,
double y,
double width,
double height,
double factorW,
double factorH,
boolean updateComponentBounds)
Updates the bounds of this node. |
|
abstract void |
setChild(SplitNode child,
int location)
Adds a child to this node at a given location. |
|
void |
setParent(SplitNode parent)
Sets the parent of this node. |
|
void |
setPlaceholderMap(PlaceholderMap placeholderMap)
Sets information about the placeholders of a DockStation that was
child of this node. |
|
void |
setPlaceholders(Path[] placeholders)
Sets all the placeholders of this node |
|
abstract
|
submit(SplitTreeFactory<N> factory)
Writes the contents of this node into a new tree create by factory . |
|
String |
toString()
|
|
abstract void |
toString(int tabs,
StringBuilder out)
Writes some contents of this node into out . |
|
protected void |
treeChanged()
Called if a child of this node changed. |
|
void |
updateBounds(double x,
double y,
double width,
double height,
double factorW,
double factorH,
boolean updateComponentBounds)
Updates the bounds of this node. |
|
abstract void |
visit(SplitNodeVisitor visitor)
Invokes one of the methods of the visitor for every
child in the subtree with this as root. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected double x
protected double y
protected double width
protected double height
Constructor Detail |
---|
protected SplitNode(SplitDockAccess access, long id)
access
- the access to the owner of this node. Must not be null
id
- the unique id of this node, -1 indicates that the id must be createdMethod Detail |
---|
protected void treeChanged()
public SplitDockStation getStation()
public Path[] getPlaceholders()
public void addPlaceholder(Path placeholder)
placeholder
is already known to this node.
placeholder
- the additional placeholderpublic boolean hasPlaceholders()
public boolean hasPlaceholder(Path placeholder)
placeholder
.
placeholder
- the placeholder to search
true
if placeholder
was foundpublic void setPlaceholders(Path[] placeholders)
placeholders
- all the placeholders, can be null
or emptypublic boolean removePlaceholder(Path placeholder)
placeholder
- the placeholder to remove
true
if the placeholder was removedpublic void removePlaceholders(Set<Path> placeholders)
placeholders
from this node
placeholders
- the placeholders to removepublic void setPlaceholderMap(PlaceholderMap placeholderMap)
DockStation
that was
child of this node.
placeholderMap
- the placeholder information, can be null
public void movePlaceholderMap(SplitNode destination)
PlaceholderMap
to destination
, overriding
its old value. The map of this node is set to null
destination
- the destination of the mappublic PlaceholderMap getPlaceholderMap()
DockStation
.
null
public abstract boolean isOfUse()
true
if this node has to remain in the tree, false
otherwisepublic void replace(SplitNode node)
node
. Does nothing if this node has no parent.
node
- the replacement, not null
public void delete(boolean shrink)
Dockable
s are removed from the station.
shrink
- whether this node should attempt to shrink the tree such
that no holes are left after this node was deletedpublic Leaf createLeaf(long id)
Leaf
id
- the unique identifier of the new leaf, can be -1
public Node createNode(long id)
Node
.
id
- the unique identifier of the new node, can be -1
public Placeholder createPlaceholder(long id)
Placeholder
calling SplitDockAccess.createPlaceholder(long)
id
- the unique identifier of the new leaf, can be -1
public double getX()
public double getY()
public double getWidth()
public double getHeight()
public void setParent(SplitNode parent)
parent
- the new parent, can be null
public SplitNode getParent()
null
public long getId()
protected void ensureIdUniqueAsync()
ensureIdUnique()
of the Root
node. If this method is not called within the EDT,
then the id is checked immediatelly. Several calls to this method may be merged into one invocation of
ensureIdUnique()
for optimization. If there is no Root
available, nothing happens.
protected void ensureIdUnique()
SplitNode
and ensures that no
node has the same unique id. May change the id of some nodes if necessary.
public int getTotalChildrenCount()
protected SplitDockAccess getAccess()
public abstract boolean isVisible()
true
if this node or one of its children contains
a graphical elementpublic abstract SplitNode getVisible()
null
, this
or any
child of this nodepublic abstract Dimension getMinimumSize()
public abstract Dimension getPreferredSize()
public void updateBounds(double x, double y, double width, double height, double factorW, double factorH, boolean updateComponentBounds)
Component
, then
the bounds of the component have to be updated as well.updateBounds
on
the children of this node.
x
- the relative x-coordinatey
- the relative y-coordinatewidth
- the relative width of the nodeheight
- the relative height of the nodefactorW
- a factor to be multiplied with x
and width
to get the size of the node in pixelfactorH
- a factor to be multiplied with y
and height
to get the size of the node in pixelupdateComponentBounds
- whether to update the bounds of Component
s
that are in the tree. If set to false
, then all updates stay within
the tree and the graphical user interface is not changed. That can be useful
if more than one round of updates is necessary. If in doubt, set this parameter
to true
.setBounds(double, double, double, double, double, double, boolean)
public void setBounds(double x, double y, double width, double height, double factorW, double factorH, boolean updateComponentBounds)
Component
, then
the bounds of the component have to be updated as well. This method is not recursive, it does not
call getBounds
on the children of this node.
x
- the relative x-coordinatey
- the relative y-coordinatewidth
- the relative width of the nodeheight
- the relative height of the nodefactorW
- a factor to be multiplied with x
and width
to get the size of the node in pixelfactorH
- a factor to be multiplied with y
and height
to get the size of the node in pixelupdateComponentBounds
- whether to update the bounds of Component
s
that are in the tree. If set to false
, then all updates stay within
the tree and the graphical user interface is not changed. That can be useful
if more than one round of updates is necessary. If in doubt, set this parameter
to true
.updateBounds(double, double, double, double, double, double, boolean)
public Root getRoot()
null
public abstract PutInfo getPut(int x, int y, double factorW, double factorH, Dockable drop)
Dockable
drop
if the mouse is at location x/y.
x
- the x-coordinate of the mousey
- the y-coordinate of the mousefactorW
- a factor to be multiplied with the relative
x
and width
to get the
size in pixel.factorH
- a factor to be multiplied with the relative
y
and height
to get the
size in pixel.drop
- the Dockable
which will be dropped
null
if
the dockable can't be droppedpublic abstract boolean isInOverrideZone(int x, int y, double factorW, double factorH)
SplitDockStation
or not.
x
- the x-coordinate of the mousey
- the y-coordinate of the mousefactorW
- a factor to be multiplied with the relative
x
and width
to get the
size in pixel.factorH
- a factor to be multiplied with the relative
y
and height
to get the
size in pixel.
true
if the station should not allow child-stations
to make a drop when the mouse is at x/ypublic abstract Leaf getLeaf(Dockable dockable)
dockable
.
dockable
- the Dockable whose leaf is searched
null
if no leaf was foundpublic abstract Node getDividerNode(int x, int y)
x
- the x-coordinatey
- the y-coordinate
null
is returnedpublic abstract int getChildLocation(SplitNode child)
child
- a child of this node
child
or -1 if the child is unknownpublic abstract void setChild(SplitNode child, int location)
child
- the new childlocation
- the location of the childpublic abstract int getMaxChildrenCount()
public abstract SplitNode getChild(int location)
location
.
location
- the location of the child
null
if the location is invalid or if there is no child at the locationpublic abstract void visit(SplitNodeVisitor visitor)
visitor
for every
child in the subtree with this as root.
visitor
- the visitorpublic abstract void evolve(SplitDockTree.Key key, boolean checkValidity, Map<Leaf,Dockable> linksToSet)
key
. Note that this method does not remove any Dockable
s
from the station. They must be removed explicitly using Leaf.setDockable(Dockable, bibliothek.gui.dock.DockHierarchyLock.Token)
key
- the key to readlinksToSet
- a map that is to be filled with all new Leaf
s and their Dockable
s which are not yet set.checkValidity
- whether to ensure that all new Dockable
s are
acceptable or not.public abstract boolean insert(SplitDockPathProperty property, int depth, Dockable dockable)
property
, then the next node
is to be read and the insert
-method of the matching child
to be called.dockable
has to be inserted
as new child.this
and the a leaf with dockable
.dockable
.
property
- a list of nodesdepth
- the index of the node that corresponds to thisdockable
- the element to insert
true
if the element was inserted, false
otherwisepublic abstract boolean insert(SplitDockPlaceholderProperty property, Dockable dockable)
property
and inserts the dockable
there. Also removes
the placeholder from this node.
property
- the placeholder to searchdockable
- the new element
true
if the element was inserted, false
otherwisepublic SplitNode getPlaceholderNode(Path placeholder)
SplitNode
which contains placeholder
.
placeholder
- the placeholder to search
placeholder
or null
public abstract <N> N submit(SplitTreeFactory<N> factory)
factory
.
N
- the type of element the factory
will createfactory
- the factory transforming the elements of the tree into a
new form.
public String toString()
toString
in class Object
public abstract void toString(int tabs, StringBuilder out)
out
.
tabs
- the number of tabs that should be added before the text if
a new line is necessary.out
- the container to write intopublic Dimension getSize()
public Rectangle getBounds()
VisibleSplitNode.getCurrentBounds()
.
protected Leaf create(Dockable dockable, long id)
dockable
. This method only
creates the leaf, but does not connect leaf and dockable
.
dockable
- the element to put into a leafid
- the unique identifier of the new leaf, can be -1
null
if the leaf would not be validprotected SplitNode create(SplitDockTree.Key key, boolean checkValidity, Map<Leaf,Dockable> linksToSet)
key
.
key
- the key to readcheckValidity
- whether to ensure that all new Dockable
s
are acceptable or not.linksToSet
- a map that will be filled up with new Leaf
s whose Dockable
s have not yet been set
public double intersection(SplitDockProperty property)
property
- the property that gives a rectangle
public PutInfo.Put relativeSidePut(double kx, double ky)
kx/ky
lies.
kx
- the relative x-coordinate of the pointky
- the relative y-coordinate of the point
public static boolean above(double x1, double y1, double x2, double y2, double x, double y)
x/y
lies above
the line going through x1/y1
and x2/y2
.
x1
- the x-coordinate of the first point on the liney1
- the y-coordinate of the first point on the linex2
- the x-coordinate of the second point on the liney2
- the y-coordinate of the second point on the linex
- the x-coordinate of the point which may be above the liney
- the y-coordinate of the point which may be above the line
true
if the point lies above the line, false
otherwise
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |