|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectballwar.model.paint.shape.PolygonFactory
public class PolygonFactory
Concrete IShapeFactory that provides the invariant behavior to instantiate a Shape that is a Polygon. This class can be instantiated and used simply by supplying the desired points in its constructor, or sub-classed an the constructor overridden. Note that this class cannot be used directly by the BallWar system because it does not have a no-parameter constructor.
Field Summary | |
---|---|
private AffineTransform |
at
The AffineTransform used for internal calculations |
private Polygon |
poly
The Polygon shape to use as the prototype. |
private double |
scaleFactor
Scale factor that scales the integer Point-defined Polygon to a unit size, which requires doubles. |
Constructor Summary | |
---|---|
PolygonFactory(AffineTransform at,
double scaleFactor,
Point... pts)
Constructor that uses an externally defined AffineTransform for internal use plus takes the defining points of the prototype Polygon and a scale factor to scale the given points to the desired unit size. |
Method Summary | |
---|---|
Shape |
makeShape(double x,
double y,
double xScale,
double yScale)
Instantiates a Shape object that is the prototype Polygon translated by the given (x, y) point and scaled by given (xScale, yScale) factor times the internal scaleFactor. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Polygon poly
private AffineTransform at
private double scaleFactor
Constructor Detail |
---|
public PolygonFactory(AffineTransform at, double scaleFactor, Point... pts)
at
- The AffineTransform to use.scaleFactor
- The ratio of the desired unit size to the defined size of the prototype Polygon.pts
- Vararg parameters that are the Points that define the Polygon around the origin as its center.Method Detail |
---|
public Shape makeShape(double x, double y, double xScale, double yScale)
makeShape
in interface IShapeFactory
x
- x-coordinate of the center of the resultant Polygony
- y-coordinate of the center of the resultant PolygonxScale
- The x-dimension of the polygon, usually the x-radius.yScale
- The y-dimension of the polygon, usually the y-radius.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |