public class GraphLayoutLineWrapper extends AbstractLayoutStage
GraphLayoutLineWrapper
can line-wrap or column-wrap a graph layout.
This ILayoutStage
supports both wrapping a layout at a given width (height) and wrapping a layout automatically
at some width (height) such that the resulting overall aspect ratio is close to a desired
target ratio
.
The GraphLayoutLineWrapper
can be used on an existing graph layout or on the result of the
core layout algorithm
.
Constructor and Description |
---|
GraphLayoutLineWrapper()
Creates a new
GraphLayoutLineWrapper instance with default settings. |
Modifier and Type | Method and Description |
---|---|
void |
applyLayout(LayoutGraph graph)
Cuts the layout resulting from the
core layout algorithm at a specified
width/height and shifts the remaining graph into the next row/column until the layout has the desired width/height. |
double |
getEdgeSpacing()
Gets the space that should be kept between edges.
|
double |
getFixedWidth()
Gets the desired width of the lines.
|
double |
getSpacing()
Gets the space between adjacent lines of the wrapped graph layout.
|
double |
getTargetRatio()
Gets the desired target aspect ratio for the layout.
|
boolean |
isColumnModeEnabled()
Gets whether this
ILayoutStage wraps lines/rows or columns. |
boolean |
isFixedWidthLineBreaksEnabled()
Gets whether the algorithm should use the
fixed width or target aspect ratio
to determine line breaks. |
boolean |
isMirrored()
Gets whether or not every other line is mirrored.
|
void |
setColumnModeEnabled(boolean value)
Sets whether this
ILayoutStage wraps lines/rows or columns. |
void |
setEdgeSpacing(double value)
Sets the space that should be kept between edges.
|
void |
setFixedWidth(double value)
Sets the desired width of the lines.
|
void |
setFixedWidthLineBreaksEnabled(boolean value)
Sets whether the algorithm should use the
fixed width or target aspect ratio
to determine line breaks. |
void |
setMirrored(boolean value)
Sets whether or not every other line is mirrored.
|
void |
setSpacing(double value)
Sets the space between adjacent lines of the wrapped graph layout.
|
void |
setTargetRatio(double value)
Sets the desired target aspect ratio for the layout.
|
applyLayoutCore, getCoreLayout, setCoreLayout
public GraphLayoutLineWrapper()
GraphLayoutLineWrapper
instance with default settings.public void applyLayout(LayoutGraph graph)
core layout algorithm
at a specified
width/height and shifts the remaining graph into the next row/column until the layout has the desired width/height.applyLayout
in interface ILayoutAlgorithm
applyLayout
in class AbstractLayoutStage
graph
- the input graphpublic double getEdgeSpacing()
The spacing must be non-negative.
IllegalArgumentException
- if the given spacing is a negative valuesetEdgeSpacing(double)
public double getFixedWidth()
The GraphLayoutLineWrapper
breaks the lines at the specified width.
In column mode
, the fixed width is interpreted as fixed height for a column.
FixedWidthLineBreaksEnabled
returns
true
.setFixedWidthLineBreaksEnabled(boolean)
,
setColumnModeEnabled(boolean)
,
setFixedWidth(double)
public double getSpacing()
If the column mode
is enabled, this spacing defines the distance between adjacent
columns.
The spacing should be non-negative.
IllegalArgumentException
- if the spacing is negativesetSpacing(double)
public double getTargetRatio()
The aspect ratio needs to be greater than 0
.
IllegalArgumentException
- if the target ratio is 0
or lessFixedWidthLineBreaksEnabled
returns
false
.width/height
setFixedWidthLineBreaksEnabled(boolean)
,
setTargetRatio(double)
public boolean isColumnModeEnabled()
ILayoutStage
wraps lines/rows or columns.
If this mode is enabled, the layout is wrapped vertically and new columns are appended to the right of the first column. Otherwise, the layout is wrapped horizontally and new rows are appended below the first row.
Also, the FixedWidth
property will be interpreted as a fixed height if this mode is
enabled.
false
. The layout is wrapped horizontally, producing rows.true
for column wrapping mode, false
for row wrappingsetFixedWidth(double)
,
setColumnModeEnabled(boolean)
public boolean isFixedWidthLineBreaksEnabled()
fixed width
or target aspect ratio
to determine line breaks.false
. The target aspect ratio defines how the line width is chosen.true
if a fixed line width is used, false
otherwisesetFixedWidth(double)
,
setTargetRatio(double)
,
setFixedWidthLineBreaksEnabled(boolean)
public boolean isMirrored()
When breaking a line and placing the remaining line below, this remainder can be rotated by 180
degrees. Then,
the edges connecting both lines
stay short. In case the remainder is not rotated, the edges are routed between the two lines to connect to
the front of the non-mirrored line.
true
. Every other line is mirrored.true
if every second line is rotated by 180
degrees, false
otherwisesetMirrored(boolean)
public void setColumnModeEnabled(boolean value)
ILayoutStage
wraps lines/rows or columns.
If this mode is enabled, the layout is wrapped vertically and new columns are appended to the right of the first column. Otherwise, the layout is wrapped horizontally and new rows are appended below the first row.
Also, the FixedWidth
property will be interpreted as a fixed height if this mode is
enabled.
false
. The layout is wrapped horizontally, producing rows.value
- true
for column wrapping mode, false
for row wrappingsetFixedWidth(double)
,
isColumnModeEnabled()
public void setEdgeSpacing(double value)
The spacing must be non-negative.
IllegalArgumentException
- if the given spacing is a negative valuevalue
- the space between edgesgetEdgeSpacing()
public void setFixedWidth(double value)
The GraphLayoutLineWrapper
breaks the lines at the specified width.
In column mode
, the fixed width is interpreted as fixed height for a column.
FixedWidthLineBreaksEnabled
returns
true
.value
- the width of the linessetFixedWidthLineBreaksEnabled(boolean)
,
setColumnModeEnabled(boolean)
,
getFixedWidth()
public void setFixedWidthLineBreaksEnabled(boolean value)
fixed width
or target aspect ratio
to determine line breaks.false
. The target aspect ratio defines how the line width is chosen.value
- true
if a fixed line width is used, false
otherwisesetFixedWidth(double)
,
setTargetRatio(double)
,
isFixedWidthLineBreaksEnabled()
public void setMirrored(boolean value)
When breaking a line and placing the remaining line below, this remainder can be rotated by 180
degrees. Then,
the edges connecting both lines
stay short. In case the remainder is not rotated, the edges are routed between the two lines to connect to
the front of the non-mirrored line.
true
. Every other line is mirrored.value
- true
if every second line is rotated by 180
degrees, false
otherwiseisMirrored()
public void setSpacing(double value)
If the column mode
is enabled, this spacing defines the distance between adjacent
columns.
The spacing should be non-negative.
IllegalArgumentException
- if the spacing is negativevalue
- the space between the linesgetSpacing()
public void setTargetRatio(double value)
The aspect ratio needs to be greater than 0
.
IllegalArgumentException
- if the target ratio is 0
or lessFixedWidthLineBreaksEnabled
returns
false
.value
- the desired target aspect ratio in terms of width/height
setFixedWidthLineBreaksEnabled(boolean)
,
getTargetRatio()