edu.umd.cs.jazz.util
Class ZBounds

java.lang.Object
  |
  +--java.awt.geom.RectangularShape
        |
        +--java.awt.geom.Rectangle2D
              |
              +--java.awt.geom.Rectangle2D.Double
                    |
                    +--edu.umd.cs.jazz.util.ZBounds
All Implemented Interfaces:
java.lang.Cloneable, java.io.Serializable, java.awt.Shape

public class ZBounds
extends java.awt.geom.Rectangle2D.Double
implements java.io.Serializable

ZBounds is simply a Rectangle2D.Double with extra methods that more properly deal with the case when the rectangle is "empty". A ZBounds has an extra bit to store emptiness. In this state, adding new geometry replaces the current geometry.

This is intended for use by visual objects that store their dimensions, and which may be empty.

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.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
 
Field Summary
 
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
ZBounds()
          Constructs a new ZBounds object.
ZBounds(double x, double y, double w, double h)
          Constructs a new ZBounds object with the given dimensions.
ZBounds(java.awt.geom.Rectangle2D rect)
          Constructs a new ZBounds object with the dimensions of a given Rectangle2D.
ZBounds(ZBounds bounds)
          Constructs a new ZBounds object with the dimensions of another ZBounds object.
 
Method Summary
 void add(double newx, double newy)
          Adds a point, specified by the double precision arguments newx and newy, to this ZBounds object.
 void add(java.awt.geom.Rectangle2D r)
          Adds a Rectangle2D object to this ZBounds object.
 void add(ZBounds r)
          Adds a ZBounds object to this ZBounds object.
 java.lang.Object clone()
          Returns a clone of this object.
 java.awt.geom.Point2D getCenter2D()
          Returns the center point of the bounds.
 void inset(double dx, double dy)
          This method insets the bounds by the specified amount.
 boolean isEmpty()
          Determines if this ZBounds object is empty.
 void reset()
          Sets the dimensions of this object be empty.
 void setRect(double x, double y, double w, double h)
          Sets the dimensions of this object.
 void setRect(java.awt.geom.Rectangle2D r)
          Sets the dimensions of this object to be the same as the given Rectangle2D.
 java.lang.String toString()
          Generate a string that represents this object for debugging.
 void transform(java.awt.geom.AffineTransform tf)
          Modify the object by applying the given transform.
 
Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, outcode
 
Methods inherited from class java.awt.geom.Rectangle2D
add, contains, contains, equals, getPathIterator, getPathIterator, hashCode, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
 
Methods inherited from class java.awt.geom.RectangularShape
contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ZBounds

public ZBounds()
Constructs a new ZBounds object.


ZBounds

public ZBounds(double x,
               double y,
               double w,
               double h)
Constructs a new ZBounds object with the given dimensions.

Parameters:
x - The X coordinate.
w - The width.
h - The height.

ZBounds

public ZBounds(java.awt.geom.Rectangle2D rect)
Constructs a new ZBounds object with the dimensions of a given Rectangle2D.

Parameters:
rect - The rectangle2D.

ZBounds

public ZBounds(ZBounds bounds)
Constructs a new ZBounds object with the dimensions of another ZBounds object.

Parameters:
bounds - The ZBounds object.
Method Detail

clone

public java.lang.Object clone()
Returns a clone of this object.

Overrides:
clone in class java.awt.geom.RectangularShape

reset

public void reset()
Sets the dimensions of this object be empty.


transform

public void transform(java.awt.geom.AffineTransform tf)
Modify the object by applying the given transform.

Parameters:
tf - the AffineTransform to apply.

getCenter2D

public java.awt.geom.Point2D getCenter2D()
Returns the center point of the bounds.


isEmpty

public boolean isEmpty()
Determines if this ZBounds object is empty.

Overrides:
isEmpty in class java.awt.geom.Rectangle2D.Double
Returns:
true if the bounds are empty, false otherwise.

setRect

public void setRect(double x,
                    double y,
                    double w,
                    double h)
Sets the dimensions of this object.

Overrides:
setRect in class java.awt.geom.Rectangle2D.Double
Parameters:
x - The X coordinate.
w - The width.
h - The height.

setRect

public void setRect(java.awt.geom.Rectangle2D r)
Sets the dimensions of this object to be the same as the given Rectangle2D.

Overrides:
setRect in class java.awt.geom.Rectangle2D.Double
Parameters:
r - the Rectangle2D

add

public void add(double newx,
                double newy)
Adds a point, specified by the double precision arguments newx and newy, to this ZBounds object. The resulting bounds is the smallest Rectangle2D that contains both the original bounds and the specified point.

Overrides:
add in class java.awt.geom.Rectangle2D
Parameters:
newx - The X coordinate of the new point.
newy - The Y coordinate of the new point.

add

public void add(java.awt.geom.Rectangle2D r)
Adds a Rectangle2D object to this ZBounds object. The resulting bounds is the union of the current bounds and the given Rectangle2D object.

Overrides:
add in class java.awt.geom.Rectangle2D
Parameters:
r - The Rectangle2D to add.

add

public void add(ZBounds r)
Adds a ZBounds object to this ZBounds object. The resulting bounds is the union of the current bounds and the given ZBounds object.

Parameters:
r - The ZBounds to add.

inset

public void inset(double dx,
                  double dy)
This method insets the bounds by the specified amount.


toString

public java.lang.String toString()
Generate a string that represents this object for debugging.

Overrides:
toString in class java.awt.geom.Rectangle2D.Double
Returns:
the string that represents this object for debugging


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