Class Sequencer
- java.lang.Object
-
- java.lang.Thread
-
- org.htmlparser.lexerapplications.thumbelina.Sequencer
-
- All Implemented Interfaces:
java.lang.Runnable
public class Sequencer extends java.lang.ThreadDisplay received images at a constant rate.
-
-
Field Summary
Fields Modifier and Type Field Description protected static intDEFAULT_DELAYThe default delay time, 500 milliseconds.protected booleanmActiveActivity state.protected intmDelayDelay between picture displays.protected java.util.ArrayListmPendingPictures awaiting display.protected java.util.RandommRandomRandom number generator for picture placement.protected ThumbelinamThumbelinaThe thumbelina object to drive.
-
Constructor Summary
Constructors Constructor Description Sequencer(Thumbelina thumbelina)Creates a new instance of a Sequencer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(java.awt.Image image, java.net.URL url)Add an image to the pending list.voidadd(java.awt.Image image, java.net.URL url, boolean background)Add an image to the panel.intgetDelay()Getter for property delay.protected voidplace(Picture picture, boolean add)Place a picture in the display area.protected java.awt.Pointrandom(java.lang.String url, int width, int height)Compute a random point to load the image.voidreset()Clears the pending images list.voidrun()Display pictures from pending list with delay between.voidsetDelay(int delay)Setter for property delay.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Field Detail
-
DEFAULT_DELAY
protected static final int DEFAULT_DELAY
The default delay time, 500 milliseconds.- See Also:
- Constant Field Values
-
mThumbelina
protected Thumbelina mThumbelina
The thumbelina object to drive.
-
mPending
protected java.util.ArrayList mPending
Pictures awaiting display.
-
mActive
protected boolean mActive
Activity state.truemeans fetching and displaying,falsenot.
-
mDelay
protected int mDelay
Delay between picture displays.
-
mRandom
protected java.util.Random mRandom
Random number generator for picture placement.
-
-
Constructor Detail
-
Sequencer
public Sequencer(Thumbelina thumbelina)
Creates a new instance of a Sequencer.- Parameters:
thumbelina- The object to push images to.
-
-
Method Detail
-
reset
public void reset()
Clears the pending images list.
-
random
protected java.awt.Point random(java.lang.String url, int width, int height)Compute a random point to load the image. Generate a random point for one of the corners of the image and then condition the numbers so the image is on screen.- Parameters:
url- The url this picture was fetched from. Used in computing the random position, so the picture is always placed in the same location, even when refetched.width- The width of the image.height- The height of the image.- Returns:
- The random point to use.
-
add
public void add(java.awt.Image image, java.net.URL url)Add an image to the pending list.- Parameters:
image- The image to add.url- The url the image came from.
-
add
public void add(java.awt.Image image, java.net.URL url, boolean background)Add an image to the panel.- Parameters:
image- The image to add.url- The url the image came from.background- Iftrue, just add to pending list.
-
place
protected void place(Picture picture, boolean add)
Place a picture in the display area. Places the picture at a random location on screen.- Parameters:
picture- The picture to place on screen.add- Iftrue, the picture is added to the history.
-
run
public void run()
Display pictures from pending list with delay between. If the list is empty it waits on the pending list for new pictures.- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
getDelay
public int getDelay()
Getter for property delay.- Returns:
- Value of property delay.
-
setDelay
public void setDelay(int delay)
Setter for property delay.- Parameters:
delay- New value of property delay.
-
-