|
Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.layout.CanonicMultiStageLayouter
public abstract class CanonicMultiStageLayouter
An abstract base class for layout algorithms that provides services to simplify and decompose the input graph
before it is passed to the core layout algorithm itself.
Subclasses of this layout algorithm have to provide implementations for the abstract methods:
canLayoutCore(LayoutGraph): Checks whether this layout algorithm can handle the given graph (e.g. tree
layout algorithms may only accept trees as input graph).
doLayoutCore(LayoutGraph): Invokes the actual layout routine of this layout algorithm. This is the main
method that provides the implementation of the core layout algorithm.
This class provides a configurable pipeline that contains LayoutStages that add preprocessing steps and/or
postprocessing steps to the layout algorithm. CanonicMultiStageLayouter
provides some predefined LayoutStages, that simplify the input graph for the layout algorithm and
complement the result. It is also possible to add custom LayoutStages which are executed
before or after the predefined ones.
Each LayoutStage in the pipeline wraps its successor. When the layout pipeline is processed, the
preprocessing code of the preceding LayoutStage is executed before the code in the current
LayoutStage while the postprocessing code is executed afterwards.
The pipeline of predefined LayoutStages of CanonicMultiStageLayouter
(when all are activated) causes the following sequence of steps:
layout algorithm on the simplified graph.
In order to take effect, a stage that is not already activated by default needs
to be activated using the corresponding method, e.g., setGroupNodeHidingEnabled(boolean).
Vice versa, a stage can also be deactivated, if necessary.
![]() |
![]() |
![]() |
![]() |
| Field Summary |
|---|
| Fields inherited from interface y.layout.Layouter |
|---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, NODE_TYPE_DPKEY, SELECTED_EDGES, SELECTED_NODES |
| Constructor Summary | |
|---|---|
CanonicMultiStageLayouter()
Creates a new CanonicMultiStageLayouter instance with default settings. |
|
| Method Summary | |
|---|---|
void |
appendStage(LayoutStage stage)
Appends the given LayoutStage to the layout pipeline. |
GraphLayout |
calcLayout(GraphInterface graph,
GraphLayout layout)
Calculates a layout for the given GraphInterface and GraphLayout instances. |
GraphLayout |
calcLayout(LayoutGraph graph)
Calculates a layout for the given input graph. |
boolean |
canLayout(LayoutGraph graph)
Checks whether or not the given graph can be handled by this layout algorithm. |
protected abstract boolean |
canLayoutCore(LayoutGraph graph)
Checks whether or not the core layout algorithm can layout the input graph. |
protected void |
checkGroupNodeSize(GraphLayout layout,
java.lang.Object node)
Checks the given group node for zero or negative width/height. |
protected void |
checkNodeSize(GraphLayout layout,
java.lang.Object node)
Checks the given node for zero or negative width/height. |
void |
doLayout(GraphInterface graph,
GraphLayout layout)
Calculates a layout for the given graph and writes it back to the given GraphLayout instance. |
void |
doLayout(LayoutGraph graph)
Calculates a layout for the given graph and applies it directly to the graph. |
protected abstract void |
doLayoutCore(LayoutGraph graph)
Invokes the core layout algorithm. |
void |
enableOnlyCore()
Deactivates all predefined LayoutStages so that upon doLayout(y.layout.LayoutGraph) only the
layout algorithm will be executed. |
LayoutStage |
getComponentLayouter()
Returns the LayoutStage that arranges the connected components of an input graph. |
LayoutStage |
getGroupNodeHider()
Returns the LayoutStage that hides the group nodes of the input graph. |
LayoutStage |
getLabelLayouter()
Returns the LayoutStage that places the labels of the input graph. |
byte |
getLayoutOrientation()
Returns the main orientation of the layout. |
LayoutStage |
getOrientationLayouter()
Returns the LayoutStage that modifies the orientation of a computed layout. |
LayoutStage |
getParallelEdgeLayouter()
Returns the LayoutStage that routes parallel edges. |
LayoutStage |
getSelfLoopLayouter()
Returns the LayoutStage that routes self-loops. |
LayoutStage |
getSubgraphLayouter()
Returns the LayoutStage that constrains the layout process to a subgraph of the input graph. |
boolean |
isComponentLayouterEnabled()
Returns whether or not the LayoutStage used for arranging the components of the graph is activated. |
boolean |
isGroupNodeHidingEnabled()
Returns whether or not the LayoutStage used for hiding group nodes is activated. |
boolean |
isLabelLayouterEnabled()
Returns whether or not the LayoutStage used for placing the labels of the input graph is activated. |
boolean |
isOrientationLayouterEnabled()
Returns whether or not the LayoutStage that modifies the orientation of the layout is activated. |
boolean |
isParallelEdgeLayouterEnabled()
Returns whether or not the LayoutStage used for routing parallel edges is activated. |
boolean |
isSelfLoopLayouterEnabled()
Returns whether or not the LayoutStage used for routing self-loops is activated. |
boolean |
isSubgraphLayouterEnabled()
Returns whether or not the LayoutStage used for constraining the layout process to a subgraph of the input
graph is activated. |
void |
prependStage(LayoutStage stage)
Prepends the given LayoutStage to the layout pipeline. |
void |
removeStage(LayoutStage stage)
Removes the given LayoutStage from the layout pipeline. |
void |
setComponentLayouter(LayoutStage layouter)
Specifies the LayoutStage that arranges the connected components of an input graph. |
void |
setComponentLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for arranging the components of the graph is activated. |
void |
setGroupNodeHider(LayoutStage layouter)
Specifies the LayoutStage that hides the group nodes of the input graph. |
void |
setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)
Specifies whether or not the LayoutStage used for hiding group nodes is activated. |
void |
setLabelLayouter(LayoutStage labeler)
Specifies the LayoutStage that places the labels of the input graph. |
void |
setLabelLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for placing the labels of the input graph is activated. |
void |
setLayoutOrientation(byte orientation)
Specifies the main orientation of the layout. |
void |
setOrientationLayouter(LayoutStage layouter)
Specifies the LayoutStage that modifies the orientation of a computed layout. |
void |
setOrientationLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage that modifies the orientation of the layout is activated. |
void |
setParallelEdgeLayouter(LayoutStage layouter)
Specifies the LayoutStage that routes parallel edges. |
void |
setParallelEdgeLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for routing parallel edges is activated. |
void |
setSelfLoopLayouter(LayoutStage layouter)
Specifies the LayoutStage that routes self-loops. |
void |
setSelfLoopLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for routing self-loops is activated. |
void |
setSubgraphLayouter(LayoutStage layouter)
Specifies the LayoutStage that constrains the layout process to a subgraph of the input graph. |
void |
setSubgraphLayouterEnabled(boolean enabled)
Specifies whether or not the LayoutStage used for constraining the layout process to a subgraph of the input
graph is activated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CanonicMultiStageLayouter()
CanonicMultiStageLayouter instance with default settings.
| Method Detail |
|---|
protected abstract void doLayoutCore(LayoutGraph graph)
This method should be implemented by subclasses in order to perform the layout routine of the layout algorithm.
graph - the input graphprotected abstract boolean canLayoutCore(LayoutGraph graph)
This method should be implemented by subclasses such that it determines whether or not the core layout algorithm accepts the input graph.
graph - the input graph
true if the core layout algorithm can handle the input graph, false otherwise
protected void checkNodeSize(GraphLayout layout,
java.lang.Object node)
throws java.lang.IllegalArgumentException
This method is called before the invocation of the core layouter for each normal node of the input graph. It may be overridden in order to obtain a custom implementation of the node size check or to remove it entirely.
layout - the GraphLayout instancenode - the node object
java.lang.IllegalArgumentException - if the width/height of the node object is zero or negativecheckGroupNodeSize(GraphLayout,Object),
canLayout(LayoutGraph),
doLayout(LayoutGraph),
doLayout(GraphInterface, GraphLayout),
calcLayout(LayoutGraph),
calcLayout(GraphInterface, GraphLayout)
protected void checkGroupNodeSize(GraphLayout layout,
java.lang.Object node)
throws java.lang.IllegalArgumentException
This method is called by doLayout(LayoutGraph) for each group node of the input graph.
It may be overridden in order to obtain a custom implementation of the group node size check or to remove it entirely.
layout - the GraphLayout instancenode - the group node object
java.lang.IllegalArgumentException - if the width/height of the group node object is zero or negativecheckNodeSize(GraphLayout,Object)public void prependStage(LayoutStage stage)
LayoutStage to the layout pipeline.
Stages that are added with this method will be invoked at the very beginning
of the layout pipeline.
This means before all previously prepended LayoutStages, all predefined
stages, and all appended LayoutStages.
stage - the LayoutStage instance to be addedremoveStage(LayoutStage),
appendStage(LayoutStage)public void appendStage(LayoutStage stage)
LayoutStage to the layout pipeline.
Stages that are added with this method will be invoked at the very end of
the layout pipeline.
This means after all prepended LayoutStages, all predefined stages,
and all previously appended LayoutStages, but just before the invocation
of the layout algorithm.
stage - the LayoutStage instance to be addedremoveStage(LayoutStage),
prependStage(LayoutStage)public void removeStage(LayoutStage stage)
LayoutStage from the layout pipeline.
This method can only remove LayoutStages that have been previously added using
appendStage(LayoutStage) or prependStage(LayoutStage). Predefined LayoutStages can be
deactivated separately.
stage - a LayoutStage to be removed from the layout pipelineprependStage(LayoutStage),
appendStage(LayoutStage),
setSelfLoopLayouterEnabled(boolean),
setParallelEdgeLayouterEnabled(boolean),
setOrientationLayouterEnabled(boolean),
setSubgraphLayouterEnabled(boolean),
setLabelLayouterEnabled(boolean),
setGroupNodeHidingEnabled(boolean),
setComponentLayouterEnabled(boolean)public LayoutStage getLabelLayouter()
LayoutStage that places the labels of the input graph.
LayoutStage needs to be activated in order to take
effect.LayoutStage instancesetLabelLayouter(LayoutStage),
setLabelLayouterEnabled(boolean),
SALabeling,
GreedyMISLabelingpublic void setLabelLayouter(LayoutStage labeler)
LayoutStage that places the labels of the input graph.
LayoutStage needs to be activated in order to take
effect.SALabeling. An instance of SALabeling with
SALabeling.setMaximalDuration(long) set to 0.labeler - the LayoutStage instancegetLabelLayouter(),
setLabelLayouterEnabled(boolean),
SALabeling,
GreedyMISLabelingpublic LayoutStage getSelfLoopLayouter()
LayoutStage that routes self-loops.
LayoutStage needs to be activated in order to
take effect.LayoutStage instancesetSelfLoopLayouter(LayoutStage),
setSelfLoopLayouterEnabled(boolean),
SelfLoopLayouterpublic void setSelfLoopLayouter(LayoutStage layouter)
LayoutStage that routes self-loops.
LayoutStage needs to be activated in order to
take effect.SelfLoopLayouterlayouter - the LayoutStage instancegetSelfLoopLayouter(),
setSelfLoopLayouterEnabled(boolean),
SelfLoopLayouterpublic LayoutStage getParallelEdgeLayouter()
LayoutStage that routes parallel edges.
LayoutStage needs to be activated in order
to take effect.LayoutStage instancesetParallelEdgeLayouter(LayoutStage),
setParallelEdgeLayouterEnabled(boolean),
ParallelEdgeLayouterpublic void setParallelEdgeLayouter(LayoutStage layouter)
LayoutStage that routes parallel edges.
LayoutStage needs to be activated in order
to take effect.ParallelEdgeLayouterlayouter - the LayoutStage instancegetParallelEdgeLayouter(),
setParallelEdgeLayouterEnabled(boolean),
ParallelEdgeLayouterpublic LayoutStage getComponentLayouter()
LayoutStage that arranges the connected components of an input graph.
LayoutStage needs to be activated in order to
take effect.layout algorithm separately. After all components are layouted, it
arranges them in relation to each other. Custom implementations should respect that the layout algorithm
may not be able to handle multiple connected components.LayoutStage instancesetComponentLayouter(LayoutStage),
setComponentLayouterEnabled(boolean),
ComponentLayouterpublic void setComponentLayouter(LayoutStage layouter)
LayoutStage that arranges the connected components of an input graph.
LayoutStage needs to be activated in order to
take effect.layout algorithm separately. After all components are layouted, it
arranges them in relation to each other. Custom implementations should respect that the layout algorithm
may not be able to handle multiple connected components.ComponentLayouterlayouter - the LayoutStage instancegetComponentLayouter(),
setComponentLayouterEnabled(boolean),
ComponentLayouterpublic LayoutStage getSubgraphLayouter()
LayoutStage that constrains the layout process to a subgraph of the input graph.
LayoutStage needs to be activated in order to
take effect.SubgraphLayouterLayoutStage instancesetSubgraphLayouter(LayoutStage),
setSubgraphLayouterEnabled(boolean),
SubgraphLayouterpublic void setSubgraphLayouter(LayoutStage layouter)
LayoutStage that constrains the layout process to a subgraph of the input graph.
LayoutStage needs to be activated in order to
take effect.SubgraphLayouterlayouter - the LayoutStage instancegetSubgraphLayouter(),
setSubgraphLayouterEnabled(boolean),
SubgraphLayouterpublic LayoutStage getGroupNodeHider()
LayoutStage that hides the group nodes of the input graph.
LayoutStage needs to be activated in order to
take effect.LayoutStage instancesetGroupNodeHider(LayoutStage),
setGroupNodeHidingEnabled(boolean),
GroupNodeHiderpublic void setGroupNodeHider(LayoutStage layouter)
LayoutStage that hides the group nodes of the input graph.
LayoutStage needs to be activated in order to
take effect.GroupNodeHiderlayouter - the LayoutStage instancegetGroupNodeHider(),
setGroupNodeHidingEnabled(boolean),
GroupNodeHiderpublic LayoutStage getOrientationLayouter()
LayoutStage that modifies the orientation of a computed layout.
LayoutStage using setLayoutOrientation(byte), it is necessary
that an instance of OrientationLayouter is used.LayoutStage instancesetOrientationLayouter(LayoutStage),
setOrientationLayouterEnabled(boolean),
setLayoutOrientation(byte),
OrientationLayouterpublic void setOrientationLayouter(LayoutStage layouter)
LayoutStage that modifies the orientation of a computed layout.
LayoutStage using setLayoutOrientation(byte), it is necessary
that an instance of OrientationLayouter is used.OrientationLayouterlayouter - the LayoutStage instancegetOrientationLayouter(),
setOrientationLayouterEnabled(boolean),
setLayoutOrientation(byte),
OrientationLayouterpublic void setOrientationLayouterEnabled(boolean enabled)
LayoutStage that modifies the orientation of the layout is activated.
This LayoutStage may be deactivated if the orientation is irrelevant for the layout or if the core layout
algorithm already handles the layout orientation by itself.
LayoutOrientation.TOP_TO_BOTTOM, the orientation of the layout
will not be modified.LayoutStage is activated.enabled - true if the stage that modifies the orientation is activated,
false otherwiseisOrientationLayouterEnabled(),
setOrientationLayouter(LayoutStage),
setLayoutOrientation(byte),
OrientationLayouterpublic void setLayoutOrientation(byte orientation)
This is a convenience method that configures the orientation layout stage.
OrientationLayouter. It has to be overridden to support LayoutStages that do not
extend OrientationLayouter.LayoutOrientation.TOP_TO_BOTTOMorientation - one of the default layout orientations
java.lang.IllegalArgumentException - if the specified orientation does not match a default layout orientationgetLayoutOrientation(),
setOrientationLayouter(LayoutStage),
setOrientationLayouterEnabled(boolean)public byte getLayoutOrientation()
This is a convenience method that configures the orientation layout stage.
OrientationLayouter. It has to be overridden to support LayoutStages that do not
extend OrientationLayouter.setLayoutOrientation(byte),
setOrientationLayouter(LayoutStage),
setOrientationLayouterEnabled(boolean)public boolean isOrientationLayouterEnabled()
LayoutStage that modifies the orientation of the layout is activated.
This LayoutStage may be deactivated if the orientation is irrelevant for the layout or if the core layout
algorithm already handles the layout orientation by itself.
LayoutOrientation.TOP_TO_BOTTOM, the orientation of the layout
will not be modified.true if the stage that modifies the orientation is activated, false otherwisesetOrientationLayouterEnabled(boolean),
setOrientationLayouter(LayoutStage),
setLayoutOrientation(byte),
OrientationLayouterpublic void setSelfLoopLayouterEnabled(boolean enabled)
LayoutStage used for routing self-loops is activated.
This LayoutStage should be deactivated if the layout algorithm handles
self-loops by itself.
enabled - true if the stage responsible for routing self-loops is activated, false otherwiseisSelfLoopLayouterEnabled(),
setSelfLoopLayouter(LayoutStage),
SelfLoopLayouterpublic boolean isSelfLoopLayouterEnabled()
LayoutStage used for routing self-loops is activated.
This LayoutStage should be deactivated if the layout algorithm handles
self-loops by itself.
true if the stage responsible for routing self-loops is activated, false otherwisesetSelfLoopLayouterEnabled(boolean),
setSelfLoopLayouter(LayoutStage),
SelfLoopLayouterpublic void setLabelLayouterEnabled(boolean enabled)
LayoutStage used for placing the labels of the input graph is activated.
This LayoutStage may be activated to apply a generic labeling algorithm to the input graph. It will then
try to find the best locations for the labels in the layout calculated by the
layout algorithm. When the stage is deactivated, the labels are ignored or
placed by an integrated labeling of the layout algorithm.
enabled - true if the stage responsible for placing the labels is activated, false otherwiseisLabelLayouterEnabled(),
setLabelLayouter(LayoutStage),
SALabeling,
GreedyMISLabelingpublic boolean isLabelLayouterEnabled()
LayoutStage used for placing the labels of the input graph is activated.
This LayoutStage may be activated to apply a generic labeling algorithm to the input graph. It will then
try to find the best locations for the labels in the layout calculated by the
layout algorithm. When the stage is deactivated, the labels are ignored or
placed by an integrated labeling of the layout algorithm.
true if the stage responsible for placing the labels is activated, false otherwisesetLabelLayouterEnabled(boolean),
setLabelLayouter(LayoutStage),
SALabeling,
GreedyMISLabelingpublic boolean isGroupNodeHidingEnabled()
LayoutStage used for hiding group nodes is activated.
This LayoutStage should be deactivated if the layout algorithm handles
group nodes itself.
true if the stage used for hiding group nodes is activated, false otherwisesetGroupNodeHidingEnabled(boolean),
setGroupNodeHider(LayoutStage),
GroupNodeHiderpublic void setGroupNodeHidingEnabled(boolean groupNodeHidingEnabled)
LayoutStage used for hiding group nodes is activated.
This LayoutStage should be deactivated if the layout algorithm handles
group nodes itself.
groupNodeHidingEnabled - true if the stage used for hiding group nodes is activated,
false otherwiseisGroupNodeHidingEnabled(),
setGroupNodeHider(LayoutStage),
GroupNodeHiderpublic void setComponentLayouterEnabled(boolean enabled)
LayoutStage used for arranging the components of the graph is activated.
This LayoutStage should be deactivated if the layout algorithm is able
to handle several connected components.
enabled - true if the stage that arranges the graph components is activated,
false otherwiseisComponentLayouterEnabled(),
setComponentLayouter(LayoutStage),
ComponentLayouterpublic boolean isComponentLayouterEnabled()
LayoutStage used for arranging the components of the graph is activated.
This LayoutStage should be deactivated if the layout algorithm is able
to handle several connected components.
true if the stage that arranges the graph components is activated,
false otherwisesetComponentLayouterEnabled(boolean),
setComponentLayouter(LayoutStage),
ComponentLayouterpublic void setParallelEdgeLayouterEnabled(boolean enabled)
LayoutStage used for routing parallel edges is activated.
This LayoutStage should be deactivated if the layout algorithm handles
parallel edges itself.
enabled - true if the stage responsible for routing parallel edges is activated, false otherwiseisParallelEdgeLayouterEnabled(),
setParallelEdgeLayouter(LayoutStage),
ParallelEdgeLayouterpublic boolean isParallelEdgeLayouterEnabled()
LayoutStage used for routing parallel edges is activated.
This LayoutStage should be deactivated if the layout algorithm handles
parallel edges itself.
true if the stage responsible for routing parallel edges is activated, false otherwisesetParallelEdgeLayouterEnabled(boolean),
setParallelEdgeLayouter(LayoutStage),
ParallelEdgeLayouterpublic void setSubgraphLayouterEnabled(boolean enabled)
LayoutStage used for constraining the layout process to a subgraph of the input
graph is activated. This LayoutStage may be activated if the
layout algorithm should be applied only to a specific part of the graph. The remaining
graph will stay unchanged.
enabled - true if the stage that constrains the input graph to a subgraph is activated,
false otherwiseisSubgraphLayouterEnabled(),
setSubgraphLayouter(LayoutStage),
SubgraphLayouterpublic boolean isSubgraphLayouterEnabled()
LayoutStage used for constraining the layout process to a subgraph of the input
graph is activated. This LayoutStage may be activated if the
layout algorithm should be applied only to a specific part of the graph. The remaining
graph will stay unchanged.
true if the stage that constrains the input graph to a subgraph is activated,
false otherwisesetSubgraphLayouterEnabled(boolean),
setSubgraphLayouter(LayoutStage),
SubgraphLayouterpublic void enableOnlyCore()
LayoutStages so that upon doLayout(y.layout.LayoutGraph) only the
layout algorithm will be executed.
LayoutStages prepare the graph for the layout algorithm,
i.e., they can temporarily hide elements. If the layout algorithm cannot handle those elements, e.g.,
group nodes, it may not work well on the input graph.public void doLayout(LayoutGraph graph)
LayoutStages in the layout pipeline as well as the layout algorithm.
doLayout in interface Layoutergraph - the input graphappendStage(LayoutStage),
prependStage(LayoutStage),
doLayoutCore(LayoutGraph)
public void doLayout(GraphInterface graph,
GraphLayout layout)
GraphLayout instance. This method
executes all activated LayoutStages in the layout pipeline as well as the layout algorithm.
graph - the input graphlayout - the GraphLayout instance to which the layout information is appliedappendStage(LayoutStage),
prependStage(LayoutStage),
doLayoutCore(LayoutGraph)public GraphLayout calcLayout(LayoutGraph graph)
LayoutStages in the
layout pipeline as well as the layout algorithm.
graph - the input graph
appendStage(LayoutStage),
prependStage(LayoutStage),
doLayoutCore(LayoutGraph)
public GraphLayout calcLayout(GraphInterface graph,
GraphLayout layout)
GraphInterface and GraphLayout instances. This method executes
all activated LayoutStages in the layout pipeline as well as the
layout algorithm.
graph - the GraphInterfacelayout - the GraphLayout
appendStage(LayoutStage),
prependStage(LayoutStage),
doLayoutCore(LayoutGraph)public boolean canLayout(LayoutGraph graph)
All activated LayoutStages and layout algorithm must be able to
calculate the layout to make this test successful.
canLayout in interface Layoutergraph - the input graph
true if the input graph can be handled by the given layout algorithm, false otherwiseLayouter.doLayout(LayoutGraph)
|
© Copyright 2000-2025, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||