com.tensegrity.graph.layout.swimlane
Class SwimlaneLayout

java.lang.Object
  extended bycom.tensegrity.graph.layout.swimlane.SwimlaneLayout
All Implemented Interfaces:
Layout, NodeLayout

public class SwimlaneLayout
extends java.lang.Object
implements NodeLayout

This class implements NodeLayout to layout nodes using HierarchicalLayout The constants which can be used to configure instances of this NodeLayout class are defined in class SwimlaneConstants.

Version:
$Id: SwimlaneLayout.java,v 1.69 2006/03/14 14:35:25 MichaelKegel Exp $
Author:
Sharokh Khani

Field Summary
 
Fields inherited from interface com.tensegrity.graph.layout.NodeLayout
DIRECTION_BOTTOM_TO_TOP, DIRECTION_LEFT_TO_RIGHT, DIRECTION_RIGHT_TO_LEFT, DIRECTION_TOP_TO_BOTTOM, DIRECTION_UNDEFINED
 
Constructor Summary
SwimlaneLayout()
          Constructs a new swim-lane layout instance with default settings.
 
Method Summary
 boolean addEdge(LayoutableEdge edge)
          This method adds an edge to the layout.
 boolean addNode(LayoutableNode node)
          This method adds nodes into the layout classes.
 void afterLayoutHandler()
          This method will be called after the arrangement of the graph is completed.
 void beforeAddEdgeHandler(int edgeCount)
          This method must be called before inserting edges.
 void beforeAddNodeHandler(int nodeCount)
          This method will be triggered before inserting nodes.
 void beforeLayoutHandler()
          This method will be called before performing layout to allow the layout class to do initialization work.
 boolean error()
          Returns true if an error has occurred; otherwise false.
 int getDirection()
          Returns a constant that represents the direction of the NodeLayout implementation.
 AttributeSet getEdgeAttributesTemplate()
          Returns the attribute set of edges which is initialized with default values.
 java.lang.String getErrorMessage()
          Returns the error-message if an error has occurred.
 long getEstimatedArrangingTime()
          Returns an estimate time for arranging of a given graph.
 AttributeSet getLayoutAttributesTemplate()
          This method return an AttributeSet which contains all properties supported by this Layout.
 java.lang.String getName()
          Returns the name of the Layout.
 AttributeSet getNodeAttributesTemplate()
          Returns the attribute set of nodes which is initialized with default values.
 int getPreferEdgeType(AttributeSet usingAttributes)
          This method allows a layout classes to inform the caller about it preferred edge type.
 AttributeSet getReport()
          This method submits a report about the last layout process.
 void init()
          An instance of this class may be used to arrange different graphs.
 boolean isGraphSuitable()
          This method checks whether the layout is able to arrange the visual elements it contains.
 boolean layout(int x, int y, boolean reassignPorts)
          Performs the layout process.
 void setProgressBar(LayoutProgress progressBar)
          This method might be use to set a progress bar.
 void updateAttributeSet(AttributeSet layoutAttributs)
          This method updates a given AttributeSet with the view of consistency.
 void useAttribute(AttributeSet layoutAttributs)
          This method can be used to configure a layout class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwimlaneLayout

public SwimlaneLayout()
Constructs a new swim-lane layout instance with default settings.

Method Detail

updateAttributeSet

public void updateAttributeSet(AttributeSet layoutAttributs)
Description copied from interface: Layout
This method updates a given AttributeSet with the view of consistency.
A tree layout class for example may change the attribute layer distance to radius if the user changes the arrangement type from plan to radial.

Notice: The given AttributeSet must contains valid properties supported by this Layout. Please see Layout.getLayoutAttributesTemplate() for more details.

Specified by:
updateAttributeSet in interface Layout
Parameters:
layoutAttributs - the attributes that are to be updated.
See Also:
Layout.getLayoutAttributesTemplate()

init

public void init()
Description copied from interface: Layout
An instance of this class may be used to arrange different graphs. Since the constructor of this class is called only once, this method must be called to allow a Layout instance to do initialization work before a new graph is assigned.

Specified by:
init in interface Layout

getName

public java.lang.String getName()
Description copied from interface: Layout
Returns the name of the Layout. This name will be used to identify a layout and must be unique.

Specified by:
getName in interface Layout
Returns:
String The name of this layout class.

getDirection

public int getDirection()
Description copied from interface: NodeLayout
Returns a constant that represents the direction of the NodeLayout implementation. Valid values are defined through the 'direction' constants from this interface.

Specified by:
getDirection in interface NodeLayout
Returns:
int a constant that indicates the direction of the NodeLayout

isGraphSuitable

public boolean isGraphSuitable()
Description copied from interface: NodeLayout
This method checks whether the layout is able to arrange the visual elements it contains.

Specified by:
isGraphSuitable in interface NodeLayout
Returns:
Returns true if the layout classes is able to arrange the graph.

beforeAddNodeHandler

public void beforeAddNodeHandler(int nodeCount)
Description copied from interface: NodeLayout
This method will be triggered before inserting nodes.

Specified by:
beforeAddNodeHandler in interface NodeLayout
Parameters:
nodeCount - The number of nodes that will be added.

addNode

public boolean addNode(LayoutableNode node)
Description copied from interface: NodeLayout
This method adds nodes into the layout classes.

Specified by:
addNode in interface NodeLayout
Parameters:
node - the node that is to be added.
Returns:
Returns true if the function was successful, otherwise return false in which case the methods Layout.getErrorMessage() may be used to get details information.
See Also:
NodeLayout.beforeAddNodeHandler(int)

beforeAddEdgeHandler

public void beforeAddEdgeHandler(int edgeCount)
Description copied from interface: NodeLayout
This method must be called before inserting edges. The edgeCount may be used for internal preparing like memory allocation.

Specified by:
beforeAddEdgeHandler in interface NodeLayout
Parameters:
edgeCount - he number of edges that will be added.

addEdge

public boolean addEdge(LayoutableEdge edge)
Description copied from interface: NodeLayout
This method adds an edge to the layout.

Specified by:
addEdge in interface NodeLayout
Parameters:
edge - The edge that is to be added.
Returns:
Returns true if the function was successful, otherwise return false in which case the methods Layout.getErrorMessage() may be used to get details information.
See Also:
NodeLayout.beforeAddEdgeHandler(int)

useAttribute

public void useAttribute(AttributeSet layoutAttributs)
Description copied from interface: Layout
This method can be used to configure a layout class. The method Layout#getLayoutAttributesTemplate() can be used to obtained a copy of default AttributeSet that contains all properties supported by this Layout.

Specified by:
useAttribute in interface Layout
Parameters:
layoutAttributs - The attributes that are to be used in the next layout process.

beforeLayoutHandler

public void beforeLayoutHandler()
Description copied from interface: Layout
This method will be called before performing layout to allow the layout class to do initialization work.

Specified by:
beforeLayoutHandler in interface Layout

layout

public boolean layout(int x,
                      int y,
                      boolean reassignPorts)
Description copied from interface: NodeLayout
Performs the layout process.

Specified by:
layout in interface NodeLayout
Parameters:
x - The left position of the graph bounding box after arranging.
y - The top position of the graph bounding box after arranging.
reassignPorts - Specifies whether the layout is allowed to reassign ports or not.
Returns:
true if the arranging was successful; otherwise false.
See Also:
NodeLayout.beforeAddEdgeHandler(int)

afterLayoutHandler

public void afterLayoutHandler()
Description copied from interface: Layout
This method will be called after the arrangement of the graph is completed. It allows the layout class to do post-initialization work.

Specified by:
afterLayoutHandler in interface Layout

getLayoutAttributesTemplate

public AttributeSet getLayoutAttributesTemplate()
Description copied from interface: Layout
This method return an AttributeSet which contains all properties supported by this Layout. The provided AttributeSet can be modified to configure this Layout.The method Layout.useAttribute(AttributeSet) will be used to put a modified copy of this AttributeSet.

Specified by:
getLayoutAttributesTemplate in interface Layout
Returns:
Returns a the default AttributeSet of this Layout if any; otherwise null.

getNodeAttributesTemplate

public AttributeSet getNodeAttributesTemplate()
Description copied from interface: NodeLayout
Returns the attribute set of nodes which is initialized with default values.
Note: The default node attributes are not to be confused with layout attributes. The layout attributes configure the layout as a whole. But some layout classes allow also configuration of nodes to allow different treatment.

Specified by:
getNodeAttributesTemplate in interface NodeLayout
Returns:
Returns a the default AttributeSet for nodes if any; otherwise null.
See Also:
AttributeSet

getEdgeAttributesTemplate

public AttributeSet getEdgeAttributesTemplate()
Description copied from interface: NodeLayout
Returns the attribute set of edges which is initialized with default values.
Note: The default edge attributes are not to be confused with layout attributes. The layout-attributes configure the layout as a whole. But some layout classes allow also configuration of edges to allow different treatment.

Specified by:
getEdgeAttributesTemplate in interface NodeLayout
Returns:
Returns a the default AttributeSet for nodes if any; otherwise null.

error

public boolean error()
Description copied from interface: Layout
Returns true if an error has occurred; otherwise false. You can use Layout.getErrorMessage() to obtain a description text about the last occurred error.

Specified by:
error in interface Layout
Returns:
Returns true if an error has occurred; otherwise false.

getErrorMessage

public java.lang.String getErrorMessage()
Description copied from interface: Layout
Returns the error-message if an error has occurred. You can use Layout.error() to find out whether an error has occurred.

Specified by:
getErrorMessage in interface Layout
Returns:
Returns the error description

getEstimatedArrangingTime

public long getEstimatedArrangingTime()
Description copied from interface: NodeLayout
Returns an estimate time for arranging of a given graph. This method will be called after adding nodes and edges and before the arranging process executed.

Specified by:
getEstimatedArrangingTime in interface NodeLayout
Returns:
Returns The estimate time to layout the graph which is set beforehand.

getReport

public AttributeSet getReport()
Description copied from interface: Layout
This method submits a report about the last layout process. It provides detail information accordingly.A report contains typically the calculation durations of different processing steps.

Specified by:
getReport in interface Layout
Returns:
Returns an AttributeSet which contains the report.

setProgressBar

public void setProgressBar(LayoutProgress progressBar)
Description copied from interface: NodeLayout
This method might be use to set a progress bar. The layout classes should update it to show the current progress of layout process.

Specified by:
setProgressBar in interface NodeLayout
Parameters:
progressBar - The progress bar that is to be updated.

getPreferEdgeType

public int getPreferEdgeType(AttributeSet usingAttributes)
Description copied from interface: NodeLayout
This method allows a layout classes to inform the caller about it preferred edge type.

Specified by:
getPreferEdgeType in interface NodeLayout
Parameters:
usingAttributes - the configuration that should being used.
Returns:
the prefer edge type of the layout classes.


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.