org.softsmithy.lib.awt
Class Star

java.lang.Object
  extended by org.softsmithy.lib.awt.Star
All Implemented Interfaces:
Shape

public class Star
extends Object
implements Shape

A star shape.

Author:
puce

Constructor Summary
Star(int x, int y, int width, int height)
          Creates a new Star Shape.
 
Method Summary
 boolean contains(double x, double y)
          Determines if the specified coordinates are inside this Star.
 boolean contains(double x, double y, double w, double h)
          Tests if the interior of this Star entirely contains the specified set of rectangular coordinates.
 boolean contains(Point2D p)
          Tests if a specified Point2D is inside the boundary of this Star.
 boolean contains(Rectangle2D r)
          Tests if the interior of this Star entirely contains the specified Rectangle2D.
 Rectangle getBounds()
          Gets the bounding box of this Star.
 Rectangle2D getBounds2D()
          Returns the high precision bounding box of the Shape.
 PathIterator getPathIterator(AffineTransform at)
          Returns an iterator object that iterates along the boundary of this Star and provides access to the geometry of the outline of this Star.
 PathIterator getPathIterator(AffineTransform at, double flatness)
          Returns an iterator object that iterates along the boundary of the Shape and provides access to the geometry of the outline of the Shape.
 boolean intersects(double x, double y, double w, double h)
          Tests if the interior of this Star intersects the interior of a specified set of rectangular coordinates.
 boolean intersects(Rectangle2D r)
          Tests if the interior of this Star intersects the interior of a specified Rectangle2D.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Star

public Star(int x,
            int y,
            int width,
            int height)
Creates a new Star Shape.

Parameters:
x - x-coordinate of the top-left corner
y - y-coordinate of the top-left corner
width - width of the star
height - height of the star
Method Detail

getBounds

public Rectangle getBounds()
Gets the bounding box of this Star. The bounding box is the smallest rectangle whose sides are parallel to the x and y axes of the coordinate space, and can completely contain the Star.

Specified by:
getBounds in interface Shape
Returns:
a Rectangle that defines the bounds of this Star.
See Also:
getBounds2D()

getBounds2D

public Rectangle2D getBounds2D()
Returns the high precision bounding box of the Shape.

Specified by:
getBounds2D in interface Shape
Returns:
a Rectangle2D that precisely bounds the Shape.
See Also:
getBounds()

contains

public boolean contains(double x,
                        double y)
Determines if the specified coordinates are inside this Star. For the definition of insideness, see the class comments of Shape.

Specified by:
contains in interface Shape
Parameters:
x - x-coordinate
y - y-coordinate
Returns:
true if the Star contains the specified coordinates; false otherwise.

contains

public boolean contains(Point2D p)
Tests if a specified Point2D is inside the boundary of this Star.

Specified by:
contains in interface Shape
Parameters:
p - a specified Point2D
Returns:
true if this Star contains the specified Point2D; false otherwise.
See Also:
contains(double x, double y)

intersects

public boolean intersects(double x,
                          double y,
                          double w,
                          double h)
Tests if the interior of this Star intersects the interior of a specified set of rectangular coordinates.

Specified by:
intersects in interface Shape
Parameters:
x - x-coordinate of the top-left corner of the specified rectangular area
y - y-coordinate of the top-left corner of the specified rectangular area
w - the width of the specified rectangular area
h - the height of the specified rectangular area
Returns:
true if the interior of this Star and the interior of the specified set of rectangular coordinates intersect each other; false otherwise.
See Also:
Area

intersects

public boolean intersects(Rectangle2D r)
Tests if the interior of this Star intersects the interior of a specified Rectangle2D.

Specified by:
intersects in interface Shape
Parameters:
r - a specified Rectangle2D
Returns:
true if this Star and the interior of the specified Rectangle2D intersect each other; false otherwise.
See Also:
intersects(double, double, double, double)

contains

public boolean contains(double x,
                        double y,
                        double w,
                        double h)
Tests if the interior of this Star entirely contains the specified set of rectangular coordinates.

Specified by:
contains in interface Shape
Parameters:
x - x-coordinate of the top-left corner of the specified rectangular area
y - y-coordinate of the top-left corner of the specified rectangular area
w - the width of the set of rectangular coordinates
h - the height of the set of rectangular coordinates
Returns:
true if this Star entirely contains the specified set of rectangular coordinates; false otherwise.
See Also:
Area, intersects(double, double, double, double)

contains

public boolean contains(Rectangle2D r)
Tests if the interior of this Star entirely contains the specified Rectangle2D.

Specified by:
contains in interface Shape
Parameters:
r - the specified Rectangle2D
Returns:
true if this Star entirely contains the specified Rectangle2D; false otherwise.
See Also:
contains(double, double, double, double)

getPathIterator

public PathIterator getPathIterator(AffineTransform at)
Returns an iterator object that iterates along the boundary of this Star and provides access to the geometry of the outline of this Star. An optional AffineTransform can be specified so that the coordinates returned in the iteration are transformed accordingly.

Specified by:
getPathIterator in interface Shape
Parameters:
at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
Returns:
a PathIterator object that provides access to the geometry of this Star.

getPathIterator

public PathIterator getPathIterator(AffineTransform at,
                                    double flatness)
Returns an iterator object that iterates along the boundary of the Shape and provides access to the geometry of the outline of the Shape. Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator. Since Stars are already flat, the flatness parameter is ignored. An optional AffineTransform can be specified in which case the coordinates returned in the iteration are transformed accordingly.

Specified by:
getPathIterator in interface Shape
Parameters:
at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or null if untransformed coordinates are desired
flatness - the maximum amount that the control points for a given curve can vary from colinear before a subdivided curve is replaced by a straight line connecting the endpoints. Since Stars are already flat the flatness parameter is ignored.
Returns:
a PathIterator object that provides access to the Shape object's geometry.


Copyright © 2002-2011 SoftSmithy. All Rights Reserved.