|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.geom.RectangularShape
public abstract class RectangularShape
This class provides a generic framework, and several helper methods, for subclasses which represent geometric objects inside a rectangular frame. This does not specify any geometry except for the bounding box.
Arc2D
,
Ellipse2D
,
Rectangle2D
,
RoundRectangle2D
Constructor Summary | |
---|---|
protected |
RectangularShape()
Default constructor. |
Method Summary | |
---|---|
Object |
clone()
Create a new shape of the same run-time type with the same contents as this one. |
boolean |
contains(Point2D p)
Tests if a point is inside the boundary of the shape. |
boolean |
contains(Rectangle2D r)
Tests if the shape completely contains the given rectangle. |
Rectangle |
getBounds()
Returns a bounding box for this shape, in integer format. |
double |
getCenterX()
Return the x coordinate of the center point of the framing rectangle. |
double |
getCenterY()
Return the y coordinate of the center point of the framing rectangle. |
Rectangle2D |
getFrame()
Return the frame around this object. |
abstract double |
getHeight()
Get the height of the framing rectangle. |
double |
getMaxX()
Get the maximum x coordinate in the frame. |
double |
getMaxY()
Get the maximum y coordinate in the frame. |
double |
getMinX()
Get the minimum x coordinate in the frame. |
double |
getMinY()
Get the minimum y coordinate in the frame. |
PathIterator |
getPathIterator(AffineTransform at,
double flatness)
Return an iterator along the shape boundary. |
abstract double |
getWidth()
Get the width of the framing rectangle. |
abstract double |
getX()
Get the x coordinate of the upper-left corner of the framing rectangle. |
abstract double |
getY()
Get the y coordinate of the upper-left corner of the framing rectangle. |
boolean |
intersects(Rectangle2D r)
Tests if a rectangle and this shape share common internal points. |
abstract boolean |
isEmpty()
Test if the shape is empty, meaning that no points are inside it. |
abstract void |
setFrame(double x,
double y,
double w,
double h)
Set the framing rectangle of this shape to the given coordinate and size. |
void |
setFrame(Point2D p,
Dimension2D d)
Set the framing rectangle of this shape to the given coordinate and size. |
void |
setFrame(Rectangle2D r)
Set the framing rectangle of this shape to the given rectangle. |
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. |
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. |
void |
setFrameFromDiagonal(double x1,
double y1,
double x2,
double y2)
Set the framing rectangle of this shape using two points on a diagonal. |
void |
setFrameFromDiagonal(Point2D p1,
Point2D p2)
Set the framing rectangle of this shape using two points on a diagonal. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.awt.Shape |
---|
contains, contains, getBounds2D, getPathIterator, intersects |
Constructor Detail |
---|
protected RectangularShape()
Method Detail |
---|
public abstract double getX()
public abstract double getY()
public abstract double getWidth()
public abstract double getHeight()
public double getMinX()
public double getMinY()
public double getMaxX()
public double getMaxY()
public double getCenterX()
public double getCenterY()
public Rectangle2D getFrame()
setFrame(double, double, double, double)
public abstract boolean isEmpty()
public abstract void setFrame(double x, double y, double w, double h)
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new heightgetFrame()
public void setFrame(Point2D p, Dimension2D d)
p
- the new pointd
- the new dimension
NullPointerException
- if p or d is nullgetFrame()
public void setFrame(Rectangle2D r)
r
- the new framing rectangle
NullPointerException
- if r is nullgetFrame()
public void setFrameFromDiagonal(double x1, double y1, double x2, double y2)
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinatepublic void setFrameFromDiagonal(Point2D p1, Point2D p2)
p1
- the first pointp2
- the second point
NullPointerException
- if either point is nullpublic void setFrameFromCenter(double centerX, double centerY, double cornerX, double cornerY)
centerX
- the x coordinate at the centercenterY
- the y coordinate at the centercornerX
- the x coordinate at a cornercornerY
- the y coordinate at a cornerpublic void setFrameFromCenter(Point2D center, Point2D corner)
center
- the center pointcorner
- a corner point
NullPointerException
- if either point is nullpublic boolean contains(Point2D p)
contains
in interface Shape
p
- the point to test
NullPointerException
- if p is nullShape.contains(double, double)
public boolean intersects(Rectangle2D r)
intersects
in interface Shape
r
- the rectangle to test
NullPointerException
- if r is nullShape.intersects(double, double, double, double)
public boolean contains(Rectangle2D r)
contains
in interface Shape
r
- the rectangle to test
NullPointerException
- if r is nullShape.contains(double, double, double, double)
public Rectangle getBounds()
getBounds
in interface Shape
Shape.getBounds2D()
public PathIterator getPathIterator(AffineTransform at, double flatness)
Shape.getPathIterator(AffineTransform)
is as well.
getPathIterator
in interface Shape
at
- an optional transform to apply to the iteratorflatness
- the desired flatness
IllegalArgumentException
- if flatness is invalidpublic Object clone()
clone
in class Object
Cloneable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |