com.mucommander.ui.icon
Class SpinningDial

java.lang.Object
  extended by com.mucommander.ui.icon.AnimatedIcon
      extended by com.mucommander.ui.icon.SpinningDial
All Implemented Interfaces:
javax.swing.Icon

public class SpinningDial
extends AnimatedIcon

Animated icon of a spinning dial used to notify users that an application is performing a task.

This behaves as any animated icon except for one thing: when the animation is stopped using setAnimated(boolean), the dial won't be displayed anymore until the animation is resumed.

This heavily borrows code from Technomage's furbelow package, distributed under the GNU Lesser General Public License.
The original source code can be found here.

Author:
twall, Nicolas Rinaudo

Field Summary
static boolean DEFAULT_ANIMATE
          Default creation animation status.
static java.awt.Color DEFAULT_COLOR
          Dial's default color.
static int DEFAULT_SIZE
          Icon's default width and height.
static int DEFAULT_SPOKES
          Default number of spokes in the dial.
 
Fields inherited from class com.mucommander.ui.icon.AnimatedIcon
DEFAULT_FRAME_COUNT, DEFAULT_FRAME_DELAY
 
Constructor Summary
SpinningDial()
          Creates a new spinning dial.
SpinningDial(boolean animate)
          Creates a new spinning dial.
SpinningDial(java.awt.Color c)
          Creates a new spinning dial with the specified color.
SpinningDial(java.awt.Color c, boolean animate)
          Creates a new spinning dial with the specified color.
SpinningDial(int w, int h)
          Creates a new spinning dial with the specified dimensions.
SpinningDial(int w, int h, boolean animate)
          Creates a new spinning dial with the specified dimensions.
SpinningDial(int w, int h, java.awt.Color c)
          Creates a new spinning dial with the specified dimensions and color.
SpinningDial(int w, int h, java.awt.Color c, boolean animate)
          Creates a new spinning dial with the specified dimensions and color.
SpinningDial(int w, int h, int spokes)
          Creates a new spinning dial with the specified dimensions and number of spokes.
SpinningDial(int w, int h, int spokes, boolean animate)
          Creates a new spinning dial with the specified dimensions and number of spokes.
SpinningDial(int w, int h, int spokes, java.awt.Color c)
          Creates a new spinning dial with the specified characteristics.
SpinningDial(int w, int h, int spokes, java.awt.Color c, boolean animate)
          Creates a new spinning dial with the specified characteristics.
 
Method Summary
 java.awt.Color getColor()
          Returns the color used to paint the dial.
 int getIconHeight()
          Returns the icon's height.
 int getIconWidth()
          Returns the icon's width.
protected  java.awt.Color getSpokeColor(int alpha)
          Computes the dial color according to the specified alpha-transparency value.
 float getStrokeWidth()
          Returns the width of the strokes used to paint each of the dial's spokes.
 void paintFrame(java.awt.Component c, java.awt.Graphics graphics, int x, int y)
          Paints the current frame on the specified component.
 void setAnimated(boolean a)
          Starts / stops the spinning dial.
 void setColor(java.awt.Color c)
          Sets the color used to draw the dial.
 void setStrokeWidth(float width)
          Sets the width of the strokes used to paint each of the dial's spokes.
 
Methods inherited from class com.mucommander.ui.icon.AnimatedIcon
finalize, getFrame, getFrameCount, getFrameDelay, isAnimated, nextFrame, paintIcon, repaint, setFrame, setFrameCount, setFrameDelay
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ANIMATE

public static final boolean DEFAULT_ANIMATE
Default creation animation status.

See Also:
Constant Field Values

DEFAULT_COLOR

public static final java.awt.Color DEFAULT_COLOR
Dial's default color.


DEFAULT_SIZE

public static final int DEFAULT_SIZE
Icon's default width and height.

See Also:
Constant Field Values

DEFAULT_SPOKES

public static final int DEFAULT_SPOKES
Default number of spokes in the dial.

See Also:
Constant Field Values
Constructor Detail

SpinningDial

public SpinningDial()
Creates a new spinning dial.

The new instance will be initialised using default values:

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.


SpinningDial

public SpinningDial(boolean animate)
Creates a new spinning dial.

The new instance will be initialised using default values:

Parameters:
animate - whether to animate the dial immediately or not.

SpinningDial

public SpinningDial(java.awt.Color c)
Creates a new spinning dial with the specified color.

The new instance will be initialised using default values:

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.

Parameters:
c - color in which to paint the dial.

SpinningDial

public SpinningDial(java.awt.Color c,
                    boolean animate)
Creates a new spinning dial with the specified color.

The new instance will be initialised using default values:

Parameters:
c - color in which to paint the dial.
animate - whether to animate the dial immediately or not.

SpinningDial

public SpinningDial(int w,
                    int h)
Creates a new spinning dial with the specified dimensions.

The new instance will be initialised using default values:

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.

Parameters:
w - width of the icon.
h - height of the icon.

SpinningDial

public SpinningDial(int w,
                    int h,
                    boolean animate)
Creates a new spinning dial with the specified dimensions.

The new instance will be initialised using default values:

Parameters:
w - width of the icon.
h - height of the icon.
animate - whether to animate the dial immediately or not.

SpinningDial

public SpinningDial(int w,
                    int h,
                    java.awt.Color c)
Creates a new spinning dial with the specified dimensions and color.

The new instance will use DEFAULT_SPOKES for its number of spokes.

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.

Parameters:
w - width of the icon.
h - height of the icon.
c - color in which to paint the dial.

SpinningDial

public SpinningDial(int w,
                    int h,
                    java.awt.Color c,
                    boolean animate)
Creates a new spinning dial with the specified dimensions and color.

The new instance will use DEFAULT_SPOKES for its number of spokes.

Parameters:
w - width of the icon.
h - height of the icon.
c - color in which to paint the dial.
animate - whether to animate the dial immediately or not.

SpinningDial

public SpinningDial(int w,
                    int h,
                    int spokes)
Creates a new spinning dial with the specified dimensions and number of spokes.

The new instance will use DEFAULT_COLOR for its color.

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.

Parameters:
w - width of the icon.
h - height of the icon.
spokes - number of spokes that compose the dial.

SpinningDial

public SpinningDial(int w,
                    int h,
                    int spokes,
                    boolean animate)
Creates a new spinning dial with the specified dimensions and number of spokes.

The new instance will use DEFAULT_COLOR for its color.

Parameters:
w - width of the icon.
h - height of the icon.
spokes - number of spokes that compose the dial.
animate - whether to animate the dial immediately or not.

SpinningDial

public SpinningDial(int w,
                    int h,
                    int spokes,
                    java.awt.Color c)
Creates a new spinning dial with the specified characteristics.

A dial created that way will not be displayed until setAnimated(boolean) is called to animate it.

Parameters:
w - width of the icon.
h - height of the icon.
spokes - number of spokes that compose the dial.
c - color in which to paint the dial.

SpinningDial

public SpinningDial(int w,
                    int h,
                    int spokes,
                    java.awt.Color c,
                    boolean animate)
Creates a new spinning dial with the specified characteristics.

Parameters:
w - width of the icon.
h - height of the icon.
spokes - number of spokes that compose the dial.
c - color in which to paint the dial.
animate - whether to animate the dial immediately or not.
Method Detail

setStrokeWidth

public void setStrokeWidth(float width)
Sets the width of the strokes used to paint each of the dial's spokes.

Parameters:
width - width of the strokes used to paint each of the dial's spokes.

getStrokeWidth

public float getStrokeWidth()
Returns the width of the strokes used to paint each of the dial's spokes.

Returns:
the width of the strokes used to paint each of the dial's spokes.

setColor

public void setColor(java.awt.Color c)
Sets the color used to draw the dial.

Parameters:
c - color in which to paint the dial.

getColor

public java.awt.Color getColor()
Returns the color used to paint the dial.

Returns:
the color used to paint the dial.

getSpokeColor

protected java.awt.Color getSpokeColor(int alpha)
Computes the dial color according to the specified alpha-transparency value.

Parameters:
alpha - transparency value that must be applied to the dial's color.

getIconHeight

public int getIconHeight()
Returns the icon's height.

Specified by:
getIconHeight in interface javax.swing.Icon
Specified by:
getIconHeight in class AnimatedIcon
Returns:
the icon's height.

getIconWidth

public int getIconWidth()
Returns the icon's width.

Specified by:
getIconWidth in interface javax.swing.Icon
Specified by:
getIconWidth in class AnimatedIcon
Returns:
the icon's width.

paintFrame

public void paintFrame(java.awt.Component c,
                       java.awt.Graphics graphics,
                       int x,
                       int y)
Paints the current frame on the specified component.

Specified by:
paintFrame in class AnimatedIcon
Parameters:
c - component on which to paint the dial.
graphics - graphic context to use when painting the dial.
x - horizontal coordinate at which to paint the dial.
y - vertical coordinate at which to paint the dial.

setAnimated

public void setAnimated(boolean a)
Starts / stops the spinning dial.

If a is false, the animation will stop and the the dial won't be displayed anymore until the animationr resumes.

Overrides:
setAnimated in class AnimatedIcon
Parameters:
a - whether to start or stop the animation.


This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard