net.goui.util
Class GraphLayout.Edge

java.lang.Object
  extended bynet.goui.util.GraphLayout.Edge
All Implemented Interfaces:
GraphLayout.EdgeConstraint
Direct Known Subclasses:
GoLayout.Cell
Enclosing class:
GraphLayout

public static class GraphLayout.Edge
extends java.lang.Object
implements GraphLayout.EdgeConstraint

Author:
David Beaumont, Copyright 2005

This class provides the basic implementation for an Edge within the layout graph. It is normally expected that the edge will either be subclassed or supplied with an instance of EdgeConstraint during initialisation to provide specific constraint information for it.


Constructor Summary
GraphLayout.Edge()
          This constructor creates a basic Edge instance with no specific constraint information.
GraphLayout.Edge(GraphLayout.EdgeConstraint constraint)
          This constructor creates an edge instance using the given constraint.
 
Method Summary
 int getMaxSize()
          This is a simple default implementation of the getMaxSize() method of EdgeConstraint.
 int getMinSize()
          This is a simple default implementation of the getMinSize() method of EdgeConstraint.
 int getSize()
          This method returns the current size of this Edge as determined by the layout process.
 GraphLayout.Vertex getVertexNeg()
          This method returns the negative (preceeding) Vertex for this edge.
 GraphLayout.Vertex getVertexPos()
          This method returns the positive (following) Vertex for this edge.
 int getWeight()
          This is a simple default implementation of the getWeight() method of EdgeConstraint.
 void invalidate()
          This method will be called when layout information has become invalid.
 void remove()
          This method removes this Edge instance from the layout graph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphLayout.Edge

public GraphLayout.Edge()
This constructor creates a basic Edge instance with no specific constraint information. Unless a very simple and generic edge is required, it is expected that this constructor will be invoked by a subclass in which some or all of the constraint methods have been overloaded.

The default values returned from the constraint methods of this base class are:


GraphLayout.Edge

public GraphLayout.Edge(GraphLayout.EdgeConstraint constraint)
This constructor creates an edge instance using the given constraint. If the given constraint is null then this is equivalent to calling the no-argument constructor.

Parameters:
constraint - The constraint to be used when laying out this edge.
See Also:
GraphLayout.EdgeConstraint
Method Detail

getSize

public final int getSize()
This method returns the current size of this Edge as determined by the layout process. This is typically the same as the distance between the Vertices either side of this Edge, unless the weight for this Edge is zero and the distance between the Vertices exceeds the minimum size of this Edge. In this case the size of the Edge will be smaller than the distance between the Vertices.

If this Edge has not been laid out since the last call to reset() on the GraphLayout instance then INVALID is returned.

Returns:
The non-negative size of this Edge, or INVALID.

getMinSize

public int getMinSize()
This is a simple default implementation of the getMinSize() method of EdgeConstraint. This method can be overloaded by subclasses to return more specific constraint information for this edge. If an external constraint has been provided for this edge, this method will return the minimum size of the constraint, otherwise it returns 0.

Specified by:
getMinSize in interface GraphLayout.EdgeConstraint
Returns:
The non-negative minimum size for the associated edge.
See Also:
GraphLayout.EdgeConstraint

getMaxSize

public int getMaxSize()
This is a simple default implementation of the getMaxSize() method of EdgeConstraint. This method can be overloaded by subclasses to return more specific constraint information for this edge. If an external constraint has been provided for this edge, this method will return the maximum size of the constraint, otherwise it returns Integer.MAX_VALUE.

Specified by:
getMaxSize in interface GraphLayout.EdgeConstraint
See Also:
GraphLayout.EdgeConstraint

getWeight

public int getWeight()
This is a simple default implementation of the getWeight() method of EdgeConstraint. This method can be overloaded by subclasses to return more specific constraint information for this edge. If an external constraint has been provided for this edge, this method will return the weight size of the constraint, otherwise it returns 1.

Specified by:
getWeight in interface GraphLayout.EdgeConstraint
Returns:
The non-negative weight value for the associated edge.
See Also:
GraphLayout.EdgeConstraint

invalidate

public void invalidate()
This method will be called when layout information has become invalid. Any subclass of this class which caches the constraint information must provide an implementation of this method which invalidates any such data.

Specified by:
invalidate in interface GraphLayout.EdgeConstraint
See Also:
GraphLayout.EdgeConstraint

getVertexNeg

public final GraphLayout.Vertex getVertexNeg()
This method returns the negative (preceeding) Vertex for this edge. This will be the same negative Vertex instance with which this edge was originally added to the layout. If the edge has not yet been added to the layout, this will return null.

Returns:
The negative Vertex for this edge or null.

getVertexPos

public final GraphLayout.Vertex getVertexPos()
This method returns the positive (following) Vertex for this edge. This will be the same positive Vertex instance with which this edge was originally added to the layout. If the edge has not yet been added to the layout, this will return null.

Returns:
The positive Vertex for this edge or null.

remove

public final void remove()
This method removes this Edge instance from the layout graph. If the Edge was not already added to the graph, this method does nothing.

Warning This method is unsynchronised and it is up to the user to ensure that concurrent modification of the layout graph does not occur.