edu.nrao.sss.geom
Class Circle

java.lang.Object
  extended by edu.nrao.sss.geom.Circle
All Implemented Interfaces:
Shape, Cloneable

public class Circle
extends Object
implements Shape, Cloneable

A circle described by a central point and radial length. This circle class fits in with java's 2D package.

Version Info:

$Revision: 797 $
$Date: 2007-08-08 16:48:50 -0600 (Wed, 08 Aug 2007) $
$Author: dharland $ (last person to modify)

Since:
2007-08-07
Author:
David M. Harland

Constructor Summary
Circle(double radius)
          Creates a new circle, centered at the origin, with the given radius.
Circle(Point2D center, double radius)
          Creates a new circle with the given center and radius.
 
Method Summary
 Circle clone()
          Creates a copy of this circle.
 boolean contains(double x, double y)
           
 boolean contains(double x, double y, double w, double h)
           
 boolean contains(Point2D p)
           
 boolean contains(Rectangle2D r)
           
 Rectangle getBounds()
           
 Rectangle2D getBounds2D()
           
 Point2D getCenter()
          Returns a copy of the center of this circle.
 double getDiameter()
          Returns the diameter of this circle.
 PathIterator getPathIterator(AffineTransform at)
           
 PathIterator getPathIterator(AffineTransform at, double flatness)
           
 double getRadius()
          Returns the radius of this circle.
 boolean intersects(double x, double y, double w, double h)
           
 boolean intersects(Rectangle2D r)
          
 void setCenter(Point2D newCenter)
          Sets the center of this circle to be coincident with newCenter.
 void setRadius(double newRadius)
          Sets the radius of this circle.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Circle

public Circle(double radius)
Creates a new circle, centered at the origin, with the given radius.

Parameters:
radius - the radius of this circle. The units are arbitrary, but are often taken to be pixels.

Circle

public Circle(Point2D center,
              double radius)
Creates a new circle with the given center and radius.

Parameters:
center - the center of this circle.
radius - the radius of this circle. The units are arbitrary, but are often taken to be pixels. If this value is infinite, negative, or not a number, the radius will be set to one.
Method Detail

setRadius

public void setRadius(double newRadius)
Sets the radius of this circle. If newRadius is negative, infinite, or not a number, an IllegalArgumentException is thrown.

Parameters:
newRadius - the new radius of this circle.

getRadius

public double getRadius()
Returns the radius of this circle. The units are arbitrary, but are often taken to be pixels.

Returns:
the radius of this circle.

getDiameter

public double getDiameter()
Returns the diameter of this circle. The units are arbitrary, but are often taken to be pixels.

Returns:
the diameter of this circle.

setCenter

public void setCenter(Point2D newCenter)
Sets the center of this circle to be coincident with newCenter. Note that this circle will not hold a reference to newCenter, so changes made to it after calling this method will not be reflected herein.

If newCenter is null, the center of this circle will not be altered.

Parameters:
newCenter - the new center of this circle.

getCenter

public Point2D getCenter()
Returns a copy of the center of this circle.

Returns:
a copy of the center of this circle.

contains

public boolean contains(double x,
                        double y)
Specified by:
contains in interface Shape

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Specified by:
contains in interface Shape

contains

public boolean contains(Point2D p)
Specified by:
contains in interface Shape

contains

public boolean contains(Rectangle2D r)
Specified by:
contains in interface Shape

getBounds

public Rectangle getBounds()
Specified by:
getBounds in interface Shape

getBounds2D

public Rectangle2D getBounds2D()
Specified by:
getBounds2D in interface Shape

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Specified by:
getPathIterator in interface Shape

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Specified by:
getPathIterator in interface Shape

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Specified by:
intersects in interface Shape

intersects

public boolean intersects(Rectangle2D r)

Specified by:
intersects in interface Shape

clone

public Circle clone()
Creates a copy of this circle. If anything goes wrong during the cloning process a runtime exception is thrown.

Overrides:
clone in class Object


Copyright © 2009. All Rights Reserved.