java.awt.geom
Class RectangularShape
- Cloneable, Shape
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.
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.
|
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
clone
public Object clone()
Create a new shape of the same run-time type with the same contents as
this one.
- clone in interface Object
contains
public boolean contains(Point2D p)
Tests if a point is inside the boundary of the shape.
- contains in interface Shape
- true if the point is inside the shape
contains
public boolean contains(Rectangle2D r)
Tests if the shape completely contains the given rectangle.
- contains in interface Shape
r
- the rectangle to test
- true if r is contained in this shape
contains(double, double, double, double)
getBounds
public Rectangle getBounds()
Returns a bounding box for this shape, in integer format. Notice that you
may get a tighter bound with getBounds2D.
- getBounds in interface Shape
getCenterX
public double getCenterX()
Return the x coordinate of the center point of the framing rectangle.
getCenterY
public double getCenterY()
Return the y coordinate of the center point of the framing rectangle.
getFrame
public Rectangle2D getFrame()
Return the frame around this object. Note that this may be a looser
bounding box than getBounds2D.
- the frame, in double precision
getHeight
public abstract double getHeight()
Get the height of the framing rectangle.
getMaxX
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.
getMaxY
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.
getMinX
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.
getMinY
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.
getPathIterator
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 by
getPathIterator(AffineTransform)
is as well.
- getPathIterator in interface Shape
at
- an optional transform to apply to the iteratorflatness
- the desired flatness
- a new iterator over the boundary
getWidth
public abstract double getWidth()
Get the width of the framing rectangle.
getX
public abstract double getX()
Get the x coordinate of the upper-left corner of the framing rectangle.
getY
public abstract double getY()
Get the y coordinate of the upper-left corner of the framing rectangle.
intersects
public boolean intersects(Rectangle2D r)
Tests if a rectangle and this shape share common internal points.
- intersects in interface Shape
r
- the rectangle to test
- true if the rectangle intersects this shpae
intersects(double, double, double, double)
isEmpty
public abstract boolean isEmpty()
Test if the shape is empty, meaning that no points are inside it.
- true if the shape is empty
setFrame
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.
x
- the new x coordinatey
- the new y coordinatew
- the new widthh
- the new height
setFrame
public void setFrame(Point2D p,
Dimension2D d)
Set the framing rectangle of this shape to the given coordinate and size.
p
- the new pointd
- the new dimension
setFrame
public void setFrame(Rectangle2D r)
Set the framing rectangle of this shape to the given rectangle.
r
- the new framing rectangle
setFrameFromCenter
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.
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
setFrameFromCenter
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.
center
- the center pointcorner
- a corner point
setFrameFromDiagonal
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.
x1
- the first x coordinatey1
- the first y coordinatex2
- the second x coordinatey2
- the second y coordinate
setFrameFromDiagonal
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.
p1
- the first pointp2
- the second point
RectangularShape.java -- a rectangular frame for several generic shapes
Copyright (C) 2000, 2002 Free Software Foundation
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.