Jazz API Documentation

edu.umd.cs.jazz
Class ZTreeLayoutManager

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

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

ZTreeLayoutManager implements a generic tree layout manager that can layout hierarchical Jazz objects, ie. a scenegraph. This layout does not give each child subtree in the scenegraph enough room for the bounding box of the entire subtree, rather it tries to minimize the total space used while maintaining no overlap among child subtrees.


Field Summary
protected  java.util.Hashtable areaManager
           
protected  int currentHeadStyle
           
protected  int currentLinkStyle
           
protected static int currentOrientation
           
protected  float currentXSpacing
           
protected  float currentYSpacing
           
protected static float DEFAULT_SPACING
           
static int HEAD_IN
          Heading style that puts current node at the middle of its immediate children
static int HEAD_OUT
          Heading style that puts current node at the middle of all its children
static int HEAD_SIDE
          Heading style that puts current node at one side of all its children (ie.
static int LINK_ANGLEDLINE
          This option connects parent nodes to child nodes with vertical and horizontal lines only
static int LINK_STRAIGHTLINE
          This option connects parent nodes to child nodes with a straight line
protected  boolean linkVisible
           
static int ORIENT_HORIZONTAL
          Horizontal Tree Layout - a left to right layout
static int ORIENT_VERTICAL
          Vertical Tree Layout - a top to bottom layout
protected static java.awt.geom.Point2D ORIGIN
           
protected  int recurseLevel
           
protected  java.util.ArrayList transformNodes
           
protected  java.util.Hashtable transformTable
           
 
Constructor Summary
ZTreeLayoutManager()
          The default constructor - uses all default values
ZTreeLayoutManager(int orientation, int headingStyle, boolean showLink, int linkStyle)
          Fully qualified constructor
 
Method Summary
protected  void calculateChildrenLayout(ZGroup aPrimaryGroup)
          Appropriately Lays out the children of the provided node
protected  void computeNodeArea(ZNode aPrimaryNode)
          Computes the given nodes area - this includes the bounds of its visual component and the stored areas for its immediate children
protected  java.awt.geom.Point2D computeOverlap(java.awt.geom.Area a, java.awt.geom.Area b)
          Returns the overlap of the two given areas
 void doLayout(ZGroup aLayoutGroup)
          Method from the ZLayoutManager interface Called to layout the layout group
 int getCurrentHeadStyle()
          Get the current heading style
 int getCurrentOrientation()
          Get the current orientation.
 float getCurrentXSpacing()
          Get the current x spacing
 float getCurrentYSpacing()
          Get the current y spacing
protected  ZBounds getFrontVisualComponentBounds(ZNode aVisualNode)
          Convenience method to get the bounds of the front visual component of the given node
 int getLinkStyle()
          Get the value of linkStyle.
protected  java.awt.geom.Area getNodeArea(ZNode aPrimaryNode)
          Gets the stored area for the given node
protected  ZBounds padBounds(ZBounds bounds)
          Convenience method to pad the given bounds with the current spacing
 void postLayout(ZGroup aLayoutGroup)
          Method from the ZLayoutManager interface Called after doLayout
 void preLayout(ZGroup aLayoutGroup)
          Method from the ZLayoutManager interface Called before doLayout
protected  void resetTransformVariables()
          Resets the transformTable and the transformNodes
 boolean setCurrentHeadingStyle(ZLayoutGroup layout, int h)
           
 boolean setCurrentOrientation(ZLayoutGroup layout, int orientation)
          Set the current orientation.
 boolean setCurrentXSpacing(float x)
           
 boolean setCurrentYSpacing(float y)
           
protected  java.awt.geom.Point2D setDestinationPoint(ZNode aPrimaryNode, java.awt.geom.Point2D dest)
          Sets the bounds location for the given node to the specified point The resulting translation is meant to be a pure translation that will not depend on any scaling in this node's transform - ie.
 boolean setLinkStyle(ZLayoutGroup layout, int v)
          Set the value of linkStyle.
 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.
protected  void translateDestinationPoint(ZNode aPrimaryNode, java.awt.geom.Point2D trans)
          Translates the transform for the transform corresponding to the given node in the transformTable This is meant to be a pure translation that will not depend on any scaling in this node's transform - ie.
protected  java.awt.geom.Area updateChildArea(ZNode aPrimaryNode, java.awt.geom.Point2D trans)
          Translates the child nodes area, potentially stored in the area manager, by the specified translation
protected static void updateInvalidLinks(ZNode top)
          Updates all links, in depth-first order, below the supplied ZNode
protected  void updateTree()
          Actually transforms all nodes that have a stored transform in the transformTable
 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORIENT_VERTICAL

public static final int ORIENT_VERTICAL
Vertical Tree Layout - a top to bottom layout

ORIENT_HORIZONTAL

public static final int ORIENT_HORIZONTAL
Horizontal Tree Layout - a left to right layout

HEAD_IN

public static final int HEAD_IN
Heading style that puts current node at the middle of its immediate children

HEAD_OUT

public static final int HEAD_OUT
Heading style that puts current node at the middle of all its children

HEAD_SIDE

public static final int HEAD_SIDE
Heading style that puts current node at one side of all its children (ie. left-most or top-most)

LINK_STRAIGHTLINE

public static final int LINK_STRAIGHTLINE
This option connects parent nodes to child nodes with a straight line

LINK_ANGLEDLINE

public static final int LINK_ANGLEDLINE
This option connects parent nodes to child nodes with vertical and horizontal lines only

DEFAULT_SPACING

protected static float DEFAULT_SPACING

ORIGIN

protected static final java.awt.geom.Point2D ORIGIN

currentHeadStyle

protected int currentHeadStyle

currentOrientation

protected static int currentOrientation

currentXSpacing

protected float currentXSpacing

currentYSpacing

protected float currentYSpacing

currentLinkStyle

protected int currentLinkStyle

linkVisible

protected boolean linkVisible

areaManager

protected java.util.Hashtable areaManager

transformTable

protected java.util.Hashtable transformTable

transformNodes

protected java.util.ArrayList transformNodes

recurseLevel

protected int recurseLevel
Constructor Detail

ZTreeLayoutManager

public ZTreeLayoutManager()
The default constructor - uses all default values

ZTreeLayoutManager

public ZTreeLayoutManager(int orientation,
                          int headingStyle,
                          boolean showLink,
                          int linkStyle)
Fully qualified constructor
Parameters:
orientation - The desired tree layout orientation - ORIENT_VERTICAL or ORIENT_HORIZONTAL
headingStyle - The desired head style - HEAD_IN, HEAD_OUT, or HEAD_SIDE
showLink - Should links be displayed
linkStyle - If links are displayed, the style of links - LINK_STRAIGHTLINE or LINK_ANGLEDLINE
Method Detail

setCurrentOrientation

public boolean setCurrentOrientation(ZLayoutGroup layout,
                                     int orientation)
Set the current orientation. If the orientation is not supported, nothing will happen.
Parameters:
orientation - the desired orientation - ORIENT_VERTICAL or ORIENT_HORIZONTAL
Returns:
true if orientation set, false if orientation not supported.

getCurrentOrientation

public int getCurrentOrientation()
Get the current orientation.
Returns:
returns the current orientation for this tree

setCurrentHeadingStyle

public boolean setCurrentHeadingStyle(ZLayoutGroup layout,
                                      int h)
Parameters:
h - the desired heading style - HEAD_IN, HEAD_OUT, or HEAD_SIDE
Returns:
true if set successfuly, false otherwise

getCurrentHeadStyle

public int getCurrentHeadStyle()
Get the current heading style
Returns:
the current heading style

setCurrentXSpacing

public boolean setCurrentXSpacing(float x)
Parameters:
x - the value for x spacing -- horizontal spacing
Returns:
true if set successfuly, false otherwise

setCurrentYSpacing

public boolean setCurrentYSpacing(float y)
Parameters:
y - the value for y spacing -- horizontal spacing
Returns:
true if set successfuly, false otherwise

getCurrentXSpacing

public float getCurrentXSpacing()
Get the current x spacing
Returns:
current x spacing

getCurrentYSpacing

public float getCurrentYSpacing()
Get the current y spacing
Returns:
current y spacing

getLinkStyle

public int getLinkStyle()
Get the value of linkStyle.
Returns:
Value of linkStyle.

setLinkStyle

public boolean setLinkStyle(ZLayoutGroup layout,
                            int v)
Set the value of linkStyle.
Parameters:
v - Value to assign to linkStyle - LINK_STRAIGHTLINE or LINK_ANGLEDLINE
Returns:
true if set successfuly

preLayout

public void preLayout(ZGroup aLayoutGroup)
Method from the ZLayoutManager interface Called before doLayout
Specified by:
preLayout in interface ZLayoutManager
Parameters:
aLayoutGroup - The layout group currently under consideration

doLayout

public void doLayout(ZGroup aLayoutGroup)
Method from the ZLayoutManager interface Called to layout the layout group
Specified by:
doLayout in interface ZLayoutManager
Parameters:
aLayoutGroup - The layout group currently under consideration

postLayout

public void postLayout(ZGroup aLayoutGroup)
Method from the ZLayoutManager interface Called after doLayout
Specified by:
postLayout in interface ZLayoutManager
Parameters:
aLayoutGroup - The layout group currently under consideration

calculateChildrenLayout

protected void calculateChildrenLayout(ZGroup aPrimaryGroup)
Appropriately Lays out the children of the provided node
Parameters:
aPrimaryGroup - The primary group for which the children should be laid out

updateTree

protected void updateTree()
Actually transforms all nodes that have a stored transform in the transformTable

translateDestinationPoint

protected void translateDestinationPoint(ZNode aPrimaryNode,
                                         java.awt.geom.Point2D trans)
Translates the transform for the transform corresponding to the given node in the transformTable This is meant to be a pure translation that will not depend on any scaling in this node's transform - ie. this resulting transform will be preConcatenated with the node's current transform
Parameters:
aPrimaryNode - the primary node to transform
trans - the amount to translate

setDestinationPoint

protected java.awt.geom.Point2D setDestinationPoint(ZNode aPrimaryNode,
                                                    java.awt.geom.Point2D dest)
Sets the bounds location for the given node to the specified point The resulting translation is meant to be a pure translation that will not depend on any scaling in this node's transform - ie. this resulting will be preConcatenated with the node's current transform
Parameters:
aPrimaryNode - the primary node to transform
trans - the amount to translate
Returns:
The translation needed to set the destination point to dest

updateChildArea

protected java.awt.geom.Area updateChildArea(ZNode aPrimaryNode,
                                             java.awt.geom.Point2D trans)
Translates the child nodes area, potentially stored in the area manager, by the specified translation
Parameters:
aPrimaryNode - the primary child node whose area is to be updated
trans - the translation by which the area is to be updated
Returns:
The currently stored area for the given node

computeNodeArea

protected void computeNodeArea(ZNode aPrimaryNode)
Computes the given nodes area - this includes the bounds of its visual component and the stored areas for its immediate children
Parameters:
aPrimaryNode - the node for which the area is computed

getNodeArea

protected java.awt.geom.Area getNodeArea(ZNode aPrimaryNode)
                                  throws java.util.ConcurrentModificationException
Gets the stored area for the given node
Parameters:
aPrimaryNode - The node for which the area is desired

getFrontVisualComponentBounds

protected ZBounds getFrontVisualComponentBounds(ZNode aVisualNode)
Convenience method to get the bounds of the front visual component of the given node
Parameters:
aVisualNode - The node for which the visual component bounds are desired

padBounds

protected ZBounds padBounds(ZBounds bounds)
Convenience method to pad the given bounds with the current spacing
Parameters:
bounds - the bounds to be padded
Returns:
Convenience return of the padded bounds

computeOverlap

protected java.awt.geom.Point2D computeOverlap(java.awt.geom.Area a,
                                               java.awt.geom.Area b)
Returns the overlap of the two given areas
Parameters:
a - one area for which overlap is computed
b - one area for which overlap is computed
Returns:
The current amount to translate to reduce overlap

resetTransformVariables

protected void resetTransformVariables()
Resets the transformTable and the transformNodes

updateInvalidLinks

protected static void updateInvalidLinks(ZNode top)
Updates all links, in depth-first order, below the supplied ZNode
Parameters:
top - The node below which all links should be updated

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

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

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

Jazz API Documentation