|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.swing.ImageIcon de.fhg.igd.ui.AnimatedIcon
This icon uses animations to communicate its states. The states are enabled, disabled, looping, and oneshot.
Nested Class Summary |
Nested classes inherited from class javax.swing.ImageIcon |
ImageIcon.AccessibleImageIcon |
Field Summary | |
protected int[] |
anim_
The oneshot animation frame spec, given as a sequence of image numbers. |
protected int |
current_
The current frame's number. |
protected long |
delay_
The frame rate given as the number of millis between frame changes. |
private int |
height_
The cached width of the image. |
protected Image[] |
image_
The animation images. |
protected int |
off_
The number of the image that represents disabled state. |
protected int |
offset_
The direction in which the animation is looping, either backwards (-1) or forwards (1). |
protected int |
on_
The number of the image that represents enabled state. |
protected JComponent |
parent_
The parent component. |
protected Thread |
thread_
The thread that animates this icon. |
protected int |
toFrame_
The target frame number or -1 if looping. |
private int |
width_
The cached width of the image. |
Fields inherited from class javax.swing.ImageIcon |
component, tracker |
Constructor Summary | |
private |
AnimatedIcon()
Creates an uninitialized instance. |
|
AnimatedIcon(String name)
Creates an instance with the given animation. |
Method Summary | |
Object |
clone()
Returns a clone of this animation. |
protected int |
frameNumber(int inum)
Returns a frame number that displays the image with the given image number. |
long |
getDelay()
Returns the delay time of this icon. |
int |
getIconHeight()
Get the height of the Icon |
int |
getIconWidth()
Get the width of the Icon |
int |
getImageLoadStatus()
Returns COMPLETE . |
void |
init(String name)
Initializes the animation from resource data. |
protected void |
loadImage(Image image)
Load the given image. |
static void |
main(String[] argv)
Shows an animation. |
void |
run()
The main loop of the animator thread. |
void |
setEnabled(boolean enable)
Puts the icon into enabled or disabled state. |
void |
setLooping()
Puts the icon into looping state. |
void |
setOneShot()
Puts the icon into one shot state. |
void |
setParentComponent(JComponent component)
Sets the parent component. |
void |
start()
Starts the animation thread. |
boolean |
stepOne()
Steps once in the direction in which we are looping and displays the next frame. |
void |
stop()
|
Methods inherited from class javax.swing.ImageIcon |
getAccessibleContext, getDescription, getImage, getImageObserver, paintIcon, setDescription, setImage, setImageObserver, toString |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected int current_
protected int toFrame_
protected long delay_
protected int[] anim_
protected int off_
protected int on_
protected int offset_
protected Image[] image_
protected Thread thread_
private int width_
private int height_
protected JComponent parent_
Constructor Detail |
public AnimatedIcon(String name) throws InterruptedException, IOException
name
- The name of the image and animation file
resources.private AnimatedIcon()
Method Detail |
public Object clone()
public void setParentComponent(JComponent component)
component
- The parent component.public void run()
run
in interface Runnable
public void start()
public void stop()
public long getDelay()
public void setEnabled(boolean enable)
enable
- true
if this icon should go to
enabled state, and false
if it should go
to disabled state.public void setLooping()
public void setOneShot()
public boolean stepOne()
Called by the timer thread to display the next frame of the animation.
true
if the target image was reached.protected int frameNumber(int inum)
inum
- The image number of the target frame.
public void init(String name) throws IOException, InterruptedException
name
denotes the path to the resource images. Image
names must have the form:
<name><num>.<extension> where
<num> is the running number of the animation
frame, and <extension> is taken from the
animation definition file. Animation frame numbers must
start with zero.The animation sequence given as array of image numbers must be given as a string of space or comma separated numbers in a resource file with name <name>.anim; the first token must be the extension of the image frames, then the frame delay in milliseconds, then two numbers that define the off and on frames, followed by the complete animation sequence.
name
- The name prefix of the images.
IOException
- if guess what.
InterruptedException
- if the image loading
is interrupted.protected void loadImage(Image image)
image
- The image to load; this parameter is
ignored but for exception checking.
NullPointerException
- if image
is null
.public int getIconWidth()
getIconWidth
in interface Icon
public int getIconHeight()
getIconHeight
in interface Icon
public int getImageLoadStatus()
COMPLETE
.
public static void main(String[] argv)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |