ks.client.gamefactory.skin
Class BouncingBalls

java.lang.Object
  |
  +--ks.client.gamefactory.skin.BouncingBalls
All Implemented Interfaces:
java.lang.Runnable

public class BouncingBalls
extends java.lang.Object
implements java.lang.Runnable

Class for presenting a ball bouncing around, and off the various widgets, using the same background color.

While an object is being dragged by the container, no bouncing will occur


Field Summary
protected  java.util.Vector balls
          Balls in motion.
protected  Container container
          Container over which we are operating; we need to have dragging.
protected  java.awt.Rectangle containerBounds
          Bounds for container -- used to detect off the screen movement.
protected  int delay
          Delay between bounces.
protected  java.awt.Graphics myGraphics
          Graphics context in which to draw.
protected  boolean onePerChild
          Should there just be a single ball, or one per RectangleHierarchy child?
protected  int radius
          size of ball radius.
protected  java.lang.Thread thread
          The thread to oversee the scrolling.
protected  boolean visible
          Assume we are originally visible.
 
Constructor Summary
BouncingBalls(Container container)
          ImageScroller constructor with a single Bouncing Ball.
BouncingBalls(Container container, boolean onePerChild)
          ImageScroller constructor.
 
Method Summary
 int getDelay()
          Return delay between image scrolling.
 int getRadius()
          Return size of Ball.
 boolean isVisible()
          Determine whether image is visible.
 void offsetBallPosition()
          For each ball in play, update its new position.
protected  int randomOffset(int width)
          Returns a number from (-width/2) ..
 void run()
          Thread will operate by pausing n milliseconds and then checking if container is in a drag.
 void setDelay(int newDelay)
          Set the time delay between image scrolling.
 void setRadius(int newRadius)
          Set size of ball.
 void setVisible(boolean newVisible)
          Setting to invisible will cause this thread to stop.
 void visit(RectangleHierarchy node)
          Copy the appropriate image onto Graphics g at (x,y,width,height) taking into account the scrolling image.
 void visit(RectangleHierarchy node, java.awt.Rectangle clip)
          Copy the appropriate image onto Graphics g at (x,y,width,height) taking into account the scrolling image.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

balls

protected java.util.Vector balls
Balls in motion.


delay

protected int delay
Delay between bounces.


onePerChild

protected boolean onePerChild
Should there just be a single ball, or one per RectangleHierarchy child?


myGraphics

protected java.awt.Graphics myGraphics
Graphics context in which to draw.


container

protected Container container
Container over which we are operating; we need to have dragging.


containerBounds

protected java.awt.Rectangle containerBounds
Bounds for container -- used to detect off the screen movement.


radius

protected int radius
size of ball radius.


thread

protected java.lang.Thread thread
The thread to oversee the scrolling.


visible

protected boolean visible
Assume we are originally visible.

Constructor Detail

BouncingBalls

public BouncingBalls(Container container)
ImageScroller constructor with a single Bouncing Ball.


BouncingBalls

public BouncingBalls(Container container,
                     boolean onePerChild)
ImageScroller constructor.

Method Detail

getDelay

public int getDelay()
Return delay between image scrolling.

Returns:
int

getRadius

public int getRadius()
Return size of Ball. Creation date: (1/5/02 12:17:41 AM)

Returns:
int

isVisible

public boolean isVisible()
Determine whether image is visible.

Returns:
boolean

offsetBallPosition

public void offsetBallPosition()
For each ball in play, update its new position.


randomOffset

protected int randomOffset(int width)
Returns a number from (-width/2) .. 0 .. (width/2)


run

public void run()
Thread will operate by pausing n milliseconds and then checking if container is in a drag. Once it is verified that we can scroll, we do so, and the entire container background is redrawn.

Specified by:
run in interface java.lang.Runnable

setDelay

public void setDelay(int newDelay)
Set the time delay between image scrolling.

Parameters:
newDelay - int

setRadius

public void setRadius(int newRadius)
Set size of ball. Creation date: (1/5/02 12:17:41 AM)

Parameters:
newRadius - int

setVisible

public void setVisible(boolean newVisible)
Setting to invisible will cause this thread to stop.

Parameters:
newVisible - boolean

visit

public void visit(RectangleHierarchy node)
Copy the appropriate image onto Graphics g at (x,y,width,height) taking into account the scrolling image.


visit

public void visit(RectangleHierarchy node,
                  java.awt.Rectangle clip)
Copy the appropriate image onto Graphics g at (x,y,width,height) taking into account the scrolling image.

Note: only Leaf nodes are drawn.

Clip to the given Rectangle clip area. [clip is unaffected by this invocation.]