com.tensegrity.graph.layout.edge
Class DefaultEdgeLayout

java.lang.Object
  extended bycom.tensegrity.graph.layout.edge.DefaultEdgeLayout
All Implemented Interfaces:
EdgeLayout, Layout

public class DefaultEdgeLayout
extends java.lang.Object
implements EdgeLayout

This EdgeLayout implementation arranges edges without moving any nodes. While most NodeLayout classes are not able to route edges alone but only together with the connected nodes, a layouter which only routes edges is an essential part of every application that supports runtime user-interaction.

This EdgeLayout implementation can be used to completely arrange edges or simply to refine the edges which have already been roughly arranged by a NodeLayout.

This class builds on a set of building blocks. Each building block handles a specific aspect of edge arrangement. The following layout building blocks are provided:

The required constants to configure an EdgeLayout instance are defined in class EdgeLayoutConstants.

Version:
$Id: DefaultEdgeLayout.java,v 1.80 2006/06/08 01:30:33 SharokhKhani Exp $
Author:
Sharokh Khani

Constructor Summary
DefaultEdgeLayout()
          Constructs an EdgeLayout instance and initializes it with default attributes.
 
Method Summary
 void afterLayoutHandler()
          This method will be called after the arrangement of the graph is completed.
 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.
 AttributeSet getEdgeAttributesTemplate()
          Returns the attribute set for edges which is initialized with default values.
 java.lang.String getErrorMessage()
          Returns the error-message if an error has occurred.
 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 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 relayout(java.util.ArrayList edgesToReadgust, java.util.ArrayList hindrance, Boundary boundary)
          Arranges all specified edges, which may be arranged completely or simply readjusted, taking the current edge paths into consideration.
 boolean storePreferEdgePoints(java.util.ArrayList edges)
          Call this method to store additional edge points.
 boolean storePreferEdgePoints(LayoutableEdge edge, boolean doRemove)
          Call this method to store additional edge points for a specified edge.
 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

DefaultEdgeLayout

public DefaultEdgeLayout()
Constructs an EdgeLayout instance and initializes it with default attributes.

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.

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

storePreferEdgePoints

public boolean storePreferEdgePoints(java.util.ArrayList edges)
Description copied from interface: EdgeLayout
Call this method to store additional edge points. An EdgeLayout should take the current edge paths into consideration because in most cases the edge paths will have already been arranged by a NodeLayout.

Specified by:
storePreferEdgePoints in interface EdgeLayout
Parameters:
edges - a List containing the edges of which the additional points are to be stored.
Returns:
true if the layout was successful; otherwise false.

storePreferEdgePoints

public boolean storePreferEdgePoints(LayoutableEdge edge,
                                     boolean doRemove)
Description copied from interface: EdgeLayout
Call this method to store additional edge points for a specified edge. An EdgeLayout should take the current edge paths into consideration because in most cases the edge paths will have already been arranged by a NodeLayout.

Specified by:
storePreferEdgePoints in interface EdgeLayout
Parameters:
edge - the edges of which the additional points are to be stored.
doRemove - specifies whether the existing points should be overwritten or not
Returns:
true if the layout was successful; otherwise false.

relayout

public boolean relayout(java.util.ArrayList edgesToReadgust,
                        java.util.ArrayList hindrance,
                        Boundary boundary)
Description copied from interface: EdgeLayout
Arranges all specified edges, which may be arranged completely or simply readjusted, taking the current edge paths into consideration.

Specified by:
relayout in interface EdgeLayout
Parameters:
edgesToReadgust - All edges that should be rearranged. The elements the ArrayList are from type EdgeMap.
hindrance - A list of hindrances. Each hindrance is an integer array of length 5 containing a node boundary and its identifier, as shown here:
  • left position of the node.
  • top position of the node.
  • right position of the node.
  • bottom position of the node.
  • the identifier of the node.
boundary - the total available area that can be used by the edge layout
Returns:
true if the layout was successful; otherwise false.

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.

getEdgeAttributesTemplate

public AttributeSet getEdgeAttributesTemplate()
Description copied from interface: EdgeLayout
Returns the attribute set for edges which is initialized with default values.
Notice: 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 also allow the configuration of edges for alternate treatment.

Specified by:
getEdgeAttributesTemplate in interface EdgeLayout
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

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.


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