edu.umd.cs.jazz.util
Class ZLayout

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZLayout

public class ZLayout
extends java.lang.Object

ZLayout is a utility class that provides general-purpose layout mechanisms to position nodes.


Constructor Summary
ZLayout()
           
 
Method Summary
protected static float computeDimensionTranslation(java.awt.geom.Point2D dim, java.awt.geom.Point2D currentP, java.awt.geom.Point2D remainderP, java.awt.geom.Point2D finishedP, java.awt.geom.Point2D dir, java.util.Vector coordinates, boolean ascending)
          A helper function that computes the length of path in the given dimension.
static void distribute(java.util.Vector objects, java.util.Vector coordinates)
          Distributes a set of objects (those being ZNodes) along the path specified by coordinates.
static void distribute(java.util.Vector objects, java.util.Vector coordinates, boolean exact, boolean closedPath)
          Distributes a set of objects (those being ZNodes) along the (optionally closed) path specified by coordinates.
static void distribute(java.util.Vector objects, java.util.Vector coordinates, float tolerance, boolean closedPath)
          Distributes a set of objects (those being ZNodes) along the (optionally closed) path specified by coordinates.
static void distribute(java.util.Vector objects, java.util.Vector coordinates, float space, float tolerance, boolean exact, boolean closedPath)
          Distributes the given objects (those being ZNodes) along the (optionally closed) path specified by coordinates.
protected static void normalizeVector(java.awt.geom.Point2D p)
          Normalizes the given vector ie.
protected static float pathLength(java.util.Vector coords)
          Computes the length of the path for a given vector of coordinates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZLayout

public ZLayout()
Method Detail

distribute

public static void distribute(java.util.Vector objects,
                              java.util.Vector coordinates)
Distributes a set of objects (those being ZNodes) along the path specified by coordinates. Assumes exact spacing on a non-closed path with default tolerance.
Parameters:
objects - The objects to be distributed.
coordinates - The coordinates of the path.
See Also:
distribute(Vector, Vector, float, boolean)

distribute

public static void distribute(java.util.Vector objects,
                              java.util.Vector coordinates,
                              boolean exact,
                              boolean closedPath)
Distributes a set of objects (those being ZNodes) along the (optionally closed) path specified by coordinates. exact specifies, if false, that the algorithm should run once using a first guess at spacing or, if true, that the algorithm should attempt to evenly space the objects using the entire path.
Parameters:
objects - The objects to be distributed.
coordinates - The coordinates of the path.
exact - Should the algorithm run once and stop or iterate to get exact spacing.
closedPath - Does the path represent a closed path?
See Also:
distribute(Vector, Vector, float, float, boolean, boolean)

distribute

public static void distribute(java.util.Vector objects,
                              java.util.Vector coordinates,
                              float tolerance,
                              boolean closedPath)
Distributes a set of objects (those being ZNodes) along the (optionally closed) path specified by coordinates. The algorithm will iterate until the objects are placed along the path within tolerance of the given path.
Parameters:
objects - The objects to be distributed.
coordinates - The coordinates of the path.
tolerance - The error allowed in placing the objects
closedPath - Does the path represent a closed path?
See Also:
distribute(Vector, Vector, float, float, boolean, boolean)

distribute

public static void distribute(java.util.Vector objects,
                              java.util.Vector coordinates,
                              float space,
                              float tolerance,
                              boolean exact,
                              boolean closedPath)
Distributes the given objects (those being ZNodes) along the (optionally closed) path specified by coordinates. The algorithm initially distributes the objects with the specified space along the path. If exact spacing is not requested, the algorithm does not iterate. Hence, the objects will be spaced with the intial value of space regardless of the objects' positions. If exact spacing is requested, the algorithm iterates until the objects and spacing are within tolerance of the given path, where tolerance is specified as a percentage of the total path length. The algorithm will terminate with suboptimal results if the path is too short for the objects or if an optimal result cannot be computed.
Parameters:
objects - The objects to be distributed.
coordinates - The coordinates of the path.
space - The initial amount of spacing to leave between objects.
tolerance - The percent of the total path length to which the algorithm should compute, a value from 0.0-100.0.
exact - Should the algorithm iterate or make a single pass?
closedPath - Does the path represent a closed path?

computeDimensionTranslation

protected static float computeDimensionTranslation(java.awt.geom.Point2D dim,
                                                   java.awt.geom.Point2D currentP,
                                                   java.awt.geom.Point2D remainderP,
                                                   java.awt.geom.Point2D finishedP,
                                                   java.awt.geom.Point2D dir,
                                                   java.util.Vector coordinates,
                                                   boolean ascending)
A helper function that computes the length of path in the given dimension. Computes the destination location for the given dimension based on the current point, current remainder, and current direction. The caller can specify whether the coordinates should be viewed in ascending or descending order. If descending order is used, the coordinates are not removed from the vector.
Parameters:
dim - The dimension of the bounds in which to perfrom the computations
currentP - The current point on the path
remainderP - The remainder of path from previous point
finishedP - The storage location for the resultant destination point
dir - The current direction of the path
coordinates - The coordinates of the path
ascending - Look at the points of the path in ascending or descending order?
Returns:
A float equal to the length of the path in dim

pathLength

protected static float pathLength(java.util.Vector coords)
Computes the length of the path for a given vector of coordinates
Parameters:
coords - The path for which to compute the length
Returns:
The length of the given path

normalizeVector

protected static void normalizeVector(java.awt.geom.Point2D p)
Normalizes the given vector ie. maintains the vectors direction but gives it unit length
Parameters:
p - Vector (vector in the physics sense, actually a point) to be normalized