|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.RegularShape
Class RegularShape provides factory methods
to create regular polygons and regular star shapes.
This class also provides the mathematical methods that return the vertex arrays in case the caller wishes to deal directly with this data.
This class cannot be instantiated.
| Constructor Summary | |
private |
RegularShape()
Prevent instantiation. |
| Method Summary | |
static PolygonShape |
polygon(double x,
double y,
double r,
int vertices)
Creates a regular polygon with center (x,y) and radius r with the initial vertex positioned vertically above the center and with the given number of vertices. |
static double[][] |
regularShapeData(double x,
double y,
double r,
int vertices,
int jump)
Returns the array of coordinate data for a regular polygon or regular star shape with center (x,y), radius r, and the given number of outer vertices and the given jump between outer vertices. |
static float[][] |
regularShapeDataFloat(double x,
double y,
double r,
int vertices,
int jump)
Returns the same coordinate information as the method regularShapeData except as an array of
float. |
static PolygonShape |
star(double x,
double y,
double r,
int vertices,
int jump)
Creates a regular star shape with center (x,y) and radius r with the initial vertex positioned vertically above the center and with the given number of outer vertices and the given jump. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
private RegularShape()
| Method Detail |
public static PolygonShape polygon(double x,
double y,
double r,
int vertices)
Creates a regular polygon with center (x,y) and radius r with the initial vertex positioned vertically above the center and with the given number of vertices.
x - the x-coordinate of the centery - the y-coordinate of the centerr - the radiusvertices - the number of polygon vertices
public static PolygonShape star(double x,
double y,
double r,
int vertices,
int jump)
Creates a regular star shape with center (x,y) and radius r with the initial vertex positioned vertically above the center and with the given number of outer vertices and the given jump.
Conceptually, the jump determines the distance between outer vertices that are "connected" by a line in the star. In particular, if jump is 1, then the shape reduces to a regular polygon .
In the actual shape construction, we do not in fact directly connect the outer vertices of a star. Instead, we compute a sequence of inner vertices positioned midway between the outer vertices and then build the star by connecting vertices in an alternating pattern: outer, inner, outer, inner, etc. This methodology makes the star a shape with no self-intersections.
x - the x-coordinate of the centery - the y-coordinate of the centerr - the radiusvertices - the number of outer star verticesjump - the jump between outer star vertices
public static double[][] regularShapeData(double x,
double y,
double r,
int vertices,
int jump)
Returns the array of coordinate data for a regular polygon or regular star shape with center (x,y), radius r, and the given number of outer vertices and the given jump between outer vertices.
Let V stand for the vertices
parameter. Then:
If jump==1, the array returned has shape
double[V][2].
If jump!=1, the array returned has shape
double[2*V][2] to account for both
the outer and the inner vertices of the star.
The vertices parameter should be at least
3 and the jump parameter should
be at least 1 and less than vertices.
Invalid parameters will be adjusted to the most reasonable
valid values.
x - the x-coordinate of the centery - the y-coordinate of the centerr - the radiusvertices - the number of outer star verticesjump - the jump between outer star vertices
public static float[][] regularShapeDataFloat(double x,
double y,
double r,
int vertices,
int jump)
Returns the same coordinate information as the method
regularShapeData except as an array of
float.
x - the x-coordinate of the centery - the y-coordinate of the centerr - the radiusvertices - the number of outer star verticesjump - the jump between outer star vertices
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||