edu.umd.cs.jazz.util
Class ZLayout

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZLayout
All Implemented Interfaces:
java.io.Serializable

public class ZLayout
extends java.lang.Object
implements java.io.Serializable

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

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Lance Good
, Ben Bederson
See Also:
Serialized Form

Constructor Summary
ZLayout()
           
 
Method Summary
protected static double 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.ArrayList coordinates, boolean ascending)
          A helper function that computes the length of path in the given dimension.
static void distribute(ZNode[] nodes, java.util.ArrayList coordinates)
          Distributes a set of nodes (those being ZNodes) along the path specified by coordinates.
static void distribute(ZNode[] nodes, java.util.ArrayList coordinates, boolean exact, boolean closedPath)
          Distributes a set of nodes (those being ZNodes) along the (optionally closed) path specified by coordinates.
static void distribute(ZNode[] nodes, java.util.ArrayList coordinates, double tolerance, boolean closedPath)
          Distributes a set of nodes (those being ZNodes) along the (optionally closed) path specified by coordinates.
static void distribute(ZNode[] nodes, java.util.ArrayList coordinates, double space, double tolerance, boolean exact, boolean closedPath)
          Distributes the given nodes (those being ZNodes) along the (optionally closed) path specified by coordinates.
protected static void normalizeList(java.awt.geom.Point2D p)
          Normalizes the given ArrayList ie.
protected static double pathLength(java.util.ArrayList coords)
          Computes the length of the path for a given ArrayList 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(ZNode[] nodes,
                              java.util.ArrayList coordinates)
Distributes a set of nodes (those being ZNodes) along the path specified by coordinates. Assumes exact spacing on a non-closed path with default tolerance.

Parameters:
nodes - The nodes to be distributed.
coordinates - The coordinates of the path.
See Also:
distribute(ZNode[], ArrayList, double, boolean)

distribute

public static void distribute(ZNode[] nodes,
                              java.util.ArrayList coordinates,
                              boolean exact,
                              boolean closedPath)
Distributes a set of nodes (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 nodes using the entire path.

Parameters:
nodes - The nodes 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(ZNode[], ArrayList, double, double, boolean, boolean)

distribute

public static void distribute(ZNode[] nodes,
                              java.util.ArrayList coordinates,
                              double tolerance,
                              boolean closedPath)
Distributes a set of nodes (those being ZNodes) along the (optionally closed) path specified by coordinates. The algorithm will iterate until the nodes are placed along the path within tolerance of the given path.

Parameters:
nodes - The nodes to be distributed.
coordinates - The coordinates of the path.
tolerance - The error allowed in placing the nodes
closedPath - Does the path represent a closed path?
See Also:
distribute(ZNode[], ArrayList, double, double, boolean, boolean)

distribute

public static void distribute(ZNode[] nodes,
                              java.util.ArrayList coordinates,
                              double space,
                              double tolerance,
                              boolean exact,
                              boolean closedPath)
Distributes the given nodes (those being ZNodes) along the (optionally closed) path specified by coordinates. The algorithm initially distributes the nodes with the specified space along the path. If exact spacing is not requested, the algorithm does not iterate. Hence, the nodes will be spaced with the intial value of space regardless of the nodes' positions. If exact spacing is requested, the algorithm iterates until the nodes 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 nodes or if an optimal result cannot be computed.

Parameters:
nodes - The nodes to be distributed.
coordinates - The coordinates of the path.
space - The initial amount of spacing to leave between nodes.
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 double 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.ArrayList 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 ArrayList.

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 double equal to the length of the path in dim

pathLength

protected static double pathLength(java.util.ArrayList coords)
Computes the length of the path for a given ArrayList of coordinates

Parameters:
coords - The path for which to compute the length
Returns:
The length of the given path

normalizeList

protected static void normalizeList(java.awt.geom.Point2D p)
Normalizes the given ArrayList ie. maintains the ArrayLists direction but gives it unit length

Parameters:
p - ArrayList (ArrayList in the physics sense, actually a point) to be normalized


Copyright 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.