|
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.partial.PartialLayouter
public class PartialLayouter
This class represents a partial layouter. A partial layouter is a layout algorithm that changes the coordinates for a given set of graph elements (called partial elements). The location or size of the remaining elements (called fixed elements) is not allowed to be changed. The layout algorithm tries to place the partial elements such that the resulting drawing (including the fixed elements) has a good quality with respect to common graph drawing aesthetics.
This layouter can be applied to plain graphs as well as to grouped graphs. Note: when a partial node should be placed inside a fixed group node, it is important that there is enough free space inside the group. Otherwise, there may be overlapping node elements.
The layouter handles each selected graph element as partial element. Therefore it looks up the data provider keys
PARTIAL_NODES_DPKEY
and PARTIAL_EDGES_DPKEY
. Partial node elements can be
assigned to so called subgraph components. During the layout process each subgraph induced by the nodes of a
component is first laid out using the specified core layouter setCoreLayouter(y.layout.Layouter)
. Then, the
different components are placed one-by-one onto the drawing area such that the number of overlaps among graph
elements is small. The user can specify different objectives for finding 'good' positions for subgraph components
(setPositioningStrategy(byte)
), e.g., SUBGRAPH_POSITIONING_STRATEGY_BARYCENTER
specifies that the
component should be placed close to the barycenter of its graph neighbors and SUBGRAPH_POSITIONING_STRATEGY_FROM_SKETCH
specifies that the component should be placed close to its original
position.
Method setComponentAssignmentStrategy(byte)
allows to specify the strategy that is used
to assign partial nodes to subgraph components. Possible values are COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
,
COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
, COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
and COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
. The last value allows to use a customized component assignment. Note:
nodes of a component cannot be assigned to different group nodes.
Furthermore, the user can specify the edge
routing strategy (method setEdgeRoutingStrategy(byte)
) that is used for routing partial edges and edges
between different subgraph components (so-called inter-edges). Possible values are EDGE_ROUTING_STRATEGY_ORGANIC
, EDGE_ROUTING_STRATEGY_ORTHOGONAL
, EDGE_ROUTING_STRATEGY_STRAIGHTLINE
, EDGE_ROUTING_STRATEGY_OCTILINEAR
and EDGE_ROUTING_STRATEGY_AUTOMATIC
.
Nested Class Summary | |
---|---|
static class |
PartialLayouter.StraightLineEdgeRouter
Simple Edge Router that draws edges straight-line. |
Field Summary | |
---|---|
static Object |
COMPONENT_ASSIGNMENT_DPKEY
DataProvider key used to store an object for each partial node of the graph. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
Specifier for the strategy that is used to assign partial nodes to subgraph components. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
Specifier for the strategy that is used to assign partial nodes to subgraph components. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
Specifier for the strategy that is used to assign partial nodes to subgraph components. |
static byte |
COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
Specifier for the strategy that is used to assign partial nodes to subgraph components. |
static byte |
EDGE_ROUTING_STRATEGY_AUTOMATIC
Specifier for the routing strategy of inter-edges (edges between fixed and partial nodes as well as edges between different subgraph components). |
static byte |
EDGE_ROUTING_STRATEGY_OCTILINEAR
Specifier for the routing strategy of inter-edges (edges between fixed and partial nodes as well as edges between different subgraph components). |
static byte |
EDGE_ROUTING_STRATEGY_ORGANIC
Specifier for the routing strategy of inter-edges (edges between fixed and partial nodes as well as edges between different subgraph components). |
static byte |
EDGE_ROUTING_STRATEGY_ORTHOGONAL
Specifier for the routing strategy of inter-edges (edges between fixed and partial nodes as well as edges between different subgraph components). |
static byte |
EDGE_ROUTING_STRATEGY_STRAIGHTLINE
Specifier for the routing strategy of inter-edges (edges between fixed and partial nodes as well as edges between different subgraph components). |
static byte |
ORIENTATION_AUTO_DETECTION
Specifies the orientation of the drawing. |
static byte |
ORIENTATION_BOTTOM_TO_TOP
Specifies the orientation of the drawing. |
static byte |
ORIENTATION_LEFT_TO_RIGHT
Specifies the orientation of the drawing. |
static byte |
ORIENTATION_NONE
Specifies the orientation of the drawing. |
static byte |
ORIENTATION_RIGHT_TO_LEFT
Specifies the orientation of the drawing. |
static byte |
ORIENTATION_TOP_TO_BOTTOM
Specifies the orientation of the drawing. |
static Object |
PARTIAL_EDGES_DPKEY
The data provider key used to look up the partial edges of the graph. |
static Object |
PARTIAL_NODES_DPKEY
The data provider key used to look up the partial nodes of the graph. |
static String |
ROUTE_EDGE_DPKEY
The data provider key used to mark edges for routing. |
static byte |
SUBGRAPH_POSITIONING_STRATEGY_BARYCENTER
Specifies the objective used for finding 'good' positions for subgraph components. |
static byte |
SUBGRAPH_POSITIONING_STRATEGY_FROM_SKETCH
Specifies the objective used for finding 'good' positions for subgraph components. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
PartialLayouter()
Creates a new instance of the PartialLayouter. |
|
PartialLayouter(Layouter subgraphLayouter)
Creates a new instance of the PartialLayouter. |
Method Summary | |
---|---|
boolean |
canLayout(LayoutGraph graph)
Returns true iff the given graph can be laid
out by this algorithm. |
protected void |
configureEdgeRouter(Layouter edgeRouter)
This method is called each time edges are routed with an edge router instance. |
void |
doLayout(LayoutGraph graph)
Main layout routine that assigns new layout information to the given graph. |
void |
doPartialLayout(LayoutGraph graph)
This method calculates the partial layout. |
byte |
getComponentAssignmentStrategy()
Returns the strategy that is used to assign partial nodes to subgraph components. |
Layouter |
getCoreLayouter()
Returns the core layouter, i.e., the layout algorithm that is applied to the subgraph components. |
Layouter |
getEdgeRouter()
Returns the edge router used for routing partial edges as well as edges between different subgraph components (so-called inter-edges). |
byte |
getEdgeRoutingStrategy()
Return the specified edge routing strategy. |
byte |
getLayoutOrientation()
Returns the layout orientation. |
long |
getMaximalDuration()
Returns the time limit (in milliseconds) set for the layout algorithm. |
int |
getMinimalNodeDistance()
Returns the minimum distance between two adjacent nodes. |
byte |
getPositioningStrategy()
Returns the objective used for finding 'good' positions for subgraph components. |
boolean |
isConsiderNodeAlignment()
Returns true, if node alignment is enabled, that is the algorithm tries to align partial nodes with other nodes. |
boolean |
isFixedGroupResizingEnabled()
Returns whether or not fixed group nodes may be resized. |
boolean |
isMirroringAllowed()
Returns whether or not subgraph components may be mirrored to improve the layout quality, i.e., for each component the algorithm checks which of the four possible mirrorings minimizes the edge length. |
boolean |
isOrientationOptimizationEnabled()
Returns whether or not a postprocessing step should be applied to reduce the number of edges that do not comply with the desired orientation. |
boolean |
isPackComponentsEnabled()
If enabled, the bounding boxes of subgraph components may overlap (elements of different components will still not overlap). |
boolean |
isRouteInterEdgesImmediatelyEnabled()
Returns whether or not edges between different subgraph components should be routed immediately. |
protected void |
layoutSubgraph(LayoutGraph subGraph)
Calculates the layout for the subgraph component. |
protected void |
placeSubgraphs(LayoutGraph graph,
NodeList[] subgraphComponents)
This method places the subgraph components one-by-one onto the drawing area. |
protected void |
routeEdgesBetweenFixedElements(LayoutGraph graph,
EdgeList partialEdges)
This method routes all partial edges that connect two fixed elements. |
protected void |
routeInterEdges(LayoutGraph graph,
EdgeList interEdges)
This method routes all inter-edges, that is edges between different subgraph components (including edges between fixed and partial elements). |
void |
setComponentAssignmentStrategy(byte strategy)
Specifies the strategy that is used to assign partial nodes to subgraph components. |
void |
setConsiderNodeAlignment(boolean considerNodeAlignment)
Specifies whether or not nodes should be aligned. |
void |
setCoreLayouter(Layouter layouter)
Sets the core layouter, i.e., the layout algorithm that is applied to the subgraph components. |
void |
setEdgeRouter(Layouter edgeRouter)
Sets a customized edge router. |
void |
setEdgeRoutingStrategy(byte strategy)
This method allows to specify the edge routing strategy that is used for routing partial edges and edges between different subgraph components (so-called inter-edges). |
void |
setFixedGroupResizingEnabled(boolean fixedGroupResizingEnabled)
Specifies whether or not fixed (non-partial) group nodes may be resized. |
void |
setLayoutOrientation(byte layoutOrientation)
Specifies the layout orientation. |
void |
setMaximalDuration(long maximalDuration)
Sets a preferred time limit (in milliseconds) for the layout algorithm. |
void |
setMinimalNodeDistance(int minimalNodeDistance)
Sets the minimum distance between two adjacent nodes. |
void |
setMirroringAllowed(boolean mirroringAllowed)
Specifies whether or not subgraph components may be mirrored to improve the layout quality, i.e., for each component the algorithm checks which of the four possible mirrorings minimizes the edge length. |
void |
setOrientationOptimizationEnabled(boolean enabled)
Specifies whether or not a postprocessing step should be applied to reduce the number of edges that do not comply with the desired orientation. |
void |
setPackComponentsEnabled(boolean packComponentsEnabled)
Packing subgraph components leads to more compact layout results. |
void |
setPositioningStrategy(byte strategy)
Specifies the objective used for finding 'good' positions for subgraph components. |
void |
setRouteInterEdgesImmediatelyEnabled(boolean enabled)
Whether or not edges between different subgraph components should be routed immediately. |
Methods inherited from class y.layout.AbstractLayoutStage |
---|
canLayoutCore, doLayoutCore |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final Object PARTIAL_NODES_DPKEY
public static final Object PARTIAL_EDGES_DPKEY
public static final String ROUTE_EDGE_DPKEY
getBool
method will return true
for edges that have to be
routed and false
for all other edges.
setEdgeRouter(y.layout.Layouter)
,
Constant Field Valuespublic static final byte EDGE_ROUTING_STRATEGY_ORTHOGONAL
getEdgeRoutingStrategy()
,
setEdgeRoutingStrategy(byte)
,
Constant Field Valuespublic static final byte EDGE_ROUTING_STRATEGY_STRAIGHTLINE
getEdgeRoutingStrategy()
,
setEdgeRoutingStrategy(byte)
,
Constant Field Valuespublic static final byte EDGE_ROUTING_STRATEGY_AUTOMATIC
getEdgeRoutingStrategy()
,
setEdgeRoutingStrategy(byte)
,
Constant Field Valuespublic static final byte EDGE_ROUTING_STRATEGY_ORGANIC
getEdgeRoutingStrategy()
,
setEdgeRoutingStrategy(byte)
,
Constant Field Valuespublic static final byte EDGE_ROUTING_STRATEGY_OCTILINEAR
getEdgeRoutingStrategy()
,
setEdgeRoutingStrategy(byte)
,
Constant Field Valuespublic static final Object COMPONENT_ASSIGNMENT_DPKEY
DataProvider
key used to store an object for each partial node of the graph. All partial nodes
associated with the same object are assigned to the same subgraph component. Note: nodes of a component cannot be
assigned to different group nodes as well as different partition cells.
COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
,
getComponentAssignmentStrategy()
,
setComponentAssignmentStrategy(byte)
public static final byte COMPONENT_ASSIGNMENT_STRATEGY_SINGLE
getComponentAssignmentStrategy()
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CONNECTED
getComponentAssignmentStrategy()
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CLUSTERING
getComponentAssignmentStrategy()
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte COMPONENT_ASSIGNMENT_STRATEGY_CUSTOMIZED
COMPONENT_ASSIGNMENT_DPKEY
.
getComponentAssignmentStrategy()
,
setComponentAssignmentStrategy(byte)
,
Constant Field Valuespublic static final byte SUBGRAPH_POSITIONING_STRATEGY_BARYCENTER
getPositioningStrategy()
,
setPositioningStrategy(byte)
,
Constant Field Valuespublic static final byte SUBGRAPH_POSITIONING_STRATEGY_FROM_SKETCH
getPositioningStrategy()
,
setPositioningStrategy(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_TOP_TO_BOTTOM
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_BOTTOM_TO_TOP
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_LEFT_TO_RIGHT
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_RIGHT_TO_LEFT
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_AUTO_DETECTION
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field Valuespublic static final byte ORIENTATION_NONE
getLayoutOrientation()
,
setLayoutOrientation(byte)
,
Constant Field ValuesConstructor Detail |
---|
public PartialLayouter()
public PartialLayouter(Layouter subgraphLayouter)
subgraphLayouter
- the layout algorithm that is applied to the subgraph components.Method Detail |
---|
public void setCoreLayouter(Layouter layouter)
setCoreLayouter
in interface LayoutStage
setCoreLayouter
in class AbstractLayoutStage
public Layouter getCoreLayouter()
getCoreLayouter
in interface LayoutStage
getCoreLayouter
in class AbstractLayoutStage
public long getMaximalDuration()
setMaximalDuration(long)
public void setMaximalDuration(long maximalDuration)
maximalDuration
- the time limit.getMaximalDuration()
public boolean isRouteInterEdgesImmediatelyEnabled()
setRouteInterEdgesImmediatelyEnabled(boolean)
public void setRouteInterEdgesImmediatelyEnabled(boolean enabled)
enabled
- if true
edges between different subgraph
components should be routed immediately.isRouteInterEdgesImmediatelyEnabled()
,
routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)
,
placeSubgraphs(y.layout.LayoutGraph, y.base.NodeList[])
public boolean isPackComponentsEnabled()
setPackComponentsEnabled(boolean)
public void setPackComponentsEnabled(boolean packComponentsEnabled)
isPackComponentsEnabled()
public boolean isFixedGroupResizingEnabled()
setFixedGroupResizingEnabled(boolean)
public void setFixedGroupResizingEnabled(boolean fixedGroupResizingEnabled)
isFixedGroupResizingEnabled()
public byte getPositioningStrategy()
setPositioningStrategy(byte)
public void setPositioningStrategy(byte strategy)
strategy
- one of
getPositioningStrategy()
public int getMinimalNodeDistance()
public void setMinimalNodeDistance(int minimalNodeDistance)
minimalNodeDistance
- the minimum distance to usepublic boolean isConsiderNodeAlignment()
setConsiderNodeAlignment(boolean)
public void setConsiderNodeAlignment(boolean considerNodeAlignment)
isConsiderNodeAlignment()
public boolean canLayout(LayoutGraph graph)
Layouter
true
iff the given graph can be laid
out by this algorithm. Calling doLayout
with
the given graph as its argument will only success if
this method returns true
.
public byte getComponentAssignmentStrategy()
setComponentAssignmentStrategy(byte)
public void setComponentAssignmentStrategy(byte strategy)
strategy
- one of
getComponentAssignmentStrategy()
public boolean isOrientationOptimizationEnabled()
By default, this feature is disabled.
setOrientationOptimizationEnabled(boolean)
,
getLayoutOrientation()
,
setLayoutOrientation(byte)
public void setOrientationOptimizationEnabled(boolean enabled)
By default, this feature is disabled.
enabled
- true
, if the postprocessing should be applied.getLayoutOrientation()
,
setLayoutOrientation(byte)
public Layouter getEdgeRouter()
setEdgeRouter(y.layout.Layouter)
,
setEdgeRoutingStrategy(byte)
public void setEdgeRouter(Layouter edgeRouter)
ROUTE_EDGE_DPKEY
data provider key.
Note: the customized edge router is disabled when method setEdgeRoutingStrategy(byte)
is called
afterwards.
edgeRouter
- the customized edge router.ROUTE_EDGE_DPKEY
,
getEdgeRouter()
,
setEdgeRoutingStrategy(byte)
public byte getEdgeRoutingStrategy()
setEdgeRoutingStrategy(byte)
public void setEdgeRoutingStrategy(byte strategy)
Note: calling this method disables a previously set customized edge router (see method
setEdgeRouter(y.layout.Layouter)
).
strategy
- one of
getEdgeRoutingStrategy()
,
setEdgeRouter(y.layout.Layouter)
public byte getLayoutOrientation()
ORIENTATION_TOP_TO_BOTTOM
,
ORIENTATION_BOTTOM_TO_TOP
,
ORIENTATION_LEFT_TO_RIGHT
,
ORIENTATION_RIGHT_TO_LEFT
,
ORIENTATION_AUTO_DETECTION
,
ORIENTATION_NONE
public void setLayoutOrientation(byte layoutOrientation)
ORIENTATION_TOP_TO_BOTTOM
,
ORIENTATION_BOTTOM_TO_TOP
,
ORIENTATION_LEFT_TO_RIGHT
,
ORIENTATION_RIGHT_TO_LEFT
,
ORIENTATION_AUTO_DETECTION
,
ORIENTATION_NONE
public boolean isMirroringAllowed()
setMirroringAllowed(boolean)
public void setMirroringAllowed(boolean mirroringAllowed)
mirroringAllowed
- whether or not subgraph components may be mirrored/rotated.isMirroringAllowed()
public void doLayout(LayoutGraph graph)
Layouter
public void doPartialLayout(LayoutGraph graph)
routeEdgesBetweenFixedElements(y.layout.LayoutGraph, y.base.EdgeList)
2. layoutSubgraph(y.layout.LayoutGraph)
for each subgraph component 3. placeSubgraphs(y.layout.LayoutGraph,
y.base.NodeList[])
4. routeInterEdges(y.layout.LayoutGraph, y.base.EdgeList)
Note: the method is called after applying the OrientationLayouter
. Hence, the called methods
always assume that the graph is drawn from top to bottom.
graph
- the input graph.protected void layoutSubgraph(LayoutGraph subGraph)
subGraph
- the subgraph componentprotected void placeSubgraphs(LayoutGraph graph, NodeList[] subgraphComponents)
setPositioningStrategy(byte)
).
graph
- the input graphsubgraphComponents
- each entry contains a NodeList that defines a subgraph componentprotected void routeInterEdges(LayoutGraph graph, EdgeList interEdges)
setEdgeRouter(y.layout.Layouter)
. If no edge router was specified
by the user, it uses an internal edge router with routing strategy
getEdgeRoutingStrategy()
.
graph
- the original graph.interEdges
- the edges to route.protected void routeEdgesBetweenFixedElements(LayoutGraph graph, EdgeList partialEdges)
setEdgeRouter(y.layout.Layouter)
. If no edge router was specified by the user, it uses an internal
edge router with routing strategy getEdgeRoutingStrategy()
.
graph
- the original graph.partialEdges
- the edges to route.protected void configureEdgeRouter(Layouter edgeRouter)
The type of the given instance depends on the edge routing strategy, i.e.,
if the routing strategy is set to EDGE_ROUTING_STRATEGY_OCTILINEAR
or
EDGE_ROUTING_STRATEGY_ORTHOGONAL
it's an instance of PartialLayouter.StraightLineEdgeRouter
, if the routing strategy is set
to EDGE_ROUTING_STRATEGY_ORGANIC
it's an instance of SmartOrganicLayouter
, and, if the routing
strategy is set to EDGE_ROUTING_STRATEGY_STRAIGHTLINE
it's an instance of PartialLayouter.StraightLineEdgeRouter
.
If the edge routing strategy is set to EDGE_ROUTING_STRATEGY_AUTOMATIC
one of the above strategies is used.
Note: if a customized edge router is set (see setEdgeRouter(y.layout.Layouter)
),
the edge router instance is of this type.
edgeRouter
- the instance used for routing the edges.setEdgeRouter(y.layout.Layouter)
,
setEdgeRoutingStrategy(byte)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |