|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.layout.AbstractLayoutStage y.layout.OrientationLayouter
public class OrientationLayouter
OrientationLayouter
is a LayoutStage
that changes the orientation of the layout.
There are four orientations that can be used for a layout. These orientations can exist with or without mirroring at the x-axis or y-axis.
Changing the layout orientation is useful for layout styles that show a main direction.
LayoutOrientation.TOP_TO_BOTTOM
layout
LayoutOrientation.BOTTOM_TO_TOP
layout with mirroring
LayoutOrientation.LEFT_TO_RIGHT
layout
LayoutOrientation.RIGHT_TO_LEFT
layout
OrientationLayouter
performs three basic steps.
PortConstraint
s are
transformed to the LayoutOrientation.TOP_TO_BOTTOM
orientation.
core layout algorithm
is invoked and calculates the layout for
orientation LayoutOrientation.TOP_TO_BOTTOM
.
core layout algorithm
is rotated and mirrored to fit the
desired layout orientation.
OrientationLayouter
can either be used as a LayoutStage
wrapping a
layout algorithm
. Then it will change the orientation of the result of the
core layout algorithm
.
If no core layout algorithm
is specified, OrientationLayouter
can work alone. It
will just change the orientation of the layout without arranging nodes and edges.
CanonicMultiStageLayouter
s it is highly recommended to use
CanonicMultiStageLayouter.getOrientationLayouter()
for layout orientation changes and not to wrap
CanonicMultiStageLayouter
with an OrientationLayouter
instance. That may cause unwanted
artifacts.Nested Class Summary | |
---|---|
class |
OrientationLayouter.Transformer
This class provides methods for transferring a point to its final position. |
Field Summary | |
---|---|
static int |
MIRROR_BOTTOM_TO_TOP
Mirroring specifier that defines that layout orientation LayoutOrientation.BOTTOM_TO_TOP will be mirrored. |
static int |
MIRROR_LEFT_TO_RIGHT
Mirroring specifier that defines that layout orientation LayoutOrientation.LEFT_TO_RIGHT will be mirrored. |
static int |
MIRROR_NONE
Mirroring specifier that can be used for preventing any mirroring of layout orientations. |
static int |
MIRROR_RIGHT_TO_LEFT
Mirroring specifier that defines that layout orientation LayoutOrientation.RIGHT_TO_LEFT will be mirrored. |
static int |
MIRROR_TOP_TO_BOTTOM
Mirroring specifier that defines that layout orientation LayoutOrientation.TOP_TO_BOTTOM will be mirrored. |
Fields inherited from interface y.layout.LayoutOrientation |
---|
BOTTOM_TO_TOP, LEFT_TO_RIGHT, RIGHT_TO_LEFT, 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 | |
---|---|
OrientationLayouter()
Creates a new OrientationLayouter instance with default settings. |
|
OrientationLayouter(byte orientation)
Creates a new OrientationLayouter instance using the given orientation. |
|
OrientationLayouter(Layouter coreLayouter)
Creates a new OrientationLayouter instance using the given core layout algorithm . |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Accepts all graphs that can be handled by the core layout algorithm . |
protected void |
completeOrientationChange(LayoutGraph graph)
Applies the desired orientation to the graph. |
protected YPoint |
completeTransform(YPoint point)
Transforms the given point during completion. |
YInsets |
createOrientedInsets(java.awt.Insets insets)
Deprecated. Use createOrientedInsets(YInsets) instead. |
YInsets |
createOrientedInsets(YInsets insets)
Creates YInsets that are a geometric transformation of the given YInsets . |
NodeHalo |
createOrientedNodeHalo(NodeHalo halo)
Creates a NodeHalo that is a geometric transformation of the given NodeHalo . |
YDimension |
createOrientedNodeSize(YDimension nodeSize)
Creates a YDimension that is a geometric transformation of the given size. |
void |
doLayout(LayoutGraph graph)
Prepares the graph for orientation change before calling the core layout algorithm and
finishes the orientation change afterwards. |
int |
getMirrorMask()
Returns the mirror mask that defines which orientations this OrientationLayouter shall mirror. |
byte |
getOrientation()
Returns the main direction of the layout. |
boolean |
isConsiderEdgeLabelsEnabled()
Returns whether or not the position of the edge labels should be changed during orientation change. |
boolean |
isHorizontalOrientation()
Returns whether or not the current orientation is horizontal. |
boolean |
isOrientationMirrored(byte orientation)
Returns whether or not this OrientationLayouter instance will mirror the graph for a given layout
orientation. |
protected void |
prepareOrientationChange(LayoutGraph graph)
Prepares the layout for the desired orientation. |
protected YPoint |
prepareTransform(YPoint point)
Transforms the given point during preparation. |
void |
setConsiderEdgeLabelsEnabled(boolean enabled)
Specifies whether or not the position of the edge labels should be changed during orientation change. |
void |
setMirrorMask(int mirrorMask)
Specifies the mirror mask that defines which orientations this OrientationLayouter shall mirror. |
void |
setOrientation(byte orientation)
Specifies the main direction of the layout. |
protected YPoint |
transform(YPoint point,
boolean prepare)
Transforms the given point during the preparation or completion step. |
Methods inherited from class y.layout.AbstractLayoutStage |
---|
canLayoutCore, doLayoutCore, getCoreLayouter, setCoreLayouter |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MIRROR_NONE
setMirrorMask(int)
,
setOrientation(byte)
,
Constant Field Valuespublic static final int MIRROR_TOP_TO_BOTTOM
LayoutOrientation.TOP_TO_BOTTOM
will be mirrored.
This specifier can be used for creating a mirror mask that defines which layout orientations shall be mirrored at their corresponding axis. It can be combined with the other mirroring specifiers to mirror several orientations.
setMirrorMask(int)
,
setOrientation(byte)
,
Constant Field ValuesLayoutOrientation.TOP_TO_BOTTOM for the left graph and the mirrored graph on the right |
public static final int MIRROR_RIGHT_TO_LEFT
LayoutOrientation.RIGHT_TO_LEFT
will be mirrored.
This specifier can be used for creating a mirror mask that defines which layout orientations shall be mirrored at their corresponding axis. It can be combined with the other mirroring specifiers to mirror several orientations.
setMirrorMask(int)
,
setOrientation(byte)
,
Constant Field ValuesLayoutOrientation.RIGHT_TO_LEFT for the left graph and the mirrored graph on the right |
public static final int MIRROR_BOTTOM_TO_TOP
LayoutOrientation.BOTTOM_TO_TOP
will be mirrored.
This specifier can be used for creating a mirror mask that defines which layout orientations shall be mirrored at their corresponding axis. It can be combined with the other mirroring specifiers to mirror several orientations.
setMirrorMask(int)
,
setOrientation(byte)
,
Constant Field ValuesLayoutOrientation.BOTTOM_TO_TOP for the left graph and the mirrored graph on the right |
public static final int MIRROR_LEFT_TO_RIGHT
LayoutOrientation.LEFT_TO_RIGHT
will be mirrored.
This specifier can be used to create a mirror mask that defines which layout orientations shall be mirrored at their corresponding axis. It can be combined with the other mirroring specifiers to mirror several orientations.
setMirrorMask(int)
,
setOrientation(byte)
,
Constant Field ValuesLayoutOrientation.LEFT_TO_RIGHT for the left graph and the mirrored graph on the right |
Constructor Detail |
---|
public OrientationLayouter(Layouter coreLayouter)
OrientationLayouter
instance using the given core layout algorithm
.
coreLayouter
- the core layout routinepublic OrientationLayouter()
OrientationLayouter
instance with default settings.
public OrientationLayouter(byte orientation)
OrientationLayouter
instance using the given orientation.
orientation
- the orientation specifier
java.lang.IllegalArgumentException
- if the specified orientation is unknownsetOrientation(byte)
Method Detail |
---|
public void setOrientation(byte orientation)
LayoutOrientation.TOP_TO_BOTTOM
orientation
- one of the valid orientation specifiers
java.lang.IllegalArgumentException
- if the specified orientation is unknownpublic byte getOrientation()
setOrientation(byte)
public int getMirrorMask()
OrientationLayouter
shall mirror.
Setting a layout orientation
can be seen as rotating the graph by 90
,
180
or 270
degrees. Afterwards the graph can be mirrored at the x-axis (for horizontal
layout orientations) or y-axis (for vertical layout orientations).
Which directions are mirrored can be defined by the given mask. It can combine several mirrored directions with
a logical or
-operation.
setMirrorMask(int)
public void setMirrorMask(int mirrorMask)
OrientationLayouter
shall mirror.
Setting a layout orientation
can be seen as rotating the graph by 90
,
180
or 270
degrees. Afterwards the graph can be mirrored at the x-axis (for horizontal
layout orientations) or y-axis (for vertical layout orientations).
Which directions are mirrored can be defined by the given mask. It can combine several mirrored directions with
a logical or
-operation.
MIRROR_BOTTOM_TO_TOP
mirrorMask
- the mask that determines which layout orientations should be mirrored
java.lang.IllegalArgumentException
- if an unknown mask is specifiedpublic boolean isHorizontalOrientation()
The orientation is horizontal if it is LayoutOrientation.LEFT_TO_RIGHT
or LayoutOrientation.RIGHT_TO_LEFT
.
true
if a horizontal orientation is currently used, false
otherwisesetOrientation(byte)
public boolean isConsiderEdgeLabelsEnabled()
core layout algorithm
should switch this off if it performs integrated edge
labeling.true
if the position of the edge labels are changed, false
otherwisesetConsiderEdgeLabelsEnabled(boolean)
public void setConsiderEdgeLabelsEnabled(boolean enabled)
core layout algorithm
should switch this off if it performs integrated edge
labeling.OrientationLayouter
.enabled
- true
if the position of the edge labels should be changed, false
otherwisepublic boolean canLayout(LayoutGraph graph)
core layout algorithm
.
canLayout
in interface Layouter
graph
- the input graph
true
if there is no core layout algorithm
or it can handle the
given graph, false
otherwiseLayouter.doLayout(LayoutGraph)
public void doLayout(LayoutGraph graph)
core layout algorithm
and
finishes the orientation change afterwards.
doLayout
in interface Layouter
graph
- the input graphLayouter.canLayout(LayoutGraph)
public boolean isOrientationMirrored(byte orientation)
OrientationLayouter
instance will mirror the graph for a given layout
orientation.
Horizontal orientations get mirrored at the x-axis while vertical orientations are mirrored at the y-axis.
orientation
- the layout orientation for which to check the mirror state
true
if the layout algorithm will mirror the graph at the corresponding axis for the given
layout orientation, false
otherwisesetOrientation(byte)
,
setMirrorMask(int)
protected void prepareOrientationChange(LayoutGraph graph)
It will rotate and mirror the coordinates and bounds of the graph layout such that the
core layout algorithm
can perform its calculations assuming the canonical
LayoutOrientation.TOP_TO_BOTTOM
orientation.
This method is called by doLayout(LayoutGraph)
before invoking the
core layout algorithm
. It might be overridden to extend the preparations to custom
layout features.
graph
- the input graphcompleteOrientationChange(LayoutGraph)
protected void completeOrientationChange(LayoutGraph graph)
It performs the inverse coordinate transformation that has been applied to the layout by method
prepareOrientationChange(LayoutGraph)
.
This method is called by doLayout(LayoutGraph)
after invoking the
core layout algorithm
. It may be overridden to extend the orientation change to
custom layout features.
graph
- the input graphprepareOrientationChange(LayoutGraph)
protected YPoint transform(YPoint point, boolean prepare)
This method is called by prepareOrientationChange(LayoutGraph)
and
completeOrientationChange(LayoutGraph)
to get the according point location.
point
- the original/calculated pointprepare
- true
if this method is called during preparation, false
if it is called
during completion
prepareOrientationChange(LayoutGraph)
,
completeOrientationChange(LayoutGraph)
,
prepareTransform(YPoint)
,
completeTransform(YPoint)
protected YPoint prepareTransform(YPoint point)
The point is transformed so it matches the LayoutOrientation.TOP_TO_BOTTOM
orientation.
point
- the original point
prepareOrientationChange(LayoutGraph)
protected YPoint completeTransform(YPoint point)
The point is transformed from LayoutOrientation.TOP_TO_BOTTOM
orientation to the desired orientation.
point
- the calculated point
completeOrientationChange(LayoutGraph)
public YInsets createOrientedInsets(java.awt.Insets insets)
createOrientedInsets(YInsets)
instead.
YInsets
that are a geometric transformation of the given Insets
.
The transform will correspond to the currently set orientation.
insets
- the original insets
setOrientation(byte)
public YInsets createOrientedInsets(YInsets insets)
YInsets
that are a geometric transformation of the given YInsets
.
The transform will correspond to the currently set orientation.
insets
- the original insets
setOrientation(byte)
public NodeHalo createOrientedNodeHalo(NodeHalo halo)
NodeHalo
that is a geometric transformation of the given NodeHalo
.
The transform will correspond to the currently set orientation.
halo
- the original NodeHalo
NodeHalo
setOrientation(byte)
public YDimension createOrientedNodeSize(YDimension nodeSize)
YDimension
that is a geometric transformation of the given size.
The transform will correspond to the currently set orientation.
nodeSize
- the original node size
setOrientation(byte)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |