public class ImagePaintStrategy extends APaintStrategy
Modifier and Type | Field and Description |
---|---|
private double |
fillFactor
The percentage of the average of the width and height of the image that
defines a unit radius for the image.
|
private java.awt.Image |
image
The image to paint
|
private java.awt.image.ImageObserver |
imageObs
ImageObserver needed for some image operations
|
protected java.awt.geom.AffineTransform |
localAT
A local affine transform used to transform the image into its unit size
and location.
|
private double |
scaleFactor
Ratio of the unit radius circle to the effective radius size of the image.
|
protected java.awt.geom.AffineTransform |
tempAT |
NullObject
Constructor and Description |
---|
ImagePaintStrategy(java.awt.geom.AffineTransform at,
java.lang.String filename,
double fillFactor)
Constructor that takes an external AffineTransform, the filename of the
image to paint and a fill factor of the image.
|
ImagePaintStrategy(java.lang.String filename,
double fillFactor)
Constructor that takes the image filename and fill factor.
|
Modifier and Type | Method and Description |
---|---|
void |
init(Ball host)
Initializes the internal ImageObserver reference from the host Ball Also
calculates the net scale factor for the image.
|
void |
paintXfrm(java.awt.Graphics g,
Ball host,
java.awt.geom.AffineTransform at)
Draws the image on the given Graphics context using the given affine
transform in combination with the local affine transform.
|
getAT, paint, paintCfg
private java.awt.image.ImageObserver imageObs
private java.awt.Image image
private double scaleFactor
private double fillFactor
protected java.awt.geom.AffineTransform localAT
protected java.awt.geom.AffineTransform tempAT
public ImagePaintStrategy(java.lang.String filename, double fillFactor)
filename
- The filename of the image file to use.fillFactor
- The ratio of the desired average radius of the image to the
actual average of the image's width and height.public ImagePaintStrategy(java.awt.geom.AffineTransform at, java.lang.String filename, double fillFactor)
at
- The AffineTransform to use internally.filename
- The filename of the image file to use.fillFactor
- The ratio of the desired average diameter of the image to the
actual average of the image's width and height.public void paintXfrm(java.awt.Graphics g, Ball host, java.awt.geom.AffineTransform at)
paintXfrm
in class APaintStrategy
g
- The graphics context to paint onhost
- The host Ballat
- The AffineTransform to use.public void init(Ball host)
init
in interface IPaintStrategy
init
in class APaintStrategy
host
- The host Ball