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.
-
Flyer(int, int)
- Constructor for a Flyer of width x and height y.
-
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.
-
add(Component)
- Method to add a component to the Flyer.
-
componentHidden(ComponentEvent)
-
-
componentMoved(ComponentEvent)
-
-
componentResized(ComponentEvent)
-
-
componentShown(ComponentEvent)
-
-
getFrameRate()
- Gets the current frame rate (in frames/second).
-
getMinimumSize()
- Gets the current size of the Flyer
-
getPosition()
-
Gets the current position of the contents of the Flyer.
-
getPreferredSize()
- Gets the current size of the Flyer
-
getSpeedX()
- Gets the current horizontal speed (in pixels/second).
-
getSpeedY()
- Gets the current vertical speed (in pixels/second).
-
isBouncingX()
- Returns the state of the horizontal bounce.
-
isBouncingY()
- Returns the state of the vertical bounce.
-
isRunning()
- Queries the Flyer to determine if it is currently animating.
-
isRunningOffScreenX()
- Returns the state of the horizontal run off screen
-
isRunningOffScreenY()
- Returns the state of the vertical run off screen
-
main(String[])
- A test program for Flyer
-
removeNotify()
-
-
run()
- Use the start() method to begin or resume the animation of a Flyer.
-
setBounce(boolean, boolean)
-
Sets the vertical and horizontal bounce.
-
setBounceX(boolean)
-
Sets the horizontal bounce only.
-
setBounceY(boolean)
- Sets the vertical bounce only.
-
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.
-
setPosition(int, int)
-
Sets the current position of the contents of the Flyer.
-
setPosition(Point)
-
Sets the current position of the contents of the Flyer, using the provided coordinates.
-
setPreferredSize(Dimension)
- Sets the preferred size of the Flyer
-
setPreferredSize(int, int)
- Sets the preferred size of the Flyer
-
setRunOffScreen(boolean, boolean)
-
Sets the horizontal and vertical run off screen behavior.
-
setRunOffScreenX(boolean)
- Sets the horizontal run off only.
-
setRunOffScreenY(boolean)
- Sets the vertical run off only.
-
setSpeed(double, double, double)
-
Sets the speed and frame rate of the Flyer.
-
start()
-
This is the method to use to start (or resume) the animation of a Flyer.
-
stop()
-
This method will stop the animation of a Flyer.
-
update(Graphics)
-
-
zeroComponent()
- sets the location of the contents to (0,0)
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.
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.
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
setPreferredSize
public void setPreferredSize(Dimension d)
- Sets the preferred size of the Flyer
setPreferredSize
public void setPreferredSize(int x,
int y)
- Sets the preferred size of the Flyer
getPreferredSize
public Dimension getPreferredSize()
- Gets the current size of the Flyer
- Overrides:
- getPreferredSize in class Container
getMinimumSize
public Dimension getMinimumSize()
- Gets the current size of the Flyer
- Overrides:
- getMinimumSize in class Container
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.
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.
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
setBounceX
public void setBounceX(boolean bounceX)
- Sets the horizontal bounce only.
- See Also:
- setBounce
setBounceY
public void setBounceY(boolean bounceY)
- Sets the vertical bounce only.
- See Also:
- setBounce
setRunOffScreenX
public void setRunOffScreenX(boolean offX)
- Sets the horizontal run off only.
- See Also:
- setRunOffScreen
setRunOffScreenY
public void setRunOffScreenY(boolean offY)
- Sets the vertical run off only.
- See Also:
- setRunOffScreen
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?
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?
getPosition
public Point getPosition()
- Gets the current position of the contents of the Flyer.
- Returns:
- returns a Point object.
getSpeedX
public double getSpeedX()
- Gets the current horizontal speed (in pixels/second).
getSpeedY
public double getSpeedY()
- Gets the current vertical speed (in pixels/second).
getFrameRate
public double getFrameRate()
- Gets the current frame rate (in frames/second).
isBouncingX
public boolean isBouncingX()
- Returns the state of the horizontal bounce.
- See Also:
- setBounce
isBouncingY
public boolean isBouncingY()
- Returns the state of the vertical bounce.
- See Also:
- setBounce
isRunningOffScreenX
public boolean isRunningOffScreenX()
- Returns the state of the horizontal run off screen
- See Also:
- setRunOffScreen
isRunningOffScreenY
public boolean isRunningOffScreenY()
- Returns the state of the vertical run off screen
- See Also:
- setRunOffScreen
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.
componentHidden
public void componentHidden(ComponentEvent e)
componentMoved
public void componentMoved(ComponentEvent e)
componentShown
public void componentShown(ComponentEvent e)
componentResized
public void componentResized(ComponentEvent e)
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
zeroComponent
public void zeroComponent()
- sets the location of the contents to (0,0)
run
public void run()
- Use the start() method to begin or resume the animation of a Flyer.
update
public void update(Graphics g)
- Overrides:
- update in class Container
start
public synchronized void start()
- This is the method to use to start (or resume) the animation of a Flyer.
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.
removeNotify
public void removeNotify()
- Overrides:
- removeNotify in class Container
main
public static void main(String args[])
- A test program for Flyer
All Packages Class Hierarchy This Package Previous Next Index