|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjview.BlinkingImage
public class BlinkingImage
A blinking image is used to allow blinking of icons or other images. This class can work also on parts of a graphics object, so it is possible to differently animate compunds of the entire component.
This class expects two images, the on and off image in its constructor,
along with the swing component within which this image animation
should be drwan. If the user wants to specify a different location than
(0,0) for the image to be displayed, call the method
setUpperLeftCorner(java.awt.Point) prior to starting the blinker with
startBlink(). Because this implementation uses a swing timer
to perform the blinking, the time intervall between the on and off
state are equal.
| Nested Class Summary | |
|---|---|
static class |
BlinkingImage.Test
For testing. |
| Field Summary | |
|---|---|
private boolean |
afteroff
If true we draw the off image after animation, otherwise on. |
private static int |
count
The current invocation number in the action performed method. |
private boolean |
current
True if the on image should be isplayed. |
private static int |
DEFBLINK
The default blinking time, in ms. |
private boolean |
draw
A boolean determining whether the blinker is drawing. |
private static Timer |
flash
The timer used to produce action events for the blinking. |
private int |
frequency
The number of action events to drop for the next frame. |
private BufferedImage |
off
The off-image. |
private Point |
offset
The offset where to draw the blinking image. |
private BufferedImage |
on
The on-image. |
private Component |
pane
The component where to get the graphics object from. |
private boolean |
prioron
If true we draw the on image prior to animation start, otherwise off. |
private Dimension |
size
The dimension of the images. |
| Constructor Summary | |
|---|---|
BlinkingImage(Image high,
Image low,
Component observer)
Creates a new blinking image instance. |
|
BlinkingImage(Image high,
Image low,
int delay,
Component observer)
Creates a new blinking image instance. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(ActionEvent ae)
Does the blinking. |
WritableRaster |
copyData(WritableRaster raster)
|
private static Timer |
createTimer()
For all blinking images, we have a single timer. |
private BufferedImage |
getActualImage()
Returns the actual image. |
ColorModel |
getColorModel()
|
Raster |
getData()
|
Raster |
getData(Rectangle rect)
|
int |
getHeight()
|
int |
getMinTileX()
|
int |
getMinTileY()
|
int |
getMinX()
|
int |
getMinY()
|
int |
getNumXTiles()
|
int |
getNumYTiles()
|
Object |
getProperty(String name)
|
String[] |
getPropertyNames()
|
SampleModel |
getSampleModel()
|
Vector |
getSources()
|
Raster |
getTile(int tileX,
int tileY)
|
int |
getTileGridXOffset()
|
int |
getTileGridYOffset()
|
int |
getTileHeight()
|
int |
getTileWidth()
|
Point |
getUpperLeftCorner()
Returns the offset. |
int |
getWidth()
|
boolean |
isActive()
Queries this component whether it is drawing. |
void |
setBlinkIntervall(int delay)
Sets the blinking intervall. |
void |
setPriorAndAfterState(boolean onprior,
boolean offafter)
Determines which images are to displayed prior to the animation and after stopping it. |
void |
setUpperLeftCorner(Point ul)
Sets an offset where this blinking image should be displayed on the observer's graphics object. |
void |
startBlink()
Starts the blinking. |
void |
stopBlink()
Stops the blinking. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final int DEFBLINK
private BufferedImage on
private BufferedImage off
private boolean current
on image should be isplayed.
private static Timer flash
private static int count
private Component pane
private Point offset
private Dimension size
private boolean draw
private boolean prioron
private boolean afteroff
private int frequency
| Constructor Detail |
|---|
public BlinkingImage(Image high,
Image low,
Component observer)
startBlink() is explicedly called.
high - The image to display in the on state or prior to start.low - The image to display in the off state or after stop.observer - The component whose graphics is used to draw the image.time - The timer to allow synchronous blinking for multiple
blinking images.
public BlinkingImage(Image high,
Image low,
int delay,
Component observer)
startBlink() is explicedly called.
high - The image to display in the on state or prior to start.low - The image to display in the off state or after stop.observer - The component whose graphics is used to draw the image.delay - The target blinking delay. If not a straight multiple of
the timer's delay, round to closest multiple.time - The timer to allow synchronous blinking for multiple
blinking images.| Method Detail |
|---|
private static Timer createTimer()
public void setPriorAndAfterState(boolean onprior,
boolean offafter)
on image is displayed
before start and the off after stopping.
onprior - If false, use the off image before animationoffafter - If false, use the on image after animation.public void setUpperLeftCorner(Point ul)
public Point getUpperLeftCorner()
public void setBlinkIntervall(int delay)
public void startBlink()
public void stopBlink()
public boolean isActive()
public void actionPerformed(ActionEvent ae)
actionPerformed in interface ActionListenerpublic WritableRaster copyData(WritableRaster raster)
copyData in interface RenderedImagepublic ColorModel getColorModel()
getColorModel in interface RenderedImagepublic Raster getData()
getData in interface RenderedImagepublic Raster getData(Rectangle rect)
getData in interface RenderedImagepublic int getHeight()
getHeight in interface RenderedImagepublic int getMinTileX()
getMinTileX in interface RenderedImagepublic int getMinTileY()
getMinTileY in interface RenderedImagepublic int getMinX()
getMinX in interface RenderedImagepublic int getMinY()
getMinY in interface RenderedImagepublic int getNumXTiles()
getNumXTiles in interface RenderedImagepublic int getNumYTiles()
getNumYTiles in interface RenderedImagepublic Object getProperty(String name)
getProperty in interface RenderedImagepublic String[] getPropertyNames()
getPropertyNames in interface RenderedImagepublic SampleModel getSampleModel()
getSampleModel in interface RenderedImagepublic Vector getSources()
getSources in interface RenderedImage
public Raster getTile(int tileX,
int tileY)
getTile in interface RenderedImagepublic int getTileGridXOffset()
getTileGridXOffset in interface RenderedImagepublic int getTileGridYOffset()
getTileGridYOffset in interface RenderedImagepublic int getTileHeight()
getTileHeight in interface RenderedImagepublic int getTileWidth()
getTileWidth in interface RenderedImagepublic int getWidth()
getWidth in interface RenderedImageprivate BufferedImage getActualImage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||