|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.partial.FillAreaLayouter
public class FillAreaLayouter
This layout algorithm tries to fill a specified area with graph elements by moving nearby elements towards it, with the goal to make the existing layout more compact and not changing it too much.
The algorithm can make an existing layout more compact in the region of the defined area
.
It moves nearby graph elements, while keeping the given layout style as much as possible.
Ideally, only local changes around the marked area are made such that the mental map for the user is preserved.
The best applications are those where it shall be avoided to calculate a completely new layout after
local changes have been made to an already existing and good layout. Also not that the results for this
application are much better when the edge paths are already good orthogonal, polyline or octilinear paths.
For straight-line edge routes, the shape and overall mental map of the layout can not be preserved that well
and the changes may be more global.
An example application is the use case that nodes were removed from the graph.
The region where the nodes have been removed can then be defined as the area
so that the algorithm can try to fill/use this free space and make the layout more compact.
This way it can be avoided to compute a completely new layout for such cases.
Another use case would be when a group node is collapsed and converted to a smaller folder node.
In that case the folder node should be marked as fixed
.
Note that it isn't guaranteed that the area is filled with elements after calling the algorithm.
Sample input graph where the gray area should be filled with elements.
Result layout after applying this algorithm - the drawing was made much more compact and the free area is used.
The area (see setArea(YRectangle)
) defines a region in the given graph which should be filled
with elements, with the goal to make the overall layout more compact. To do so, graph elements must
be moved. This includes nodes, edges and their labels. Whether node labels and edge labels should be considered
can be controlled via settings isNodeLabelConsiderationEnabled()
and
isEdgeLabelConsiderationEnabled()
.
Keep in mind that the goal is to make the layout more compact. Therefore, if the area is located such that it brings no advantage to move elements towards it, the algorithm may also do nothing - based on a heuristic decision. This means that it does not fill the specified area in any case.
The algorithm is able to consider a specified PartitionGrid
as long as there are no group nodes that
span multiple grid cells.
For this feature to work properly it is required that the values of the properties
ColumnDescriptor.getOriginalPosition()
, RowDescriptor.getOriginalPosition()
ColumnDescriptor.getOriginalWidth()
and RowDescriptor.getOriginalHeight()
are correctly specified. This is usually automatically the case when executing the FillAreaLayouter
as a
standalone algorithm via layout execution convenience methods (e.g. the values are taken from the table
visualization of the grid). However, if the FillAreaLayouter
is applied as part of a more complex
layout pipeline it may be necessary to specify the values manually. For example, if another algorithm
previously computed the grid position values and stored them in the respective 'computed' properties
(e.g. ColumnDescriptor.getComputedPosition()
), and afterwards FillAreaLayouter
should be applied, then the 'computed' values of the first algorithm should be written to the 'original'
values prior to the run of the FillAreaLayouter
.
Field Summary | |
---|---|
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
A component assignment strategy where the subgraph components correspond to the clusters computed by a clustering algorithm based on edge betweenness centrality . |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
A component assignment strategy where the subgraph components correspond to the connected components of the graph. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
A component assignment strategy where the subgraph components are defined by the user. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
A component assignment strategy that assigns each node to a separate subgraph component. |
static java.lang.Object |
COMPONENT_ID_DPKEY
A DataProvider key for defining custom components whose elements should preferably not be separated
While the algorithm may move a whole component, it should preferably not move only a subset of
its elements. |
static java.lang.Object |
FIXED_NODE_DPKEY
A DataProvider key for marking nodes as fixed
A node marked as fixed will not be moved by this algorithm but stay at its current position. |
static byte |
ORIENTATION_AUTO_DETECTION
Layout orientation specifier where the orientation is automatically detected. |
static byte |
ORIENTATION_BOTTOM_TO_TOP
Layout orientation specifier which defines that the main layout orientation is from bottom to top. |
static byte |
ORIENTATION_LEFT_TO_RIGHT
Layout orientation specifier which defines that the main layout orientation is from left to right. |
static byte |
ORIENTATION_NONE
Layout orientation specifier where the layout orientation is completely ignored. |
static byte |
ORIENTATION_RIGHT_TO_LEFT
Layout orientation specifier which defines that the main layout orientation is from right to left. |
static byte |
ORIENTATION_TOP_TO_BOTTOM
Layout orientation specifier which defines that the main layout orientation is from top to bottom. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
FillAreaLayouter()
Creates a new instance of FillAreaLayouter with default settings. |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all general graphs. |
void |
doLayout(LayoutGraph graph)
Tries to fill the specified area in the given graph with elements, such that the resulting layout is more compact. |
YRectangle |
getArea()
Returns the rectangular area that should be filled. |
byte |
getComponentAssignmentStrategy()
Returns the strategy that assigns nodes to components whose elements should preferably not be separated. |
double |
getGridSpacing()
Returns the current grid spacing. |
byte |
getLayoutOrientation()
Returns the layout orientation that is considered during the compaction process. |
long |
getMaximumDuration()
Returns the time limit in milliseconds for the layout algorithm. |
double |
getSpacing()
Returns the spacing that is considered between elements when they are moved. |
boolean |
isEdgeLabelConsiderationEnabled()
Returns whether or not the layout algorithm considers edge labels. |
boolean |
isNodeLabelConsiderationEnabled()
Returns whether or not the layout algorithm considers node labels. |
void |
setArea(YRectangle area)
Specifies the rectangular area that should be filled. |
void |
setComponentAssignmentStrategy(byte componentAssignmentStrategy)
Specifies the strategy that assigns nodes to components whose elements should preferably not be separated. |
void |
setEdgeLabelConsiderationEnabled(boolean edgeLabelConsiderationEnabled)
Specifies whether or not the layout algorithm considers edge labels. |
void |
setGridSpacing(double gridSpacing)
Specifies the current grid spacing. |
void |
setLayoutOrientation(byte layoutOrientation)
Specifies the layout orientation that is considered during the compaction process. |
void |
setMaximumDuration(long maximumDuration)
Specifies the time limit in milliseconds for the layout algorithm. |
void |
setNodeLabelConsiderationEnabled(boolean nodeLabelConsiderationEnabled)
Specifies whether or not the layout algorithm considers node labels. |
void |
setSpacing(double spacing)
Specifies the spacing that is considered between elements when they are moved. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object COMPONENT_ID_DPKEY
DataProvider
key for defining custom components whose elements should preferably not be separated
While the algorithm may move a whole component, it should preferably not move only a subset of its elements. This means that the algorithm tries to move all elements of a component by the same offset (if at all). In order to achieve good results with this feature, the different components should not overlap in the initial drawing.
getComponentAssignmentStrategy()
is set to COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
.setComponentAssignmentStrategy(byte)
public static final java.lang.Object FIXED_NODE_DPKEY
DataProvider
key for marking nodes as fixed
A node marked as fixed will not be moved by this algorithm but stay at its current position.
public static final byte COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
PartialLayouter.setComponentAssignmentStrategy(byte)
,
ClearAreaLayouter.setComponentAssignmentStrategy(byte)
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
PartialLayouter.setComponentAssignmentStrategy(byte)
,
ClearAreaLayouter.setComponentAssignmentStrategy(byte)
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
edge betweenness centrality
.
PartialLayouter.setComponentAssignmentStrategy(byte)
,
ClearAreaLayouter.setComponentAssignmentStrategy(byte)
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
PartialLayouter.setComponentAssignmentStrategy(byte)
,
ClearAreaLayouter.setComponentAssignmentStrategy(byte)
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_TOP_TO_BOTTOM
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_BOTTOM_TO_TOP
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_LEFT_TO_RIGHT
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_RIGHT_TO_LEFT
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_AUTO_DETECTION
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_NONE
PartialLayouter.setLayoutOrientation(byte)
,
ClearAreaLayouter.setLayoutOrientation(byte)
,
setLayoutOrientation(byte)
,
Constant Field ValuesConstructor Detail |
---|
public FillAreaLayouter()
FillAreaLayouter
with default settings.
Method Detail |
---|
public double getGridSpacing()
Elements are moved by multiples of this value, thus, keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid.
The grid spacing needs to be a non-negative value. If it is set to 0
, no grid is considered.
setGridSpacing(double)
public void setGridSpacing(double gridSpacing)
Elements are moved by multiples of this value, thus, keeping their offset to the grid. That way, components or parts of them that were placed on a grid before, will stay on their original grid.
The grid spacing needs to be a non-negative value. If it is set to 0
, no grid is considered.
gridSpacing
- the grid spacing
java.lang.IllegalArgumentException
- if the given spacing is negativepublic byte getComponentAssignmentStrategy()
While the algorithm may move a whole component, it tries to not move only a subset of its elements, thus, all elements of a component are not moved at all or moved by the same offset.
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
: the components can be user-defined.
If the user does not specify any, there are no components that should explicitly be kept together,
which is equal to the behavior of COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
.
COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
components are defined by the connected components
of the graph.
COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
: components are defined by edge betweenness clustering.
COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
: each node is a separate component which basically
means that there are no components that should explicitly be kept together.
setComponentAssignmentStrategy(byte)
,
COMPONENT_ID_DPKEY
public void setComponentAssignmentStrategy(byte componentAssignmentStrategy)
While the algorithm may move a whole component, it tries to not move only a subset of its elements, thus, all elements of a component are not moved at all or moved by the same offset.
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
: the components can be user-defined.
If the user does not specify any, there are no components that should explicitly be kept together,
which is equal to the behavior of COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
.
COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
components are defined by the connected components
of the graph.
COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
: components are defined by edge betweenness clustering.
COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
: each node is a separate component which basically
means that there are no components that should explicitly be kept together.
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
. Components can be user-defined and if none
are defined, each node is a separate component.componentAssignmentStrategy
- one of the predefined assignment strategies
java.lang.IllegalArgumentException
- if the specified strategy does not match one of the predefined strategiesCOMPONENT_ID_DPKEY
public long getMaximumDuration()
Values have to be greater than or equal to 0
.
setMaximumDuration(long)
public void setMaximumDuration(long maximumDuration)
Values have to be greater than or equal to 0
.
Long.MAX_VALUE
. maximumDuration
- the non-negative value that specifies the time limit in milliseconds
java.lang.IllegalArgumentException
- if the maximum duration is negativepublic YRectangle getArea()
The specified area may already contain some elements. In order to fill the area, the algorithm may move elements while it still tries to preserve the mental map of the initial layout. Note that after applying this algorithm it is not guaranteed that there are any elements in the specified area.
null
(default) or if it is specified and contains all elements of the
graph, the algorithm terminates without changing anything.setArea(YRectangle)
public void setArea(YRectangle area)
The specified area may already contain some elements. In order to fill the area, the algorithm may move elements while it still tries to preserve the mental map of the initial layout. Note that after applying this algorithm it is not guaranteed that there are any elements in the specified area.
null
(default) or if it is specified and contains all elements
of the graph, the algorithm terminates without changing anything.area
- the rectangular area that should be filledpublic double getSpacing()
This spacing only affects the moving of elements towards the desired area
. Elements keep the
specified distance to other elements and among each other. Carefully observe that if the distance between two
elements is already smaller, then they may not be moved apart.
The spacing is considered for all graph elements, including nodes, edges, node labels and edge labels when they are encountered during the movement process.
setSpacing(double)
public void setSpacing(double spacing)
This spacing only affects the moving of elements towards the desired area
. Elements keep the
specified distance to other elements and among each other. Carefully observe that if the distance between two
elements is already smaller, then they may not be moved apart.
The spacing is considered for all graph elements, including nodes, edges, node labels and edge labels when they are encountered during the movement process.
public boolean isNodeLabelConsiderationEnabled()
If enabled, node labels are considered when moving elements such that overlaps with them are not allowed.
If disabled, elements that are moved may overlap with node labels, even if they did not overlap in the input.
true
if node labels are considered, false
otherwisesetNodeLabelConsiderationEnabled(boolean)
public void setNodeLabelConsiderationEnabled(boolean nodeLabelConsiderationEnabled)
If enabled, node labels are considered when moving elements such that overlaps with them are not allowed.
If disabled, elements that are moved may overlap with node labels, even if they did not overlap in the input.
nodeLabelConsiderationEnabled
- true
if node labels should be considered,
false
otherwisepublic boolean isEdgeLabelConsiderationEnabled()
If enabled, edge labels are considered when moving elements such that overlaps with them are not allowed. Furthermore, they are correctly moved along with an edge if an edge is moved.
If disabled, elements that are moved may overlap with edge labels, even if they did not overlap in the input.
true
if edge labels are considered, false
otherwisesetEdgeLabelConsiderationEnabled(boolean)
public void setEdgeLabelConsiderationEnabled(boolean edgeLabelConsiderationEnabled)
If enabled, edge labels are considered when moving elements such that overlaps with them are not allowed. Furthermore, they are correctly moved along with an edge if an edge is moved.
If disabled, elements that are moved may overlap with edge labels, even if they did not overlap in the input.
edgeLabelConsiderationEnabled
- true
if edge labels should be considered,
false
otherwisepublic byte getLayoutOrientation()
The orientation affects the direction that the algorithm prefers when moving elements.
For the vertical orientations ORIENTATION_TOP_TO_BOTTOM
and ORIENTATION_BOTTOM_TO_TOP
,
moving elements horizontally (i.e. to the left and to the right) is preferred. For the horizontal
orientations ORIENTATION_LEFT_TO_RIGHT
and ORIENTATION_RIGHT_TO_LEFT
, the vertical
moving direction is preferred. This is mainly useful for layouts that have a clear direction and
nodes are divided into layers with respect to this directions, like e.g., hierarchical layouts.
If this behavior is undesired, the orientation can be ignored by specifying ORIENTATION_NONE
.
No specific moving direction will be preferred in that case. The orientation can also be automatically
detected based on the flow direction of the edges when choosing ORIENTATION_AUTO_DETECTION
.
setLayoutOrientation(byte)
public void setLayoutOrientation(byte layoutOrientation)
The orientation affects the direction that the algorithm prefers when moving elements.
For the vertical orientations ORIENTATION_TOP_TO_BOTTOM
and ORIENTATION_BOTTOM_TO_TOP
,
moving elements horizontally (i.e. to the left and to the right) is preferred. For the horizontal
orientations ORIENTATION_LEFT_TO_RIGHT
and ORIENTATION_RIGHT_TO_LEFT
, the vertical
moving direction is preferred. This is mainly useful for layouts that have a clear direction and
nodes are divided into layers with respect to this directions, like e.g., hierarchical layouts.
If this behavior is undesired, the orientation can be ignored by specifying ORIENTATION_NONE
.
No specific moving direction will be preferred in that case. The orientation can also be automatically
detected based on the flow direction of the edges when choosing ORIENTATION_AUTO_DETECTION
.
ORIENTATION_NONE
. The layout is considered to have no specific orientation.layoutOrientation
- one of the predefined layout orientations
java.lang.IllegalArgumentException
- if the specified orientation does not match one of the predefined orientationspublic boolean canLayout(LayoutGraph graph)
canLayout
in interface Layouter
graph
- the input graph
true
for all kinds of graphsLayouter.doLayout(LayoutGraph)
public void doLayout(LayoutGraph graph)
doLayout
in interface Layouter
graph
- the input graphLayouter.canLayout(LayoutGraph)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |