public class CompactOrthogonalLayout extends PartitionLayout
This layout algorithm is a variant of OrthogonalLayout
that tries to arrange nodes in a more compact way. It
allows to specify a desired aspect ratio for the bounds of the calculated layout. Nodes of a given graph are arranged
such that each edge is drawn as an alternating sequence of horizontal and vertical segments.
CompactOrthogonalLayout
is well suited for small and medium-sized sparse graphs and produces compact drawings
with no overlapping nodes, few crossings and few bends. It is also especially suitable for printing the diagram on a
paper of predefined size. As a disadvantage, this algorithm will usually produce less elegant edge routes than the ones
of OrthogonalLayout
.
Application domains of orthogonal drawings are software engineering, project management, function call graphs and object-oriented class diagrams.
Sample output of the layout algorithm with aspect ratio 1.0
This algorithm is implemented as a PartitionLayout
and applies the following steps:
PartitionLayout.EdgeBetweennessPartitionFinder
.OrthogonalLayout
.PartitionLayout.ComponentPartitionPlacer
.PartitionLayout.ChannelInterEdgeRouter
.
Each of these steps can be individually configured and/or replaced. To do so, use methods
PartitionFinder
,
CoreLayout
,
PartitionPlacer
and
InterEdgeRouter
, respectively.
The aspect ratio of the resulting layout bounds, i.e., the ratio of width/height of the layout, can be configured using
AspectRatio
. CompactOrthogonalLayout
tries to reach this preferred value.
However, depending on the actual graph structure, this may not always be possible.
Octilinear routing of edges can be supported by appending
PolylineLayoutStage
.
PartitionLayout.IInterEdgeRouter, PartitionLayout.IPartitionFinder, PartitionLayout.IPartitionPlacer
Constructor and Description |
---|
CompactOrthogonalLayout()
Creates a new
CompactOrthogonalLayout instance with default settings. |
Modifier and Type | Method and Description |
---|---|
double |
getAspectRatio()
Gets the desired aspect ratio (i.e.
|
int |
getGridSpacing()
Gets the equidistant spacing between the horizontal and vertical grid lines.
|
void |
setAspectRatio(double value)
Sets the desired aspect ratio (i.e.
|
void |
setGridSpacing(int value)
Sets the equidistant spacing between the horizontal and vertical grid lines.
|
applyLayout, getInterEdgeRouter, getPartitionFinder, getPartitionPlacer, setInterEdgeRouter, setPartitionFinder, setPartitionPlacer
applyLayoutCore, getCoreLayout, setCoreLayout
public CompactOrthogonalLayout()
CompactOrthogonalLayout
instance with default settings.public double getAspectRatio()
the quotient width/height) of the resulting layout bounds.
The aspect ratio needs to be greater than 0
.
IllegalArgumentException
- if the given aspect ratio is less than or equal to zeropartition placer
is of type PartitionLayout.ComponentPartitionPlacer
.PartitionLayout.setPartitionPlacer(PartitionLayout.IPartitionPlacer)
,
PartitionLayout.ComponentPartitionPlacer
,
setAspectRatio(double)
public int getGridSpacing()
Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if the endpoints of the edges allow to place the ports accordingly.
The grid spacing has to be greater than 0
.
IllegalArgumentException
- if the grid spacing is negative or zerosetGridSpacing(int)
public void setAspectRatio(double value)
the quotient width/height) of the resulting layout bounds.
The aspect ratio needs to be greater than 0
.
IllegalArgumentException
- if the given aspect ratio is less than or equal to zeropartition placer
is of type PartitionLayout.ComponentPartitionPlacer
.value
- the desired aspect ratioPartitionLayout.setPartitionPlacer(PartitionLayout.IPartitionPlacer)
,
PartitionLayout.ComponentPartitionPlacer
,
getAspectRatio()
public void setGridSpacing(int value)
Each node will be placed on a grid point. Edges will be routed such that their segments lie on grid lines, if the endpoints of the edges allow to place the ports accordingly.
The grid spacing has to be greater than 0
.
IllegalArgumentException
- if the grid spacing is negative or zerovalue
- the grid spacinggetGridSpacing()