|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Image
jview.BlinkImage
public class BlinkImage
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 |
BlinkImage.Test
For testing. |
| Field Summary | |
|---|---|
private boolean |
afteroff
If true we draw the off image after animation, otherwise on. |
private 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 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 Image |
off
The off-image. |
private Point |
offset
The offset where to draw the blinking image. |
private Image |
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. |
| Fields inherited from class java.awt.Image |
|---|
accelerationPriority, SCALE_AREA_AVERAGING, SCALE_DEFAULT, SCALE_FAST, SCALE_REPLICATE, SCALE_SMOOTH, UndefinedProperty |
| Constructor Summary | |
|---|---|
BlinkImage(Image high,
Image low,
Component observer,
Timer time)
Creates a new blinking image instance. |
|
BlinkImage(Image high,
Image low,
int delay,
Component observer,
Timer time)
Creates a new blinking image instance. |
|
| Method Summary | |
|---|---|
void |
actionPerformed(ActionEvent ae)
Does the blinking. |
void |
flush()
|
private Image |
getActualImage()
Returns the actual image. |
Graphics |
getGraphics()
|
int |
getHeight(ImageObserver observer)
|
Object |
getProperty(String name,
ImageObserver observer)
|
Image |
getScaledInstance(int width,
int height,
int hints)
|
ImageProducer |
getSource()
|
Point |
getUpperLeftCorner()
Returns the offset. |
int |
getWidth(ImageObserver observer)
|
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.awt.Image |
|---|
getAccelerationPriority, getCapabilities, setAccelerationPriority |
| 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 Image on
private Image off
private boolean current
on image should be isplayed.
private Timer flash
private Component pane
private Point offset
private Dimension size
private boolean draw
private boolean prioron
private boolean afteroff
private int frequency
private int count
| Constructor Detail |
|---|
public BlinkImage(Image high,
Image low,
Component observer,
Timer time)
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 BlinkImage(Image high,
Image low,
int delay,
Component observer,
Timer time)
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 |
|---|
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 void flush()
flush in class Imagepublic Graphics getGraphics()
getGraphics in class Imagepublic int getHeight(ImageObserver observer)
getHeight in class Image
public Object getProperty(String name,
ImageObserver observer)
getProperty in class Image
public Image getScaledInstance(int width,
int height,
int hints)
getScaledInstance in class Imagepublic ImageProducer getSource()
getSource in class Imagepublic int getWidth(ImageObserver observer)
getWidth in class Imageprivate Image getActualImage()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||