Search this API

y.layout
Class OrientationLayouter

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

public class OrientationLayouter
extends AbstractLayoutStage
implements LayoutOrientation

A layout stage that performs changes the orientation of the layout that another algorithm calculates.

For all CanonicMultiStageLayouters it is highly recommended to use CanonicMultiStageLayouter.getOrientationLayouter() for layout orientation changes and not to wrap the CanonicMultiStageLayouter with an OrientationLayouter, which may cause unwanted artifacts.


Nested Class Summary
 class OrientationLayouter.Transformer
          Class that provides a method for transferring a point to its final position.
 
Field Summary
static int MIRROR_BOTTOM_TO_TOP
          Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis.
static int MIRROR_LEFT_TO_RIGHT
          Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis.
static int MIRROR_NONE
          Constant that can be used to prevent any mirroring of layout orientations.
static int MIRROR_RIGHT_TO_LEFT
          Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis.
static int MIRROR_TOP_TO_BOTTOM
          Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis.
 
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, SELECTED_EDGES, SELECTED_NODES
 
Constructor Summary
OrientationLayouter()
          Instantiates a new OrientationLayouter.
OrientationLayouter(byte orientation)
          Instantiates a new OrientationLayouter with a given orientation.
OrientationLayouter(Layouter coreLayouter)
          Instantiates a new OrientationLayouter. the core layout routine will be delegated to the given layouter.
 
Method Summary
 boolean canLayout(LayoutGraph graph)
          Returns true iff the given graph can be laid out by this algorithm.
protected  void completeOrientationChange(LayoutGraph graph)
          Method that will be called after the core layouter has been activated.
protected  YPoint completeTransform(YPoint p)
          Transforms a point for the completion phase.
 YInsets createOrientedInsets(Insets insets)
          Deprecated. Use createOrientedInsets(y.geom.YInsets) instead.
 YInsets createOrientedInsets(YInsets insets)
          Create and return an insets object that is a geometric transform of the given insets.
 YDimension createOrientedNodeSize(YDimension nodeSize)
          Create and return an YDimension object that is a geometric transform of the given size.
 void doLayout(LayoutGraph graph)
          Main layout routine that assigns new layout information to the given graph.
 int getMirrorMask()
          Returns the mirror mask, that defines which orientations this layouter shall mirror.
 byte getOrientation()
          Returns the orientation 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 set orientation is a horizontal orientation, i.e. one of LayoutOrientation.LEFT_TO_RIGHT or LayoutOrientation.RIGHT_TO_LEFT.
 boolean isOrientationMirrored(byte orientation)
          This method will return whether the layouter will mirror the graph for a given layout orientation.
protected  void prepareOrientationChange(LayoutGraph graph)
          Method that will be called before the core layouter gets activated.
protected  YPoint prepareTransform(YPoint p)
          Transforms a point for the preparation phase.
 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 layouter shall mirror.
 void setOrientation(byte orientation)
          Sets the orientation of the layout.
protected  YPoint transform(YPoint p, boolean prepare)
          Transforms a point for the preparation or completion phase.
 
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

MIRROR_NONE

public static final int MIRROR_NONE
Constant that can be used to prevent any mirroring of layout orientations.

See Also:
Constant Field Values

MIRROR_TOP_TO_BOTTOM

public static final int MIRROR_TOP_TO_BOTTOM
Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis. Adding this constant to the mask will result in mirror the y-axis of the graph for layout orientation LayoutOrientation.TOP_TO_BOTTOM.

See Also:
Constant Field Values

MIRROR_RIGHT_TO_LEFT

public static final int MIRROR_RIGHT_TO_LEFT
Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis. Adding this constant to the mask will result in mirror the x-axis of the graph for layout orientation LayoutOrientation.RIGHT_TO_LEFT.

See Also:
Constant Field Values

MIRROR_BOTTOM_TO_TOP

public static final int MIRROR_BOTTOM_TO_TOP
Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis. Adding this constant to the mask will result in mirror the y-axis of the graph for layout orientation LayoutOrientation.BOTTOM_TO_TOP.

See Also:
Constant Field Values

MIRROR_LEFT_TO_RIGHT

public static final int MIRROR_LEFT_TO_RIGHT
Constant that can be used to create the mirror mask, that defines which layout orientations shall be mirrored at their corresponding axis. Adding this constant to the mask will result in mirror the x-axis of the graph for layout orientation LayoutOrientation.LEFT_TO_RIGHT.

See Also:
Constant Field Values
Constructor Detail

OrientationLayouter

public OrientationLayouter(Layouter coreLayouter)
Instantiates a new OrientationLayouter. the core layout routine will be delegated to the given layouter.


OrientationLayouter

public OrientationLayouter()
Instantiates a new OrientationLayouter.


OrientationLayouter

public OrientationLayouter(byte orientation)
Instantiates a new OrientationLayouter with a given orientation.

See Also:
setOrientation(byte)
Method Detail

setOrientation

public void setOrientation(byte orientation)
Sets the orientation of the layout. By default LayoutOrientation.TOP_TO_BOTTOM is set.

Parameters:
orientation - one of LayoutOrientation.TOP_TO_BOTTOM, LayoutOrientation.LEFT_TO_RIGHT, LayoutOrientation.RIGHT_TO_LEFT, and LayoutOrientation.BOTTOM_TO_TOP.

getOrientation

public byte getOrientation()
Returns the orientation of the layout.

See Also:
setOrientation(byte)

getMirrorMask

public int getMirrorMask()
Returns the mirror mask, that defines which orientations this layouter shall mirror. Setting a layout orientation can be seen as rotating the graph 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).

By default a mirror mask is set, where LayoutOrientation.BOTTOM_TO_TOP, will be mirrored at the y-Axis.

Returns:
a mirror mask, that determines for which layout orientation the graph will be mirrored.
See Also:
MIRROR_BOTTOM_TO_TOP, MIRROR_LEFT_TO_RIGHT, MIRROR_RIGHT_TO_LEFT, MIRROR_TOP_TO_BOTTOM

setMirrorMask

public void setMirrorMask(int mirrorMask)
Specifies the mirror mask, that defines which orientations this layouter shall mirror. Setting a layout orientation can be seen as rotating the graph 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.

By default a mirror mask is set, where LayoutOrientation.BOTTOM_TO_TOP, will be mirrored at the y-Axis.

Parameters:
mirrorMask - the mask, that determines which layout orientations shall be mirrored.
See Also:
MIRROR_BOTTOM_TO_TOP, MIRROR_LEFT_TO_RIGHT, MIRROR_RIGHT_TO_LEFT, MIRROR_TOP_TO_BOTTOM

isHorizontalOrientation

public boolean isHorizontalOrientation()
Returns whether or not the set orientation is a horizontal orientation, i.e. one of LayoutOrientation.LEFT_TO_RIGHT or LayoutOrientation.RIGHT_TO_LEFT.


isConsiderEdgeLabelsEnabled

public boolean isConsiderEdgeLabelsEnabled()
Returns whether or not the position of the edge labels should be changed during orientation change. Default is true.

Returns:
true if the position of the edge labels should be changed; false otherwise.

setConsiderEdgeLabelsEnabled

public void setConsiderEdgeLabelsEnabled(boolean enabled)
Specifies whether or not the position of the edge labels should be changed during orientation change. The core layouter should switch this off, when its integrated edge labeling is switched on. Default is true.

Parameters:
enabled - true if the position of the edge labels should be changed; false otherwise.

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.

Specified by:
canLayout in interface Layouter

doLayout

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

Specified by:
doLayout in interface Layouter

isOrientationMirrored

public boolean isOrientationMirrored(byte orientation)
This method will return whether the layouter will mirror the graph for a given layout orientation.

Parameters:
orientation - the layout orientation, for which to check the mirror state.
Returns:
  • true - if the layouter will mirror the graph at the corresponding axis (x-Axis for horizontal orientations, y-Axis for vertical orientations) for the given layout orientation.
  • false - otherwise.

prepareOrientationChange

protected void prepareOrientationChange(LayoutGraph graph)
Method that will be called before the core layouter gets activated. It prepares the layout for the desired orientation by rotating/mirroring the coordinates and bounds of the graph layout such that the core layouter can perform the layout in the canonical TOP_TO_BOTTOM manner.


completeOrientationChange

protected void completeOrientationChange(LayoutGraph graph)
Method that will be called after the core layouter has been activated. It performs the inverse coordinate transformation that has been applied to the layout by method prepareOrientationChange(LayoutGraph).


transform

protected YPoint transform(YPoint p,
                           boolean prepare)
Transforms a point for the preparation or completion phase.

Parameters:
prepare - if true then the transformation is for the preparation phase, otherwise for the completion phase.
See Also:
prepareTransform(YPoint), completeTransform(YPoint)

prepareTransform

protected YPoint prepareTransform(YPoint p)
Transforms a point for the preparation phase.

See Also:
prepareOrientationChange(LayoutGraph)

completeTransform

protected YPoint completeTransform(YPoint p)
Transforms a point for the completion phase.

See Also:
completeOrientationChange(LayoutGraph)

createOrientedInsets

public YInsets createOrientedInsets(Insets insets)
Deprecated. Use createOrientedInsets(y.geom.YInsets) instead.

Create and return an insets object that is a geometric transform of the given insets. The transform will correspond to the currently set orientation.


createOrientedInsets

public YInsets createOrientedInsets(YInsets insets)
Create and return an insets object that is a geometric transform of the given insets. The transform will correspond to the currently set orientation.


createOrientedNodeSize

public YDimension createOrientedNodeSize(YDimension nodeSize)
Create and return an YDimension object that is a geometric transform of the given size. The transform will correspond to the currently set orientation.


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