|
|
|
Class Fader
Download It
class Fader extends java.awt.Canvas
{
// Constructors
public Fader( );
public Fader( Color bgColor , Color fgColor , int diff , int rest );
// Methods
public void setBackground( Color bgColor );
public void setForeground( Color fgColor );
public void setFont( Font font );
public int setPause( int rest );
public int Reset( );
public boolean getFadeCompleted( );
public int Fade( );
public void FadeIn( );
public Color getFadeColor( );
public void drawFade( Graphics g , int W , int H , String m );
}
The Fader class can be used to handle the fundamentals of text
fading. The class can do the actual drawing to the canvas if you choose,
but it does not support double buffering. You can implement the drawing
to the canvas yourself by using the getFadeColor( ) results, which
will tell you what the current color of the fading message should be.
Constructors
Fader
public Fader( );
This is the default constructor for the Fader class.
The Background color will be set to black.
The Foreground color will be set to white.
The current FadeColor will be set to the Background color.
The diff value will be set to 5.
The rest value will be set to 10.
Fader
public Fader( Color bgColor , Color fgColor , int diff , int rest );
This is the user-defined constructor for the Fader class.
Parameters:
bgColor - the Color for the background of the canvas
fgColor - the Color for the Fade to complete at
diff - the number of steps to move the current FadeColor value
along the 255 color values of each R, G, B pair.
rest - the number of timer threads to wait between each color shift
Methods
setBackground
public void setBackground( Color bgColor );
This is used to set the background color of the canvas
Parameters:
bgColor - the background color of the canvas
setForeground
public void setForeground( Color fgColor );
This is used to set the color the fading message will climax at
Parameters:
fgColor - the ending fade color
setFont
public void setFont( Font font );
This is used to set the Font for the message
Parameters:
font - a Font object
setPause
public void setPause( int rest );
This is used to set the number of timer threads to pause between each color shift
Parameters:
rest - an integer representing the delay between color shifts
Reset
public void Reset( );
This will reset the state of the Fader to not completed
getFadeCompleted
public boolean getFadeCompleted( )
This method will return the current state of the Fader , completed or not completed
Fade
public int Fade( );
This method will update the current FadeColor, and return a value representing
the number of timer threads to pause between color shifts. The number of fades will be
the value of rest during fade shits, 10 * rest at the climax of the fade,
and 5 * rest at the completion of the fade
Returns:
The number of timer threads to pause
FadeIn
public void FadeIn( );
This method will update the current fade color as above, but it will
only fade into the fgColor then stop.
getFadeColor
public FadeColor( );
This method will return the current color value of the fade
which is in progress.
Returns:
A color object representing the current color of the fading message
drawFade
public void drawFade( Graphics g , int W , int H , String m );
This method will draw the fading text to the canvas of the
applet or application. It does not support double-buffering.
If you want to implement double-buffering you must use the return
values of getFadeCompleted( ) and getFadeColor( ).
Parameters:
g - the applet or applications Graphics object
W - the width of the applet/canvas
H - the height of the applet/canvas
m - the message to fade
Fader.class
by James Savidge
e-mail: savidge@scsud.ctstateu.edu
7-14-97
|