y.layout
Class OrientationLayouter

java.lang.Object
  |
  +--y.layout.AbstractLayoutStage
        |
        +--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.


Field Summary
 
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 layed 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.
 Insets createOrientedInsets(Insets insets)
          Create and return an insets object that is a geometric transform of the given inserts.
 void doLayout(LayoutGraph graph)
          Assigns a new graph layout to the given layout graph.
 byte getOrientation()
          Returns the orientation of the layout.
 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.
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 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
 

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:
OrientationLayouter.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:
OrientationLayouter.setOrientation(byte)

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.


canLayout

public boolean canLayout(LayoutGraph graph)
Description copied from interface: Layouter
Returns true iff the given graph can be layed out by this algorithm. Calling doLayout with the given graph as it's 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
Assigns a new graph layout to the given layout graph.

Specified by:
doLayout in interface Layouter

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 cannonic 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 OrientationLayouter.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:
OrientationLayouter.prepareTransform(YPoint), OrientationLayouter.completeTransform(YPoint)

prepareTransform

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

See Also:
OrientationLayouter.prepareOrientationChange(LayoutGraph)

completeTransform

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

See Also:
OrientationLayouter.completeOrientationChange(LayoutGraph)

createOrientedInsets

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


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

2003