|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.hierarchic.AbstractDrawer
public abstract class AbstractDrawer
This is an abstract base class that implements the drawing phase of the hierarchic layout algorithm
.
This class assigns the coordinates to the nodes according to the defined layers. It also provides methods to assign the corresponding y-coordinates.
AbstractDrawer
is used by the HierarchicLayouter
for assigning the node coordinates and implementations of this
class are used for determining specific layout styles (see HierarchicLayouter.setLayoutStyle(byte)
.
Field Summary | |
---|---|
protected NodeMap |
distanceToNextNode
Stores the minimum distance between the right border of a node and the left border of its right-hand side neighbor in a layer. |
protected NodeMap |
dummyMap
A NodeMap used for identifying dummy nodes. |
protected java.lang.Object |
edgeLengthKey
Key for registering a data provider which stores the length of the edges. |
protected LayoutGraph |
graph
The graph bound to this drawer instance. |
protected double |
minimalEdgeDistance
The minimum distance between two edges in the same layer. |
protected double |
minimalLayerDistance
The minimum distance between two layers. |
protected double |
minimalMultiEdgeDistance
The minimum distance between two edges sharing source/target in the same layer. |
protected double |
minimalNodeDistance
The minimum distance between two nodes in the same layer. |
Fields inherited from interface y.layout.hierarchic.Drawer |
---|
NODE_BORDER_BOTTOM, NODE_BORDER_LEFT, NODE_BORDER_RIGHT, NODE_BORDER_TOP, NODE_DISTANCE |
Constructor Summary | |
---|---|
protected |
AbstractDrawer()
Creates an instance of AbstractDrawer with default settings. |
Method Summary | |
---|---|
void |
assignCoordinates(LayoutGraph graph,
NodeList[] layerLists,
DataProvider layerID)
Assigns coordinates to the nodes of the given graph. |
protected abstract void |
assignCoordinates(NodeList[] layerLists,
DataProvider layerID)
Assigns the final coordinates to the objects of the graph. |
void |
assignYCoords(LayoutGraph graph,
NodeCursor[] layerCursors)
Assigns the y-coordinates to the nodes respecting the minimum layer distance. |
void |
assignYCoords(LayoutGraph graph,
NodeList[] layerLists)
Assigns the y-coordinates to the nodes respecting the minimum layer distance. |
protected void |
dispose()
Disposes of allocated resources after the drawer is finished. |
double |
getBottomBorder(Node node)
Returns the height of the bottom border of the given node. |
double |
getBottomHalf(Node node)
Returns the sum of half the height of the node and its bottom border. |
double |
getBottomY(Node node)
Returns the bottommost y-coordinate of the node when considering the bottom border of the node. |
protected double |
getDistanceToNextNode(Node node)
Returns the minimum distance between the right border of the given node and the left border of its right-hand side neighbor in the layer. |
double |
getFullHeight(Node node)
Returns the height of the node when considering the top and the bottom borders of the node. |
double |
getFullWidth(Node node)
Returns the width of the node when considering the left and the right borders of the node. |
double |
getLeftBorder(Node node)
Returns the width of the left border of the given node. |
double |
getLeftHalf(Node node)
Returns the sum of half the width of the node and its left border. |
double |
getLeftX(Node node)
Returns the leftmost x-coordinate of the node when considering the left border of the node. |
double |
getMinimalEdgeDistance()
Returns the minimum distance between two edges in the same layer. |
double |
getMinimalLayerDistance()
Returns the minimum distance between two layers. |
double |
getMinimalMultiEdgeDistance()
Returns the minimum distance between two edges sharing source/target in the same layer. |
double |
getMinimalNodeDistance()
Returns the minimum distance between two nodes in the same layer. |
double |
getRightBorder(Node node)
Returns the width of the right border of the given node. |
double |
getRightHalf(Node node)
Returns the sum of half the width of the node and its right border. |
double |
getRightX(Node node)
Returns the rightmost x-coordinate of the node when considering the right border of the node. |
double |
getTopBorder(Node node)
Returns the height of the top border of the given node. |
double |
getTopHalf(Node node)
Returns the sum of half the height of the node and its top border. |
double |
getTopY(Node node)
Returns the topmost y-coordinate of the node when considering the top border of the node. |
protected void |
initializeDistancesToNextNode(NodeList[] layerLists)
Initializes the minimum distances between the right border of a node and the left border of its right-hand side neighbor in a layer. |
void |
setDummyMap(NodeMap dummyMap)
Specifies a NodeMap instance for identifying the dummy nodes from the real nodes. |
void |
setEdgeLengthKey(java.lang.Object key)
Specifies the key for the DataProvider which stores the length of the edges. |
void |
setMinimalEdgeDistance(double d)
Specifies the minimum distance between two edges that span the same layer. |
void |
setMinimalLayerDistance(double d)
Specifies the minimum distance between two layers. |
void |
setMinimalMultiEdgeDistance(double d)
Specifies the minimum distance between two edges sharing source/target in the same layer. |
void |
setMinimalNodeDistance(double d)
Specifies the minimum distance between two nodes in the same layer. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected double minimalNodeDistance
protected double minimalLayerDistance
protected double minimalEdgeDistance
protected double minimalMultiEdgeDistance
protected NodeMap dummyMap
NodeMap
used for identifying dummy nodes.
It returns the original edge for each dummy node or null
for real nodes.
setDummyMap(NodeMap)
protected java.lang.Object edgeLengthKey
DataProvider
maps each edge of the input graph
to a double value representing the edge's length.
protected LayoutGraph graph
protected NodeMap distanceToNextNode
For each node, a double value is stored representing this minimum distance.
Constructor Detail |
---|
protected AbstractDrawer()
AbstractDrawer
with default settings.
Method Detail |
---|
public void setMinimalEdgeDistance(double d)
Minimum distance must be non-negative.
setMinimalEdgeDistance
in interface Drawer
public void setMinimalMultiEdgeDistance(double d)
Minimum distance must be non-negative.
setMinimalMultiEdgeDistance
in interface Drawer
public double getMinimalEdgeDistance()
Minimum distance must be non-negative.
setMinimalEdgeDistance(double)
public double getMinimalMultiEdgeDistance()
Minimum distance must be non-negative.
setMinimalNodeDistance(double)
public void setMinimalNodeDistance(double d)
Minimum distance must be non-negative.
setMinimalNodeDistance
in interface Drawer
public void setMinimalLayerDistance(double d)
Minimum distance must be non-negative.
setMinimalLayerDistance
in interface Drawer
public void setDummyMap(NodeMap dummyMap)
NodeMap
instance for identifying the dummy nodes from the real nodes.
setDummyMap
in interface Drawer
dummyMap
- the NodeMap
that returns the original edge for each dummy node or
null
for real nodespublic double getMinimalNodeDistance()
Minimum distance must be non-negative.
setMinimalNodeDistance(double)
public double getMinimalLayerDistance()
Minimum distance must be non-negative.
setMinimalLayerDistance(double)
public void setEdgeLengthKey(java.lang.Object key)
DataProvider
which stores the length of the edges.
key
- the given DataProvider
keypublic void assignYCoords(LayoutGraph graph, NodeList[] layerLists)
This methods calls assignYCoords(LayoutGraph, NodeCursor[])
for each node in the given list.
graph
- the graphlayerLists
- an array of NodeList
s each of which contains nodes that belong to the same layerpublic void assignYCoords(LayoutGraph graph, NodeCursor[] layerCursors)
Nodes that belong to the same layers are assigned the same y-coordinates if they are of the same size. Else, the y-coordinates are calculated based on the height of each node and on the maximum height of the nodes that each layer contains while respecting the minimum layer distance between layers.
graph
- the graphlayerCursors
- an array of NodeCursor
s each of which iterates over nodes that belong to the same layerpublic void assignCoordinates(LayoutGraph graph, NodeList[] layerLists, DataProvider layerID)
This method binds the specified graph to this drawer and calls the abstract method
assignCoordinates(NodeList[],DataProvider)
.
assignCoordinates
in interface Drawer
graph
- the input graphlayerLists
- an array of NodeList
s each of which contains nodes that belong to the same layerlayerID
- the DataProvider
that returns the zero-based index of the layer to which each node belongsprotected abstract void assignCoordinates(NodeList[] layerLists, DataProvider layerID)
This method is called by HierarchicLayouter.doLayoutCore(LayoutGraph)
after the nodes are distributed in
layers. It has to be implemented to assign the final coordinates to the objects of the graph based on the user's
specifications.
layerLists
- an array of NodeList
s each of which contains nodes that belong to the same layerlayerID
- the DataProvider
that returns the zero-based index of the layer to which each node belongspublic double getLeftX(Node node)
The left borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_LEFT
.
node
- the given node
public double getRightX(Node node)
The right borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_RIGHT
.
node
- the given node
public double getTopY(Node node)
The top borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_TOP
.
node
- the given node
public double getBottomY(Node node)
The bottom borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_BOTTOM
.
node
- the given node
public double getFullWidth(Node node)
The right and left borders are specified by DataProvider
s registered with the graph using keys
Drawer.NODE_BORDER_RIGHT
and Drawer.NODE_BORDER_LEFT
, respectively.
node
- the given node
public double getFullHeight(Node node)
The top and bottom borders are specified by DataProvider
s registered with the graph using keys
Drawer.NODE_BORDER_TOP
and Drawer.NODE_BORDER_BOTTOM
, respectively.
node
- the given node
public double getLeftBorder(Node node)
The left borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_LEFT
.
0
.DataProvider
registered with the graph using key
Drawer.NODE_BORDER_LEFT
or is equal to 0
if such a DataProvider
is not registered.
node
- the given node
public double getRightBorder(Node node)
The right borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_RIGHT
.
0
.DataProvider
registered with the graph using key
Drawer.NODE_BORDER_RIGHT
or is equal to 0
if such a DataProvider
is not registered.
node
- the given node
public double getTopBorder(Node node)
The top borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_TOP
.
0
.DataProvider
registered with the graph using key
Drawer.NODE_BORDER_TOP
or is equal to 0
if such a DataProvider
is not registered.
node
- the given node
public double getBottomBorder(Node node)
The bottom borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_BOTTOM
.
0
.DataProvider
registered with the graph using key
Drawer.NODE_BORDER_BOTTOM
or is equal to 0
if such a DataProvider
is not registered.
node
- the given node
public double getLeftHalf(Node node)
The left borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_LEFT
.
node
- the given node
public double getRightHalf(Node node)
The right borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_RIGHT
.
node
- the given node
public double getTopHalf(Node node)
The top borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_TOP
.
node
- the given node
public double getBottomHalf(Node node)
The bottom borders are specified by a DataProvider
registered with the graph using key
Drawer.NODE_BORDER_BOTTOM
.
node
- the given node
protected void initializeDistancesToNextNode(NodeList[] layerLists)
This method is called by assignCoordinates(LayoutGraph, NodeList[], DataProvider)
before the node
coordinates assignment is performed. It may be overridden to calculate the minimum distances between nodes in a
different way.
layerLists
- an array of NodeList
s, each of which contains nodes that belong to the same layergetDistanceToNextNode(Node)
,
distanceToNextNode
protected double getDistanceToNextNode(Node node)
Minimum node distances are constructed by using the values provided by the DataProvider
s that are
registered with the input graph using keys Drawer.NODE_DISTANCE
, Drawer.NODE_BORDER_LEFT
and Drawer.NODE_BORDER_RIGHT
.
node
- the given node
protected void dispose()
This method disposes of the NodeMap
that stores the minimum distance between the right border of a node and
the left border of its right-hand side neighbor in a layer.
It may be overridden for custom configurations.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |