|
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.ComponentLayouter
public class ComponentLayouter
This layout stage arranges the connected components of a graph.
It is possible to specify a core layout algorithm that will be invoked on all connected components of the graph before this layouter arranges the components themselves.
ComponentLayouter will handle hierarchically grouped graphs in a special way. The contents of a group node will always belong to the same component as the group node itself.
Field Summary | |
---|---|
static Object |
GIVEN_COMPONENT_ID_DPKEY
DataProvider key that can be used to determine components by hand. |
static Object |
LAYOUT_NODE_DPKEY
DataProvider key that can be used to determine which nodes should be laid out. |
static byte |
STYLE_MASK
Use this constant for masking actual styles constants from style modifiers. |
static byte |
STYLE_MODIFIER_AS_IS
Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should take the initial positions of the components into account. |
static byte |
STYLE_MODIFIER_NO_OVERLAP
Modifier constant that can be added to normal style constants to indicate that the arrangement strategy should produce a non-overlapping component layout. |
static byte |
STYLE_NONE
Style specification constant describing no special component arrangement at all. |
static byte |
STYLE_PACKED_CIRCLE
Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component. |
static byte |
STYLE_PACKED_COMPACT_CIRCLE
Style specification constant describing a component arrangement strategy that tries to place components like in a cloud around the biggest component. |
static byte |
STYLE_PACKED_COMPACT_RECTANGLE
Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component. |
static byte |
STYLE_PACKED_RECTANGLE
Style specification constant describing a component arrangement strategy that tries to place components like in a rectangular cloud around the biggest component. |
static byte |
STYLE_ROWS
Style specification constant describing a component arrangement strategy that tries to place components in multiple rows so that the overall aspect ratio of all components gets as close to the aspect ratio of the preferred layout size as possible. |
static byte |
STYLE_SINGLE_COLUMN
Style specification constant describing a component arrangement strategy that places components above each other in a single column. |
static byte |
STYLE_SINGLE_ROW
Style specification constant describing a component arrangement strategy that places components next to each other in a single row. |
Fields inherited from interface y.layout.Layouter |
---|
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES |
Constructor Summary | |
---|---|
ComponentLayouter()
Initializes a new ComponentLayouter instance. |
|
ComponentLayouter(Layouter coreLayouter)
Initializes a new ComponentLayouter instance. |
Method Summary | |
---|---|
protected void |
arrangeComponents(LayoutGraph graph,
NodeList[] nodes,
EdgeList[] edges,
YRectangle[] bbox,
Rectangle2D[] boxes)
Produces a non-overlapping component graph layout. |
protected void |
arrangeFields(LayoutGraph graph,
NodeList[] nodes,
EdgeList[] edges,
YRectangle[] bbox,
Rectangle2D[] boxes,
boolean circular,
boolean fill,
boolean fromSketch)
|
protected Rectangle2D |
calcBoundingBox(LayoutGraph graph)
Calculates and returns the bounding box of a graph component. |
boolean |
canLayout(LayoutGraph graph)
Determines if the preconditions for the graph layout algorithm are fulfilled, by applying them to the connected components. |
void |
doLayout(LayoutGraph graph)
Calculate the layout. |
protected int |
findGraphComponents(LayoutGraph graph,
NodeMap compNumber)
Determines which nodes will belong to the same graph component. |
double |
getComponentSpacing()
Returns the current component spacing. |
double |
getGridSpacing()
Returns the current grid spacing. |
YDimension |
getPreferredLayoutSize()
Gets the preferred layout size for this layouter. |
byte |
getStyle()
Returns the component arrangement style used by this ComponentLayouter . |
boolean |
isComponentArrangementEnabled()
Returns whether or not the separately laid out components of the input graph should be arranged by this class. |
boolean |
isGroupingActive()
Determines whether or not grouping information bound to the graph will be used to calculate the components. |
boolean |
isLabelAwarenessEnabled()
Determines whether or not to take node and edge labels into account when calculating the bounding box of the graph components. |
void |
setComponentArrangementEnabled(boolean enabled)
Sets whether or not the separately laid out components of the input graph should be arranged by this class. |
void |
setComponentSpacing(double componentSpacing)
Specifies the current component spacing. |
void |
setGridSpacing(double gridSpacing)
Specifies the current grid spacing. |
void |
setGroupingActive(boolean groupingActive)
Specifies whether or not grouping information bound to the graph should be used to determine the connectedness of the graph structure. |
void |
setLabelAwarenessEnabled(boolean enabled)
Specifies whether or not to take node and edge labels into account when calculating the bounding box of the graph components. |
protected void |
setOrigin(LayoutGraph graph,
NodeList nl,
EdgeList el,
YPoint org,
YRectangle r)
Sets the origin for a subgraph. |
void |
setPreferredLayoutSize(double width,
double height)
Sets the preferred layout size for this layouter. |
void |
setStyle(byte style)
Sets the component arrangement style used by this ComponentLayouter . |
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 Object LAYOUT_NODE_DPKEY
true
if queried through the
DataProvider instance. If no such instance is registered with the graph,
all components will be laid out by the core layout algorithm.
public static final Object GIVEN_COMPONENT_ID_DPKEY
DataProvider.get(Object)
method to query for
object instances that will be used to determine components:
If null
is returned for a node that node's component will be determined as usual.
If non-null
values are returned, they will be compared using their natural order
(Comparable
) to determine the component order.
public static final byte STYLE_NONE
STYLE_MODIFIER_NO_OVERLAP
components might get moved so that they don't overlap after the layout.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_ROWS
setStyle(byte)
,
setPreferredLayoutSize(double, double)
,
Constant Field Valuespublic static final byte STYLE_SINGLE_ROW
STYLE_MODIFIER_AS_IS
components will be placed in the same order as they were placed before the layout.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_SINGLE_COLUMN
STYLE_MODIFIER_AS_IS
components will be placed in the same order as they were placed before the layout.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_PACKED_RECTANGLE
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_PACKED_COMPACT_RECTANGLE
STYLE_PACKED_RECTANGLE
components might even be placed in empty spaces inside other components.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_PACKED_CIRCLE
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_PACKED_COMPACT_CIRCLE
STYLE_PACKED_CIRCLE
components might even be placed in empty spaces inside other components.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_MASK
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_MODIFIER_AS_IS
STYLE_SINGLE_ROW
, STYLE_SINGLE_COLUMN
, STYLE_PACKED_RECTANGLE
,
STYLE_PACKED_COMPACT_RECTANGLE
, STYLE_PACKED_CIRCLE
, and
STYLE_PACKED_COMPACT_CIRCLE
.
setStyle(byte)
,
Constant Field Valuespublic static final byte STYLE_MODIFIER_NO_OVERLAP
STYLE_NONE
.
Note that non-overlapping component layout (in the sense that no elements from
adjacent components overlap) is inherently supported by the following styles:
STYLE_PACKED_RECTANGLE
, STYLE_PACKED_COMPACT_RECTANGLE
, STYLE_PACKED_CIRCLE
,
and STYLE_PACKED_COMPACT_CIRCLE
.
setStyle(byte)
,
Constant Field ValuesConstructor Detail |
---|
public ComponentLayouter(Layouter coreLayouter)
ComponentLayouter
instance.
coreLayouter
- the layout algorithm that is invoked for connected
components of the input graph.doLayout(LayoutGraph)
public ComponentLayouter()
ComponentLayouter
instance.
setPreferredLayoutSize(double, double)
Method Detail |
---|
public void setPreferredLayoutSize(double width, double height)
width
- the preferred width of the calculated graph layout.height
- the preferred height of the calculated graph layout.getPreferredLayoutSize()
public YDimension getPreferredLayoutSize()
setPreferredLayoutSize(double, double)
public boolean canLayout(LayoutGraph graph)
protected int findGraphComponents(LayoutGraph graph, NodeMap compNumber)
graph
- the input graphcompNumber
- return value that will hold the zero-based number
of the component that it belongs to. The component number of
Node v
is compNum.getInt(v)
.
public void doLayout(LayoutGraph graph)
AbstractLayoutStage.getCoreLayouter()
,
ComponentLayouter(Layouter)
protected Rectangle2D calcBoundingBox(LayoutGraph graph)
labelAwarenessEnabled
the returned bounding box will
also take node and edge labels into account.
public void setLabelAwarenessEnabled(boolean enabled)
By default this feature is enabled.
enabled
- if true
node and edge labels are taken into
account when calculating the bounding box of the graph components.calcBoundingBox(LayoutGraph graph)
,
isLabelAwarenessEnabled()
public boolean isLabelAwarenessEnabled()
By default this feature is enabled.
true
if node and edge labels are taken into account
when calculating the bounding box of the graph components;
false
otherwise.setLabelAwarenessEnabled(boolean)
protected void arrangeComponents(LayoutGraph graph, NodeList[] nodes, EdgeList[] edges, YRectangle[] bbox, Rectangle2D[] boxes)
graph
- the layout graph.nodes
- array of type NodeList. The i-th NodeList contains all nodes of the i-th graph component.edges
- array of type EdgeList. The i-th NodeList contains all edges of the i-th graph component.bbox
- array of type YRectangle. The i-th YRectangle contains the current bounding box of the i-th graph component.boxes
- array of type Rectangle2D. The i-th Rectangle2D contains the extended bounding box of the i-th graph component.
The method arrange these boxes in such a way that they do not overlap. Then the i-th graph component must be placed
inside the i-th box.public void setComponentArrangementEnabled(boolean enabled)
By default this feature is enabled.
enabled
- if true
separately laid out components of the
input graph are arranged by this class.isComponentArrangementEnabled()
public boolean isComponentArrangementEnabled()
By default this feature is enabled.
true
if separately laid out components of the input
graph are arranged by this class; false
otherwise.setComponentArrangementEnabled(boolean)
protected void setOrigin(LayoutGraph graph, NodeList nl, EdgeList el, YPoint org, YRectangle r)
public double getGridSpacing()
public void setGridSpacing(double gridSpacing)
gridSpacing
- the current grid spacing.public double getComponentSpacing()
public void setComponentSpacing(double componentSpacing)
componentSpacing
- the current component spacing.public boolean isGroupingActive()
The default value is true
.
true
if the nesting structure of the graph is taken
into account when determining connectedness; false
otherwise.setGroupingActive(boolean)
public void setGroupingActive(boolean groupingActive)
The default value is true
.
groupingActive
- if true
the nesting structure of
the graph is taken into account when determining connectedness.isGroupingActive()
public byte getStyle()
ComponentLayouter
.
The default is STYLE_ROWS
.
STYLE_MASK
to mask out the basic style without the
modifier bits.setStyle(byte)
public void setStyle(byte style)
ComponentLayouter
.
The default is STYLE_ROWS
.
style
- New value of property style. One of STYLE_NONE
, STYLE_ROWS
,
STYLE_SINGLE_ROW
, STYLE_SINGLE_COLUMN
, STYLE_PACKED_RECTANGLE
,
STYLE_PACKED_COMPACT_RECTANGLE
, STYLE_PACKED_CIRCLE
, or STYLE_PACKED_COMPACT_CIRCLE
,
possibly bitwise combined using STYLE_MODIFIER_AS_IS
and/or STYLE_MODIFIER_NO_OVERLAP
.protected void arrangeFields(LayoutGraph graph, NodeList[] nodes, EdgeList[] edges, YRectangle[] bbox, Rectangle2D[] boxes, boolean circular, boolean fill, boolean fromSketch)
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |