net.goui.util
Class GraphLayout.Vertex

java.lang.Object
  extended bynet.goui.util.GraphLayout.Vertex
Enclosing class:
GraphLayout

public static class GraphLayout.Vertex
extends java.lang.Object

Author:
David Beaumont, Copyright 2005

This class is used to connect edges within the layout graph. A Vertex has a position which can either be set explicitly or will be determined during a layout procedure.

Unlike edges, which typically require specific constraint information to provide useful behaviour, it is not expected that Vertex will need to be subclassed during the use of a GraphLayout and while the class itself is not final, all its methods are.


Constructor Summary
GraphLayout.Vertex()
          Create a Vertex which will initially have no set position.
 
Method Summary
 int getPosition()
          This method returns the current position of this Vertex if it has been uniquely determined.
 int setPosition(int pos)
          This method will attempt to set the position of this Vertex to the given value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GraphLayout.Vertex

public GraphLayout.Vertex()
Create a Vertex which will initially have no set position. When laying out a sequence of edges (Path) you must first ensure that the Vertices at either end of the Path have a valid position, so after calling reset() on a GraphLayout instance it is necessary to set the position of the end Vertices in the first Path to be laid out.

Method Detail

setPosition

public final int setPosition(int pos)
This method will attempt to set the position of this Vertex to the given value. However due to the constraints placed upon it by the structure of the layout graph, it may not be able to honour this request without violating a minimum size constraint of an edge.

If this occurs then the Vertex will be placed at the closest position to the given value which is permitted by the layout constraints and this new value will be returned. This method will never fail to place a Vertex, however once a Vertex has had its position set, the reset() method must be called on it (or on the GraphLayout to which it belongs) before a different position can be set.

Because there is an overall constraint that Vertices cannot hold negative positions, the value returned from this method will never be negative, irrespective of the input value.

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

Parameters:
pos - The requested position for this Vertex.
Returns:
The actual position of this Vertex.

getPosition

public final int getPosition()
This method returns the current position of this Vertex if it has been uniquely determined. If this Vertex forms part of a Path which has been laid out successfully then it will have a valid position.

Note that because any source Vertices must have a non-negative initial position and because Edges always have a non-negative size, the position of every Vertex in the graph must also be non-negative once it has been determined.

If the position is not known, GraphLayout.INVALID is returned.

Returns:
The non-negative position of this Vertex, or INVALID.