edu.umd.cs.jazz
Class ZGridLayoutManager

java.lang.Object
  |
  +--edu.umd.cs.jazz.ZGridLayoutManager
All Implemented Interfaces:
ZLayoutManager, ZSerializable

public class ZGridLayoutManager
extends java.lang.Object
implements ZLayoutManager, ZSerializable

A simple grid layout. Lays out objects into equally sized cells. Allows for the specification of the number of rows or columns, the cell width and height, the vertical and horizontal spacing, and the upper left grid layout start point. This layout preserves object aspect ratios.

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
See Also:
ZNode, ZLayout

Field Summary
static int COLUMN
           
protected static double DEFAULT_CELL_HEIGHT
           
protected static double DEFAULT_CELL_WIDTH
           
protected static double DEFAULT_HORIZONTAL_SPACING
           
protected static java.awt.geom.Point2D DEFAULT_START_POINT
           
protected static double DEFAULT_VERTICAL_SPACING
           
static int ROW
           
 
Constructor Summary
ZGridLayoutManager()
          The default no arg constructor
ZGridLayoutManager(int rowsOrColumns, int numCells)
          The default constructor
ZGridLayoutManager(int rowsOrColumns, int numCells, double width, double height)
          Constructor that allows cell dimensions to be specified
ZGridLayoutManager(int rowsOrColumns, int numCells, double width, double height, double horizontalSpacing, double verticalSpacing)
          Constructor that allows cell dimensions to be specified
ZGridLayoutManager(int rowsOrColumns, int numCells, double width, double height, double horizontalSpacing, double verticalSpacing, double layoutStartX, double layoutStartY)
          Constructor that allows cell dimensions to be specified
 
Method Summary
 java.lang.Object clone()
          Layout manager objects must provide a public clone method
 void doLayout(ZGroup node)
          Apply this manager's layout algorithm to the specified node's children.
 void doLayout(ZGroup node, int millis)
          Apply this manager's layout algorithm to the specified node's children, and animate the changes over time.
 double getCellHeight()
          Gets the cell height
 double getCellWidth()
          Gets the cell width
 int getGridAxis()
          Gets whether this grid is specified by rows or columns Possible values are: 1 - COLUMN 2 - ROW
 double getHorizontalSpacing()
          Gets the current horizontal spacing
 boolean getInvertChildren()
          Gets whether this layout manager inverts its children before laying them out.
 java.awt.geom.Point2D getLayoutStartPoint()
          Gets the layout start point
 int getNumCells()
          Gets the number of cells on the grid axis
 double getVerticalSpacing()
          Gets the current vertical spacing
 void postLayout(ZGroup node)
          Notify the layout manager that the layout for this node has finished This is called after all children and the node itself are layed out.
 void preLayout(ZGroup node)
          Notify the layout manager that a potentially recursive layout is starting.
 void setCellHeight(double height)
          Sets the cell height
 void setCellWidth(double width)
          Sets the cell width
 void setGridAxis(int rowsOrColumns)
          Sets whether this grid is specified by rows or columns Possible values are: 1 - COLUMN 2 - ROW
 void setHorizontalSpacing(double horizontalSpacing)
          Sets the current horizontal spacing
 void setInvertChildren(boolean invertChildren)
          Sets whether this layout manager should invert its children before laying them out.
 void setLayoutStartPoint(double x, double y)
          Sets the layout start point
 void setLayoutStartPoint(java.awt.geom.Point2D startPoint)
          Sets the layout start point
 void setNumCells(int numCells)
          Sets the number of cells on the grid axis
 void setState(java.lang.String fieldType, java.lang.String fieldName, java.lang.Object fieldValue)
          Set some state of this object as it gets read back in.
 void setVerticalSpacing(double verticalSpacing)
          Sets the current vertical spacing
 void writeObject(ZObjectOutputStream out)
          Write out all of this object's state.
 void writeObjectRecurse(ZObjectOutputStream out)
          Specify which objects this object references in order to write out the scenegraph properly
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN

public static final int COLUMN
See Also:
Constant Field Values

ROW

public static final int ROW
See Also:
Constant Field Values

DEFAULT_START_POINT

protected static final java.awt.geom.Point2D DEFAULT_START_POINT

DEFAULT_CELL_WIDTH

protected static final double DEFAULT_CELL_WIDTH
See Also:
Constant Field Values

DEFAULT_CELL_HEIGHT

protected static final double DEFAULT_CELL_HEIGHT
See Also:
Constant Field Values

DEFAULT_HORIZONTAL_SPACING

protected static final double DEFAULT_HORIZONTAL_SPACING
See Also:
Constant Field Values

DEFAULT_VERTICAL_SPACING

protected static final double DEFAULT_VERTICAL_SPACING
See Also:
Constant Field Values
Constructor Detail

ZGridLayoutManager

public ZGridLayoutManager()
The default no arg constructor


ZGridLayoutManager

public ZGridLayoutManager(int rowsOrColumns,
                          int numCells)
The default constructor

Parameters:
rowsOrColumns - Whether this manager should fix the number of rows or columns
numCells - The number of rows or columns to which this layout manager is fixed

ZGridLayoutManager

public ZGridLayoutManager(int rowsOrColumns,
                          int numCells,
                          double width,
                          double height)
Constructor that allows cell dimensions to be specified

Parameters:
rowsOrColumns - Whether this manager should fix the number of rows or columns
numCells - The number of rows or columns to which this layout manager is fixed
width - The row width
height - The row height

ZGridLayoutManager

public ZGridLayoutManager(int rowsOrColumns,
                          int numCells,
                          double width,
                          double height,
                          double horizontalSpacing,
                          double verticalSpacing)
Constructor that allows cell dimensions to be specified

Parameters:
rowsOrColumns - Whether this manager should fix the number of rows or columns
numCells - The number of rows or columns to which this layout manager is fixed
width - The row width
height - The row height
horizontalSpacing - The horizontal spacing between columns
verticalSpacing - The vertical spacing between rows

ZGridLayoutManager

public ZGridLayoutManager(int rowsOrColumns,
                          int numCells,
                          double width,
                          double height,
                          double horizontalSpacing,
                          double verticalSpacing,
                          double layoutStartX,
                          double layoutStartY)
Constructor that allows cell dimensions to be specified

Parameters:
rowsOrColumns - Whether this manager should fix the number of rows or columns
numCells - The number of rows or columns to which this layout manager is fixed
width - The row width
height - The row height
horizontalSpacing - The horizontal spacing between columns
verticalSpacing - The vertical spacing between rows
layoutStartX - The layout start x coordinate (in the coordinate system of the parent node being laid out)
Method Detail

getGridAxis

public int getGridAxis()
Gets whether this grid is specified by rows or columns Possible values are: 1 - COLUMN 2 - ROW

Returns:
Whether this rid is specified by rows or columns

setGridAxis

public void setGridAxis(int rowsOrColumns)
Sets whether this grid is specified by rows or columns Possible values are: 1 - COLUMN 2 - ROW

Parameters:
rowsOrColumns - Whether this rid is specified by rows or columns

setInvertChildren

public void setInvertChildren(boolean invertChildren)
Sets whether this layout manager should invert its children before laying them out. That is, should it lay out the children from front to back rather than back to front


getInvertChildren

public boolean getInvertChildren()
Gets whether this layout manager inverts its children before laying them out. That is, does it lay out the children from front to back rather than back to front


getNumCells

public int getNumCells()
Gets the number of cells on the grid axis

Returns:
The number of cells on the grid axis

setNumCells

public void setNumCells(int numCells)
Sets the number of cells on the grid axis

Parameters:
numCells - The number of cells on the grid axis

getCellWidth

public double getCellWidth()
Gets the cell width

Returns:
The cell width

setCellWidth

public void setCellWidth(double width)
Sets the cell width

Parameters:
width - The new cell width

getCellHeight

public double getCellHeight()
Gets the cell height

Returns:
The cell height

setCellHeight

public void setCellHeight(double height)
Sets the cell height

Parameters:
height - The new cell height

getVerticalSpacing

public double getVerticalSpacing()
Gets the current vertical spacing

Returns:
The current vertical spacing

setVerticalSpacing

public void setVerticalSpacing(double verticalSpacing)
Sets the current vertical spacing

Parameters:
verticalSpacing - The current vertical spacing

getHorizontalSpacing

public double getHorizontalSpacing()
Gets the current horizontal spacing

Returns:
The current horizontal spacing

setHorizontalSpacing

public void setHorizontalSpacing(double horizontalSpacing)
Sets the current horizontal spacing

Parameters:
horizontalSpacing - The current horizontal spacing

getLayoutStartPoint

public java.awt.geom.Point2D getLayoutStartPoint()
Gets the layout start point

Returns:
The layout start point

setLayoutStartPoint

public void setLayoutStartPoint(double x,
                                double y)
Sets the layout start point


setLayoutStartPoint

public void setLayoutStartPoint(java.awt.geom.Point2D startPoint)
Sets the layout start point

Parameters:
startPoint - The new layout start point

doLayout

public void doLayout(ZGroup node)
Apply this manager's layout algorithm to the specified node's children.

Specified by:
doLayout in interface ZLayoutManager
Parameters:
node - The node to apply this layout algorithm to.

doLayout

public void doLayout(ZGroup node,
                     int millis)
Apply this manager's layout algorithm to the specified node's children, and animate the changes over time.

Specified by:
doLayout in interface ZLayoutManager
Parameters:
node - The node to apply this layout algorithm to.
millis - The number of milliseconds over which to animate layout changes.

preLayout

public void preLayout(ZGroup node)
Notify the layout manager that a potentially recursive layout is starting. This is called before any children are layed out.

Specified by:
preLayout in interface ZLayoutManager
Parameters:
node - The node to apply this layout algorithm to.

postLayout

public void postLayout(ZGroup node)
Notify the layout manager that the layout for this node has finished This is called after all children and the node itself are layed out.

Specified by:
postLayout in interface ZLayoutManager
Parameters:
node - The node to apply this layout algorithm to.

clone

public java.lang.Object clone()
Layout manager objects must provide a public clone method

Specified by:
clone in interface ZLayoutManager
Overrides:
clone in class java.lang.Object

writeObject

public void writeObject(ZObjectOutputStream out)
                 throws java.io.IOException
Write out all of this object's state.

Specified by:
writeObject in interface ZSerializable
Parameters:
out - The stream that this object writes into
java.io.IOException

writeObjectRecurse

public void writeObjectRecurse(ZObjectOutputStream out)
                        throws java.io.IOException
Specify which objects this object references in order to write out the scenegraph properly

Specified by:
writeObjectRecurse in interface ZSerializable
Parameters:
out - The stream that this object writes into
java.io.IOException

setState

public void setState(java.lang.String fieldType,
                     java.lang.String fieldName,
                     java.lang.Object fieldValue)
Set some state of this object as it gets read back in. After the object is created with its default no-arg constructor, this method will be called on the object once for each bit of state that was written out through calls to ZObjectOutputStream.writeState() within the writeObject method.

Specified by:
setState in interface ZSerializable
Parameters:
fieldType - The fully qualified type of the field
fieldName - The name of the field
fieldValue - The value of the field


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