Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.geom.RectangularShape
Arc2D
, Ellipse2D
, Rectangle2D
, RoundRectangle2D
Constructor Summary | |
|
Method Summary | |
Object |
|
boolean | |
boolean |
|
Rectangle |
|
double |
|
double |
|
Rectangle2D |
|
abstract double |
|
double |
|
double |
|
double |
|
double |
|
PathIterator |
|
abstract double |
|
abstract double |
|
abstract double |
|
boolean |
|
abstract boolean |
|
abstract void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public Object clone()
Create a new shape of the same run-time type with the same contents as this one.
- Returns:
- the clone
public boolean contains(Point2D p)
Tests if a point is inside the boundary of the shape.
- Parameters:
p
- the point to test
- Returns:
- true if the point is inside the shape
- Throws:
NullPointerException
- if p is null
- See Also:
contains(double, double)
public boolean contains(Rectangle2D r)
Tests if the shape completely contains the given rectangle.
- Parameters:
r
- the rectangle to test
- Returns:
- true if r is contained in this shape
- Throws:
NullPointerException
- if r is null
- See Also:
contains(double, double, double, double)
public Rectangle getBounds()
Returns a bounding box for this shape, in integer format. Notice that you may get a tighter bound with getBounds2D.
- Returns:
- a bounding box
public double getCenterX()
Return the x coordinate of the center point of the framing rectangle.
- Returns:
- the central x coordinate
public double getCenterY()
Return the y coordinate of the center point of the framing rectangle.
- Returns:
- the central y coordinate
public Rectangle2D getFrame()
Return the frame around this object. Note that this may be a looser bounding box than getBounds2D.
- Returns:
- the frame, in double precision
public abstract double getHeight()
Get the height of the framing rectangle.
- Returns:
- the height
public double getMaxX()
Get the maximum x coordinate in the frame. This is misnamed, or else Sun has a bug, because the implementation returns getX()+getWidth() even when getWidth() is negative.
- Returns:
- the maximum x coordinate
public double getMaxY()
Get the maximum y coordinate in the frame. This is misnamed, or else Sun has a bug, because the implementation returns getY()+getHeight() even when getHeight() is negative.
- Returns:
- the maximum y coordinate
public double getMinX()
Get the minimum x coordinate in the frame. This is misnamed, or else Sun has a bug, because the implementation returns getX() even when getWidth() is negative.
- Returns:
- the minimum x coordinate
public double getMinY()
Get the minimum y coordinate in the frame. This is misnamed, or else Sun has a bug, because the implementation returns getY() even when getHeight() is negative.
- Returns:
- the minimum y coordinate
public PathIterator getPathIterator(AffineTransform at, double flatness)
Return an iterator along the shape boundary. If the optional transform is provided, the iterator is transformed accordingly. The path is flattened until all segments differ from the curve by at most the value of the flatness parameter, within the limits of the default interpolation recursion limit of 1024 segments between actual points. Each call returns a new object, independent from others in use. The result is threadsafe if and only if the iterator returned bygetPathIterator(AffineTransform)
is as well.
- Specified by:
- getPathIterator in interface Shape
- Parameters:
at
- an optional transform to apply to the iteratorflatness
- the desired flatness
- Returns:
- a new iterator over the boundary
- Throws:
IllegalArgumentException
- if flatness is invalid
- Since:
- 1.2
public abstract double getX()
Get the x coordinate of the upper-left corner of the framing rectangle.
- Returns:
- the x coordinate
public abstract double getY()
Get the y coordinate of the upper-left corner of the framing rectangle.
- Returns:
- the y coordinate
public boolean intersects(Rectangle2D r)
Tests if a rectangle and this shape share common internal points.
- Specified by:
- intersects in interface Shape
- Parameters:
r
- the rectangle to test
- Returns:
- true if the rectangle intersects this shpae
- Throws:
NullPointerException
- if r is null
- See Also:
intersects(double, double, double, double)
public abstract boolean isEmpty()
Test if the shape is empty, meaning that no points are inside it.
- Returns:
- true if the shape is empty
public abstract void setFrame(double x, double y, double w, double h)
Set the framing rectangle of this shape to the given coordinate and size.
- Parameters:
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new height
- See Also:
getFrame()
public void setFrame(Point2D p, Dimension2D d)
Set the framing rectangle of this shape to the given coordinate and size.
- Parameters:
p
- the new pointd
- the new dimension
- Throws:
NullPointerException
- if p or d is null
- See Also:
getFrame()
public void setFrame(Rectangle2D r)
Set the framing rectangle of this shape to the given rectangle.
- Parameters:
r
- the new framing rectangle
- Throws:
NullPointerException
- if r is null
- See Also:
getFrame()
public void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
Set the framing rectangle of this shape using the center of the frame, and one of the four corners. The area will be positive.
- Parameters:
centerX
- the x coordinate at the centercenterY
- the y coordinate at the centercornerX
- the x coordinate at a cornercornerY
- the y coordinate at a corner
public void setFrameFromCenter(Point2D center, Point2D corner)
Set the framing rectangle of this shape using the center of the frame, and one of the four corners. The area will be positive.
- Parameters:
center
- the center pointcorner
- a corner point
- Throws:
NullPointerException
- if either point is null
public void setFrameFromDiagonal(double x1, double y1, double x2, double y2)
Set the framing rectangle of this shape using two points on a diagonal. The area will be positive.
- Parameters:
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinate
public void setFrameFromDiagonal(Point2D p1, Point2D p2)
Set the framing rectangle of this shape using two points on a diagonal. The area will be positive.
- Parameters:
p1
- the first pointp2
- the second point
- Throws:
NullPointerException
- if either point is null