|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecttipgame.Sprite
tipgame.sprite.ImageSprite
public class ImageSprite
| Field Summary | |
|---|---|
private java.awt.Image |
buffered
the image in its scaled size |
private double |
bufferedScale
the size of the currently scaled image |
private java.awt.Dimension |
bufferSize
the dimensions fo the transformed image |
private boolean |
flipHorizontal
true indicates the image should be flipped along the horizontal axis, false is the default |
private boolean |
flipVertical
true indicates the image should be flipped along the vertical axis, false is the default |
private java.awt.Image |
image
the image in its original size |
(package private) static java.util.HashMap<java.net.URL,java.awt.Image> |
imageCache
images are big and expensive, cache them if you can. |
(package private) static java.util.HashMap<java.lang.String,java.awt.Image> |
resizedCache
every time an image is resized, the image is stored so that future uses of images of this size need not be resized again. |
(package private) static java.util.HashMap<java.awt.Image,java.net.URL> |
reverseMap
this is used to enable removal from the cache given the Image |
| Fields inherited from class tipgame.Sprite |
|---|
color, tracker |
| Constructor Summary | |
|---|---|
ImageSprite(java.net.URL filename,
boolean keepAspect)
Creates a Sprite from an image file. |
|
| Method Summary | |
|---|---|
private void |
drawReliably(java.awt.Graphics2D brush,
java.awt.Image image,
double x,
double y)
if an image is not ready to be drawn, the drawImage method of graphics returns immediately false. |
void |
flipAlongHorizontalAxis()
flips the image along the horizontal axis before drawing it |
void |
flipAlongVerticalAxis()
flips the image along the vertical axis before drawing it |
double |
getRotation()
gets the rotation |
private void |
initializeImage(java.net.URL filename)
gets the image from cache if possible, from file otherwise |
void |
paint(java.awt.Graphics2D brush)
draws the image |
void |
setRotation(double angle)
sets the rotation |
private void |
updateBufferedImage()
get the image from cache if possible, otherwise, resize and cache the scaled image |
| Methods inherited from class tipgame.Sprite |
|---|
getBounds2D, getColor, getLocation, getNormalVector, getScale, getShape, getTracker, getUseBoundingBox, intersects, isDestroyed, isEnabled, isVisible, kill, normalize, paintInternal, rotate, scale, setColor, setEnabled, setLocation, setLocation, setScale, setShape, setTracker, setUseBoundingBox, setVisible, translate, update, updateInternal |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private java.awt.Image image
private java.awt.Image buffered
private double bufferedScale
private java.awt.Dimension bufferSize
private boolean flipVertical
private boolean flipHorizontal
static java.util.HashMap<java.net.URL,java.awt.Image> imageCache
static java.util.HashMap<java.awt.Image,java.net.URL> reverseMap
static java.util.HashMap<java.lang.String,java.awt.Image> resizedCache
| Constructor Detail |
|---|
public ImageSprite(java.net.URL filename,
boolean keepAspect)
| Method Detail |
|---|
private void initializeImage(java.net.URL filename)
filename - the image filepublic void flipAlongVerticalAxis()
flipAlongVerticalAxis in class Spritepublic void flipAlongHorizontalAxis()
flipAlongHorizontalAxis in class Spriteprivate void updateBufferedImage()
public void setRotation(double angle)
setRotation in class Spriteangle - the rotation in radiansSprite.setRotation(double)public double getRotation()
getRotation in class SpriteSprite.getRotation()public void paint(java.awt.Graphics2D brush)
paint in class Spritebrush - the Graphics used to draw the shape
private void drawReliably(java.awt.Graphics2D brush,
java.awt.Image image,
double x,
double y)
brush - the Graphics2D used to draw the imageimage - the image to be drawnx - the horizontal position to drawy - the vertical position to draw
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||