|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.RectangularShape
java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double
edu.umd.cs.piccolo.util.PBounds
public class PBounds
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.awt.geom.Rectangle2D |
---|
Rectangle2D.Double, 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()
Creates an empty bounds. |
|
PBounds(double x,
double y,
double width,
double height)
Constructs a PBounds object at the given coordinates with the given dimensions. |
|
PBounds(PBounds aBounds)
Creates a bounds identical to the one provided. |
|
PBounds(Point2D aCenterPoint,
double insetX,
double insetY)
Constructs a PBounds object with the given center point and the specified insets. |
|
PBounds(Rectangle2D aBounds)
Creates a bounds with the same shape as the rectangle provided. |
Method Summary | |
---|---|
void |
add(double newx,
double newy)
Grows the bounds to contain the coordinate provided. |
void |
add(PBounds bounds)
Changes this bounds to contain the provided bounds. |
void |
add(Rectangle2D r)
Grows bounds to contain the rectangle if needed. |
Object |
clone()
Returns a clone of this node. |
PDimension |
deltaRequiredToCenter(Rectangle2D targetBounds)
Returns the required translation in order for this bounds origin to sit on the center of the provided rectangle. |
PDimension |
deltaRequiredToContain(Rectangle2D targetBounds)
Returns the required translation in order for these to contain the bounds provided. |
void |
expandNearestIntegerDimensions()
Rounds the rectangle to the next largest bounds who's measurements are integers. |
Point2D |
getCenter2D()
Returns the midpoint of the bounds. |
Point2D |
getOrigin()
Returns the x,y coordinate of the bounds. |
Dimension2D |
getSize()
Returns the size of the bounds. |
PBounds |
inset(double dx,
double dy)
Adjust the measurements of this bounds so that they are the amounts given "in" from their previous border. |
boolean |
isEmpty()
Returns true if this bounds has been flagged as empty. |
PBounds |
moveBy(double dx,
double dy)
Translates the bounds by the given deltas. |
PBounds |
reset()
Flags this bounds as empty. |
PBounds |
resetToZero()
Resets the bounds to (0,0,0,0) and flags it as empty. |
PBounds |
setOrigin(double x,
double y)
Changes the origin of these bounds. |
void |
setRect(double x,
double y,
double width,
double height)
Sets the shape of the bounds to the position and dimension provided. |
void |
setRect(PBounds b)
Sets the bounds to the same shape as the bounds provided. |
void |
setRect(Rectangle2D r)
Sets the bounds to the same shape as the rectangle. |
void |
setSize(double width,
double height)
Changes the size of the bounds, but retains the origin. |
String |
toString()
Returns a string representation of this PBounds for debugging purposes. |
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 |
---|
public PBounds()
public PBounds(PBounds aBounds)
aBounds
- bounds to be copiedpublic PBounds(Rectangle2D aBounds)
aBounds
- rectangle to be copiedpublic PBounds(Point2D aCenterPoint, double insetX, double insetY)
aCenterPoint
- resulting center point of the PBounds objectinsetX
- distance from left and right the center should beinsetY
- distance from top and bottom the center should bepublic PBounds(double x, double y, double width, double height)
x
- left of boundsy
- top of boundswidth
- width of boundsheight
- height of boundsMethod Detail |
---|
public Object clone()
clone
in class RectangularShape
public boolean isEmpty()
isEmpty
in class Rectangle2D.Double
public PBounds reset()
public PBounds resetToZero()
public void setRect(Rectangle2D r)
setRect
in class Rectangle2D.Double
r
- rectangle to copypublic void setRect(PBounds b)
b
- bounds to copypublic void setRect(double x, double y, double width, double height)
setRect
in class Rectangle2D.Double
x
- new left of boundsy
- new top of boundswidth
- new width of boundsheight
- new height of boundspublic void add(double newx, double newy)
add
in class Rectangle2D
newx
- x component of pointnewy
- y component of pointpublic void add(Rectangle2D r)
add
in class Rectangle2D
r
- rectangle being addedpublic void add(PBounds bounds)
bounds
- bounds being addedpublic Point2D getOrigin()
public PBounds setOrigin(double x, double y)
x
- new x component of boundsy
- new y component of the bounds
public Dimension2D getSize()
public void setSize(double width, double height)
width
- new width of the boundsheight
- new height of the boundspublic Point2D getCenter2D()
public PBounds moveBy(double dx, double dy)
dx
- amount to move xdy
- amount to move y
public void expandNearestIntegerDimensions()
public PBounds inset(double dx, double dy)
dx
- amount to move in from border along horizontal axisdy
- amount to move in from border along vertical axis
public PDimension deltaRequiredToCenter(Rectangle2D targetBounds)
targetBounds
- rectangle to measure the center of
public PDimension deltaRequiredToContain(Rectangle2D targetBounds)
targetBounds
- rectangle to measure the center of
public String toString()
toString
in class Rectangle2D.Double
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |