com.tensegrity.graph.layout
Interface NodeLayout

All Superinterfaces:
Layout
All Known Implementing Classes:
CircularLayout, EnergyLayout, HierarchicalLayout, OrgChartLayout, RandomLayout, SwimlaneLayout, TreeLayout

public interface NodeLayout
extends Layout

The NodeLayout interface specifies the contract for classes responsible for laying out both node and edge elements of a graph. Client code may selectively add only those nodes and edges that should be positioned by the layout algorithm. The additional minor responsibilities include layout duration estimation, layout progress notification as well as two methods which can be implemented to efficiently allocate memory.

An implementation class should perform its layout using a layout algorithm that arranges nodes and edges according to some conceptual arrangement model.

The Layout classes may be used individually or by a LayoutController. To ensure that a Layout is always used properly, the following process flow is stipulated:

  1. Layout.init()
  2. Layout.getLayoutAttributesTemplate()
  3. Layout.useAttribute(AttributeSet)
  4. beforeAddNodeHandler(int)
  5. addNode(LayoutableNode)
  6. beforeAddEdgeHandler(int)
  7. addEdge(LayoutableEdge)
  8. isGraphSuitable()
  9. getEstimatedArrangingTime()
  10. Layout.beforeLayoutHandler()
  11. layout(int, int, boolean)
  12. Layout.afterLayoutHandler()

 
    ________________________________________ 
   |   + getLayoutAttributesTemplate        |
   |________________________________________|
   |   _____________________________________|
   |  |  # init                             |
   |  |_____________________________________|
   |  |  #  beforeAddNodeHandler            |
   |  |_____________________________________|
   |  |    _________________________________|
   |  |   |  + addNode                      |
   |  |   |_________________________________|
   |  |_____________________________________|
   |  |  #  beforeAddEdgeHandler            |
   |  |_____________________________________|
   |  |    _________________________________|
   |  |   |  + addEdge                      |
   |  |   |_________________________________|
   |  |_____________________________________|
   |  |   __________________________________|
   |  |  |   +  useAttribute                |
   |  |  |__________________________________|
   |  |  |\  + isGraphSuitable?       __..' |
   |  |  | \                    __..-'      |
   |  |  |  \             __..-'            |
   |  |  |NO \     __..--'      YES         |
   |  |  |____\__'__________________________|
   |  |  |     |+ getEstimatedArrangingTime |
   |  |  |     |____________________________|
   |  |  |     |   _________________________|
   |  |  |     |  | # beforeLayoutHandler   |
   |  |  |     |  | # layout     |
   |  |  |     |  | # afterLayoutHandler    |
   |  |  |     |  |_________________________|
   |  |  |     |  | + getReport()           |
   |  |  |     |  |_________________________|
   |  |  |     |____________________________|
   |  |  |__________________________________|
   |  |_____________________________________|
   |________________________________________|
 
 

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

Field Summary
static int DIRECTION_BOTTOM_TO_TOP
          constant that tells about the direction of a node layout
static int DIRECTION_LEFT_TO_RIGHT
          constant that tells about the direction of a node layout
static int DIRECTION_RIGHT_TO_LEFT
          constant that tells about the direction of a node layout
static int DIRECTION_TOP_TO_BOTTOM
          constant that tells about the direction of a node layout
static int DIRECTION_UNDEFINED
          constant that tells about the direction of a node layout
 
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 beforeAddEdgeHandler(int edgeCount)
          This method must be called before inserting edges.
 void beforeAddNodeHandler(int nodeCount)
          This method will be triggered before inserting nodes.
 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.
 long getEstimatedArrangingTime()
          Returns an estimate time for arranging of a given graph.
 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.
 boolean isGraphSuitable()
          This method checks whether the layout is able to arrange the visual elements it contains.
 boolean layout(int left, int top, boolean reassignPorts)
          Performs the layout process.
 void setProgressBar(LayoutProgress progressBar)
          This method might be use to set a progress bar.
 
Methods inherited from interface com.tensegrity.graph.layout.Layout
afterLayoutHandler, beforeLayoutHandler, error, getErrorMessage, getLayoutAttributesTemplate, getName, getReport, init, updateAttributeSet, useAttribute
 

Field Detail

DIRECTION_UNDEFINED

public static final int DIRECTION_UNDEFINED
constant that tells about the direction of a node layout

See Also:
Constant Field Values

DIRECTION_TOP_TO_BOTTOM

public static final int DIRECTION_TOP_TO_BOTTOM
constant that tells about the direction of a node layout

See Also:
Constant Field Values

DIRECTION_LEFT_TO_RIGHT

public static final int DIRECTION_LEFT_TO_RIGHT
constant that tells about the direction of a node layout

See Also:
Constant Field Values

DIRECTION_BOTTOM_TO_TOP

public static final int DIRECTION_BOTTOM_TO_TOP
constant that tells about the direction of a node layout

See Also:
Constant Field Values

DIRECTION_RIGHT_TO_LEFT

public static final int DIRECTION_RIGHT_TO_LEFT
constant that tells about the direction of a node layout

See Also:
Constant Field Values
Method Detail

getDirection

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

Returns:
int a constant that indicates the direction of the NodeLayout

beforeAddNodeHandler

public void beforeAddNodeHandler(int nodeCount)
This method will be triggered before inserting nodes.

Parameters:
nodeCount - The number of nodes that will be added.

addNode

public boolean addNode(LayoutableNode node)
This method adds nodes into the layout classes.

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:
beforeAddNodeHandler(int)

beforeAddEdgeHandler

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

Parameters:
edgeCount - he number of edges that will be added.

addEdge

public boolean addEdge(LayoutableEdge edge)
This method adds an edge to the layout.

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:
beforeAddEdgeHandler(int)

Find more information in the class documentation


isGraphSuitable

public boolean isGraphSuitable()
This method checks whether the layout is able to arrange the visual elements it contains.

Returns:
Returns true if the layout classes is able to arrange the graph.

Find more information in the class documentation


layout

public boolean layout(int left,
                      int top,
                      boolean reassignPorts)
Performs the layout process.

Parameters:
left - The left position of the graph bounding box after arranging.
top - 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:
beforeAddEdgeHandler(int)

Find more information in the class documentation


getNodeAttributesTemplate

public AttributeSet getNodeAttributesTemplate()
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.

Returns:
Returns a the default AttributeSet for nodes if any; otherwise null.
See Also:
AttributeSet

Find more information in the class documentation


getEdgeAttributesTemplate

public AttributeSet getEdgeAttributesTemplate()
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.

Returns:
Returns a the default AttributeSet for nodes if any; otherwise null.

Find more information in the class documentation


getEstimatedArrangingTime

public long getEstimatedArrangingTime()
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.

Returns:
Returns The estimate time to layout the graph which is set beforehand.

setProgressBar

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

Parameters:
progressBar - The progress bar that is to be updated.

getPreferEdgeType

public int getPreferEdgeType(AttributeSet usingAttributes)
This method allows a layout classes to inform the caller about it preferred edge type.

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.