All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class datarep.common.Flyer

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----datarep.common.Flyer

public class Flyer
extends Container
implements Runnable, ComponentListener
The Flyer class provides a very easy way to add animation to a Java application. A Flyer is a container whose contents move horizontally and/or vertically within it. The speed (in pixels/sec) can be set for the horizontal and vertical directions, as well as the frame rate and the size of the bounding rectangle.

The Flyer will not start animating until the start() method is called.

Version:
1.2
Author:
Data Representations, Inc.

Constructor Index

 o Flyer(int, int)
Constructor for a Flyer of width x and height y.
 o Flyer(int, int, int, int, int)
Constructor for a Flyer where the width x, height y, horizontal speed (in pixels/sec), vertical speed (in pixels/sec), and frames per second are all specified.

Method Index

 o add(Component)
Method to add a component to the Flyer.
 o componentHidden(ComponentEvent)
 o componentMoved(ComponentEvent)
 o componentResized(ComponentEvent)
 o componentShown(ComponentEvent)
 o getFrameRate()
Gets the current frame rate (in frames/second).
 o getMinimumSize()
Gets the current size of the Flyer
 o getPosition()
Gets the current position of the contents of the Flyer.
 o getPreferredSize()
Gets the current size of the Flyer
 o getSpeedX()
Gets the current horizontal speed (in pixels/second).
 o getSpeedY()
Gets the current vertical speed (in pixels/second).
 o isBouncingX()
Returns the state of the horizontal bounce.
 o isBouncingY()
Returns the state of the vertical bounce.
 o isRunning()
Queries the Flyer to determine if it is currently animating.
 o isRunningOffScreenX()
Returns the state of the horizontal run off screen
 o isRunningOffScreenY()
Returns the state of the vertical run off screen
 o main(String[])
A test program for Flyer
 o removeNotify()
 o run()
Use the start() method to begin or resume the animation of a Flyer.
 o setBounce(boolean, boolean)
Sets the vertical and horizontal bounce.
 o setBounceX(boolean)
Sets the horizontal bounce only.
 o setBounceY(boolean)
Sets the vertical bounce only.
 o setLayout(LayoutManager)
Since currently only one component is allowed inside a Flyer at a time, it is better to put a Panel with the desired layout inside the Flyer instead of using this method.
 o setPosition(int, int)
Sets the current position of the contents of the Flyer.
 o setPosition(Point)
Sets the current position of the contents of the Flyer, using the provided coordinates.
 o setPreferredSize(Dimension)
Sets the preferred size of the Flyer
 o setPreferredSize(int, int)
Sets the preferred size of the Flyer
 o setRunOffScreen(boolean, boolean)
Sets the horizontal and vertical run off screen behavior.
 o setRunOffScreenX(boolean)
Sets the horizontal run off only.
 o setRunOffScreenY(boolean)
Sets the vertical run off only.
 o setSpeed(double, double, double)
Sets the speed and frame rate of the Flyer.
 o start()
This is the method to use to start (or resume) the animation of a Flyer.
 o stop()
This method will stop the animation of a Flyer.
 o update(Graphics)
 o zeroComponent()
sets the location of the contents to (0,0)

Constructors

 o Flyer
 public Flyer(int x,
              int y)
Constructor for a Flyer of width x and height y. The initial horizontal speed is set to 10 pixels per second, and the vertical speed to 0 pixels per sec, with 10 frames per sec displayed.

 o Flyer
 public Flyer(int x,
              int y,
              int xps,
              int yps,
              int fps)
Constructor for a Flyer where the width x, height y, horizontal speed (in pixels/sec), vertical speed (in pixels/sec), and frames per second are all specified.

Methods

 o setLayout
 public void setLayout(LayoutManager layout)
Since currently only one component is allowed inside a Flyer at a time, it is better to put a Panel with the desired layout inside the Flyer instead of using this method.

Overrides:
setLayout in class Container
 o setPreferredSize
 public void setPreferredSize(Dimension d)
Sets the preferred size of the Flyer

 o setPreferredSize
 public void setPreferredSize(int x,
                              int y)
Sets the preferred size of the Flyer

 o getPreferredSize
 public Dimension getPreferredSize()
Gets the current size of the Flyer

Overrides:
getPreferredSize in class Container
 o getMinimumSize
 public Dimension getMinimumSize()
Gets the current size of the Flyer

Overrides:
getMinimumSize in class Container
 o setPosition
 public void setPosition(Point p)
Sets the current position of the contents of the Flyer, using the provided coordinates. (Of course, if the Flyer is animating, the contents will move!) If the position is too large or too small, the nearest valid position will be substituted.

 o setPosition
 public synchronized void setPosition(int x,
                                      int y)
Sets the current position of the contents of the Flyer. Y is the vertical coordinate, and X is the horizontal one. (Of course, if the Flyer is animating, the contents will move!) If the position is too large or too small, the nearest valid position will be substituted.

 o setSpeed
 public synchronized void setSpeed(double xps,
                                   double yps,
                                   double fps)
Sets the speed and frame rate of the Flyer. Note that the values sent here are 'double'.

Parameters:
xps - The horizontal speed in pixels/second
yps - The vertical speed in pixels/second
fps - The frame rate in frames/second
 o setBounceX
 public void setBounceX(boolean bounceX)
Sets the horizontal bounce only.

See Also:
setBounce
 o setBounceY
 public void setBounceY(boolean bounceY)
Sets the vertical bounce only.

See Also:
setBounce
 o setRunOffScreenX
 public void setRunOffScreenX(boolean offX)
Sets the horizontal run off only.

See Also:
setRunOffScreen
 o setRunOffScreenY
 public void setRunOffScreenY(boolean offY)
Sets the vertical run off only.

See Also:
setRunOffScreen
 o setBounce
 public synchronized void setBounce(boolean bounceX,
                                    boolean bounceY)
Sets the vertical and horizontal bounce. If the bounce is on, when the contents of the Flyer "hit" an edge, the contents will reverse direction and continue moving. If the bounce is off, the contents will reappear on the opposite edge, moving in the same direction as previously. Marquee text can be created by turning bounce off and letting objects run off the screen.
The default is for both horizontal and vertical bounce to be on.

Parameters:
bounceX - will the Flyer's contents display a horizontal bounce?
bounceY - will the Flyer's contents display a vertical bounce?
 o setRunOffScreen
 public synchronized void setRunOffScreen(boolean offX,
                                          boolean offY)
Sets the horizontal and vertical run off screen behavior.
If the run off is set to be true, then the contents of the Flyer are allowed to run off of the screen (the dimensions of the Flyer) during the animation. Marquee text can be created by turning bounce off and letting objects run off the screen.
The default is for both horizontal and vertical run off to be false (turned off).

Parameters:
offX - will the Flyer's contents run off the screen horizontally?
offY - will the Flyer's contents run off the screen vertically?
 o getPosition
 public Point getPosition()
Gets the current position of the contents of the Flyer.

Returns:
returns a Point object.
 o getSpeedX
 public double getSpeedX()
Gets the current horizontal speed (in pixels/second).

 o getSpeedY
 public double getSpeedY()
Gets the current vertical speed (in pixels/second).

 o getFrameRate
 public double getFrameRate()
Gets the current frame rate (in frames/second).

 o isBouncingX
 public boolean isBouncingX()
Returns the state of the horizontal bounce.

See Also:
setBounce
 o isBouncingY
 public boolean isBouncingY()
Returns the state of the vertical bounce.

See Also:
setBounce
 o isRunningOffScreenX
 public boolean isRunningOffScreenX()
Returns the state of the horizontal run off screen

See Also:
setRunOffScreen
 o isRunningOffScreenY
 public boolean isRunningOffScreenY()
Returns the state of the vertical run off screen

See Also:
setRunOffScreen
 o isRunning
 public boolean isRunning()
Queries the Flyer to determine if it is currently animating.

Returns:
returns a boolean; true if the Flyer is currently animating, otherwise false.
 o componentHidden
 public void componentHidden(ComponentEvent e)
 o componentMoved
 public void componentMoved(ComponentEvent e)
 o componentShown
 public void componentShown(ComponentEvent e)
 o componentResized
 public void componentResized(ComponentEvent e)
 o add
 public Component add(Component comp)
Method to add a component to the Flyer. The Flyer can only have one component in it at a time. If you wish to add more than one component, an easy way would be to add a Panel to the Flyer, and then add as many components as you like to the Panel.

Overrides:
add in class Container
 o zeroComponent
 public void zeroComponent()
sets the location of the contents to (0,0)

 o run
 public void run()
Use the start() method to begin or resume the animation of a Flyer.

 o update
 public void update(Graphics g)
Overrides:
update in class Container
 o start
 public synchronized void start()
This is the method to use to start (or resume) the animation of a Flyer.

 o stop
 public synchronized void stop()
This method will stop the animation of a Flyer. If the start() method is used subsequently, the animation will resume where it left off.

 o removeNotify
 public void removeNotify()
Overrides:
removeNotify in class Container
 o main
 public static void main(String args[])
A test program for Flyer


All Packages  Class Hierarchy  This Package  Previous  Next  Index