edu.umd.cs.piccolo.util
Class PBounds

java.lang.Object
  extended by java.awt.geom.RectangularShape
      extended by java.awt.geom.Rectangle2D
          extended by java.awt.geom.Rectangle2D.Double
              extended by edu.umd.cs.piccolo.util.PBounds
All Implemented Interfaces:
java.awt.Shape, java.io.Serializable, java.lang.Cloneable

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

PBounds is simply a Rectangle2D.Double with extra methods that more properly deal with the case when the rectangle is "empty". A PBounds has an extra bit to store emptiness. In this state, adding new geometry replaces the current geometry. A PBounds is emptied with the reset() method. A useful side effect of the reset method is that it only modifies the fIsEmpty variable, the other x, y, with, height variables are left alone. This is used by Piccolo's layout management system to see if a the full bounds of a node has really changed when it is recomputed. See PNode.validateLayout.

Version:
1.0
Author:
Jesse Grosjean
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces 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
PBounds()
           
PBounds(double x, double y, double width, double height)
           
PBounds(PBounds aBounds)
           
PBounds(java.awt.geom.Point2D aCenterPoint, double insetX, double insetY)
           
PBounds(java.awt.geom.Rectangle2D aBounds)
           
 
Method Summary
 void add(double newx, double newy)
           
 void add(PBounds r)
           
 void add(java.awt.geom.Rectangle2D r)
           
 java.lang.Object clone()
           
 PDimension deltaRequiredToCenter(java.awt.geom.Rectangle2D b)
           
 PDimension deltaRequiredToContain(java.awt.geom.Rectangle2D b)
           
 void expandNearestIntegerDimensions()
           
 java.awt.geom.Point2D getCenter2D()
           
 java.awt.geom.Point2D getOrigin()
           
 java.awt.geom.Dimension2D getSize()
           
 PBounds inset(double dx, double dy)
           
 boolean isEmpty()
           
 PBounds moveBy(double dx, double dy)
           
 PBounds reset()
           
 PBounds resetToZero()
           
 PBounds setOrigin(double x, double y)
           
 void setRect(double x, double y, double w, double h)
           
 void setRect(PBounds b)
           
 void setRect(java.awt.geom.Rectangle2D r)
           
 void setSize(double width, double height)
           
 java.lang.String toString()
           
 
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

PBounds

public PBounds()

PBounds

public PBounds(PBounds aBounds)

PBounds

public PBounds(java.awt.geom.Rectangle2D aBounds)

PBounds

public PBounds(java.awt.geom.Point2D aCenterPoint,
               double insetX,
               double insetY)

PBounds

public PBounds(double x,
               double y,
               double width,
               double height)
Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.awt.geom.RectangularShape

isEmpty

public boolean isEmpty()
Overrides:
isEmpty in class java.awt.geom.Rectangle2D.Double

reset

public PBounds reset()

resetToZero

public PBounds resetToZero()

setRect

public void setRect(java.awt.geom.Rectangle2D r)
Overrides:
setRect in class java.awt.geom.Rectangle2D.Double

setRect

public void setRect(PBounds b)

setRect

public void setRect(double x,
                    double y,
                    double w,
                    double h)
Overrides:
setRect in class java.awt.geom.Rectangle2D.Double

add

public void add(double newx,
                double newy)
Overrides:
add in class java.awt.geom.Rectangle2D

add

public void add(java.awt.geom.Rectangle2D r)
Overrides:
add in class java.awt.geom.Rectangle2D

add

public void add(PBounds r)

getOrigin

public java.awt.geom.Point2D getOrigin()

setOrigin

public PBounds setOrigin(double x,
                         double y)

getSize

public java.awt.geom.Dimension2D getSize()

setSize

public void setSize(double width,
                    double height)

getCenter2D

public java.awt.geom.Point2D getCenter2D()

moveBy

public PBounds moveBy(double dx,
                      double dy)

expandNearestIntegerDimensions

public void expandNearestIntegerDimensions()

inset

public PBounds inset(double dx,
                     double dy)

deltaRequiredToCenter

public PDimension deltaRequiredToCenter(java.awt.geom.Rectangle2D b)

deltaRequiredToContain

public PDimension deltaRequiredToContain(java.awt.geom.Rectangle2D b)

toString

public java.lang.String toString()
Overrides:
toString in class java.awt.geom.Rectangle2D.Double


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

Web Accessibility