|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectballwar.model.paint.SquarePaintStrategy
public class SquarePaintStrategy
Paint strategy that paints a filled square with the Ball's radius. This functionality is duplicated by the RectanglePaintStrategy. The class demonstrates a direct implementation of IPaintStrategy.
| Field Summary | |
|---|---|
private AffineTransform |
at
The AffineTransformed used for internal calculations. |
private Rectangle |
rect
Unit sized rectangle used as a prototype |
| Fields inherited from interface ballwar.model.IPaintStrategy |
|---|
NullObject |
| Constructor Summary | |
|---|---|
SquarePaintStrategy()
No parameter constructor that creates a square with sides of 2 pixels (1 pixel radius) located at the origin. |
|
SquarePaintStrategy(AffineTransform at,
int side,
Point loc)
Constructor that allows one to create the prototype square of arbitrary side and location. |
|
| Method Summary | |
|---|---|
void |
init(Ball context)
By default, do nothing for initialization. |
void |
paint(Graphics g,
Ball host)
Paints on the given graphics context using the color, scale and direction provided by the host. |
void |
paintXfrm(Graphics g,
Ball host,
AffineTransform at)
Paints a transformed square, as per the given AffineTransform Uses color already set in Graphics context |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private AffineTransform at
private Rectangle rect
| Constructor Detail |
|---|
public SquarePaintStrategy()
public SquarePaintStrategy(AffineTransform at,
int side,
Point loc)
at - The AffineTransform to use for internal calculationsside - The half-width (x-radius) of the squareloc - The location of the center of the square.| Method Detail |
|---|
public void paint(Graphics g,
Ball host)
paint in interface IPaintStrategyg - The graphics context to draw upon.host - The host ball.
public void paintXfrm(Graphics g,
Ball host,
AffineTransform at)
paintXfrm in interface IPaintStrategyg - The Graphics context to paint onhost - The Ball hostat - the AffineTransform to usepublic void init(Ball context)
init in interface IPaintStrategy
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||