Search this API

y.layout
Class FixNodeLayoutStage

java.lang.Object
  extended by y.layout.AbstractLayoutStage
      extended by y.layout.FixNodeLayoutStage
All Implemented Interfaces:
Layouter, LayoutStage

public class FixNodeLayoutStage
extends AbstractLayoutStage

Layout stage that can be used to fix the position of either a single node or the alignment of the bounding box of several nodes (but not the positions of the individual nodes).


Field Summary
static byte FIX_POINT_POLICY_CENTER
          Fix point calculation policy that results in the center of a given rectangle to be considered the fix point.
static byte FIX_POINT_POLICY_UPPER_LEFT
          Fix point calculation policy that results in the upper left corner of a given rectangle to be considered the fix point.
static Object FIXED_NODE_DPKEY
          DataProvider key to specify a DataProvider whose DataProvider.getBool(Object) method is used to determine which nodes should be considered fixed.
 
Fields inherited from interface y.layout.Layouter
EDGE_ID_DPKEY, NODE_ID_DPKEY, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
FixNodeLayoutStage()
          Initializes a new FixNodeLayoutStage.
FixNodeLayoutStage(Layouter core)
          Initializes a new FixNodeLayoutStage.
 
Method Summary
protected  Rectangle2D calculateBounds(LayoutGraph graph, NodeList fixed)
          Calculates the bounding box of the specified nodes.
protected  YPoint calculateFixPoint(LayoutGraph graph, NodeList fixed)
          Calculates the fix point for the specified nodes in the specified graph.
protected  YPoint calculateFixPoint(Rectangle2D bounds)
          Calculates the fix point of the specified rectangle according to the policy returned by getFixPointPolicy().
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 byte getFixPointPolicy()
          Returns the fix point calculation policy used in calculateFixPoint(java.awt.geom.Rectangle2D) to determine which point in the corresponding rectangle should be considered fixed.
 boolean isIncludingEdges()
          Determines whether or not subgraph edges should be taken into account when calculating the bounding box of the fixed nodes.
 boolean isIncludingLabels()
          Determines whether or not label geometries should be taken into account when calculating the bounding box of the fixed nodes.
 void setFixPointPolicy(byte policy)
          Specifies the fix point calculation policy used in calculateFixPoint(java.awt.geom.Rectangle2D) to determine which point in the corresponding rectangle should be considered fixed.
 void setIncludingEdges(boolean includingEdges)
          Specifies whether or not subgraph edges should be taken into account when calculating the bounding box of the fixed nodes.
 void setIncludingLabels(boolean includingLabels)
          Specifies whether or not label geometries should be taken into account when calculating the bounding box of the fixed nodes.
 
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

FIXED_NODE_DPKEY

public static final Object FIXED_NODE_DPKEY
DataProvider key to specify a DataProvider whose DataProvider.getBool(Object) method is used to determine which nodes should be considered fixed.


FIX_POINT_POLICY_CENTER

public static final byte FIX_POINT_POLICY_CENTER
Fix point calculation policy that results in the center of a given rectangle to be considered the fix point.

See Also:
Constant Field Values

FIX_POINT_POLICY_UPPER_LEFT

public static final byte FIX_POINT_POLICY_UPPER_LEFT
Fix point calculation policy that results in the upper left corner of a given rectangle to be considered the fix point.

See Also:
Constant Field Values
Constructor Detail

FixNodeLayoutStage

public FixNodeLayoutStage()
Initializes a new FixNodeLayoutStage.


FixNodeLayoutStage

public FixNodeLayoutStage(Layouter core)
Initializes a new FixNodeLayoutStage.

Parameters:
core - the core layout algorithm for this stage.
Method Detail

getFixPointPolicy

public byte getFixPointPolicy()
Returns the fix point calculation policy used in calculateFixPoint(java.awt.geom.Rectangle2D) to determine which point in the corresponding rectangle should be considered fixed.

By default, FIX_POINT_POLICY_CENTER is used.

Returns:
the fix point calculation policy used in calculateFixPoint(java.awt.geom.Rectangle2D).
See Also:
setFixPointPolicy(byte), FIX_POINT_POLICY_CENTER, FIX_POINT_POLICY_UPPER_LEFT

setFixPointPolicy

public void setFixPointPolicy(byte policy)
Specifies the fix point calculation policy used in calculateFixPoint(java.awt.geom.Rectangle2D) to determine which point in the corresponding rectangle should be considered fixed.

By default, FIX_POINT_POLICY_CENTER is used.

Parameters:
policy - of one
See Also:
getFixPointPolicy()

isIncludingEdges

public boolean isIncludingEdges()
Determines whether or not subgraph edges should be taken into account when calculating the bounding box of the fixed nodes.

By default, this property is set to false, i.e. subgraph edges are not taken into account.

Returns:
true if subgraph edges should be taken into account and false otherwise.
See Also:
setIncludingEdges(boolean), calculateBounds(LayoutGraph, y.base.NodeList)

setIncludingEdges

public void setIncludingEdges(boolean includingEdges)
Specifies whether or not subgraph edges should be taken into account when calculating the bounding box of the fixed nodes.

By default, this property is set to false, i.e. subgraph edges are not taken into account.

Parameters:
includingEdges - true if subgraph edges should be taken into account and false otherwise.
See Also:
isIncludingEdges(), calculateBounds(LayoutGraph, y.base.NodeList)

isIncludingLabels

public boolean isIncludingLabels()
Determines whether or not label geometries should be taken into account when calculating the bounding box of the fixed nodes.

By default, this property is set to false, i.e. label geometries are not taken into account.

Returns:
true if label geometries should be taken into account and false otherwise.
See Also:
setIncludingLabels(boolean), calculateBounds(LayoutGraph, y.base.NodeList)

setIncludingLabels

public void setIncludingLabels(boolean includingLabels)
Specifies whether or not label geometries should be taken into account when calculating the bounding box of the fixed nodes.

By default, this property is set to false, i.e. label geometries are not taken into account.

Parameters:
includingLabels - true if label geometries should be taken into account and false otherwise.
See Also:
isIncludingLabels(), calculateBounds(LayoutGraph, y.base.NodeList)

canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns 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.


doLayout

public void doLayout(LayoutGraph graph)
Description copied from interface: Layouter
Main layout routine that assigns new layout information to the given graph.


calculateFixPoint

protected YPoint calculateFixPoint(LayoutGraph graph,
                                   NodeList fixed)
Calculates the fix point for the specified nodes in the specified graph. The default implementation calls calculateBounds(LayoutGraph, y.base.NodeList) and calculateFixPoint(java.awt.geom.Rectangle2D).

Parameters:
graph - the graph associated to the specified nodes.
fixed - the list of nodes for which a fix point has to be determined.
Returns:
the fix point for the specified nodes in the specified graph.

calculateFixPoint

protected YPoint calculateFixPoint(Rectangle2D bounds)
Calculates the fix point of the specified rectangle according to the policy returned by getFixPointPolicy(). If the specified rectangle is null or the rectangle has negative width or negative height, null will be returned.

Parameters:
bounds - the rectangle for which to determine the fix point.
Returns:
the fix point of the specified rectangle or null if nothing should be fixed.
See Also:
getFixPointPolicy()

calculateBounds

protected Rectangle2D calculateBounds(LayoutGraph graph,
                                      NodeList fixed)
Calculates the bounding box of the specified nodes. The return values of methods isIncludingEdges() and isIncludingLabels() determine whether or not edges and labels are taken into account when calculating the box.

Parameters:
graph - the graph associated to the specified nodes.
fixed - the list of nodes that determine the bounding box.
Returns:
the bounding box of the specified nodes.
See Also:
isIncludingEdges(), isIncludingLabels()

© Copyright 2000-2013,
yWorks GmbH.
All rights reserved.