|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.groboclown.gui.paintpipe.v1.PainterThread | +--net.groboclown.gui.paintpipe.v1.RefreshPainter
A RefreshPainter has some similarities to a PipePainter, in that
it listens to input. However, it outputs directly to some on-screen
component which implements RefreshComponent
.
To prevent the case where the component is drawing one image, while that same image is being repainted in another thread, we swap between two images to paint to.
Again, like PipePainter, you have no need to override the functionality
of the paint()
method. Instead, you should implement its hooks,
areMoreEvents()
and processEvent(net.groboclown.gui.paintpipe.v1.PaintEvent)
. When areMoreEvents()
returns false, all registered paint threads are finished up by a call
to paintFinished(net.groboclown.gui.paintpipe.v1.PaintFinishedEvent)
.
Therefore, this class acts as the overal clock-master, keeping track of when the frames change.
PipePainter
,
PaintQueue
Inner classes inherited from class net.groboclown.gui.paintpipe.v1.PainterThread |
PainterThread.PaintRunnable |
Field Summary | |
private PaintQueue |
inQ
|
private Vector |
paintThreads
|
private PaintFinishedEvent |
pfe
|
private RefreshComponent |
rc
|
Fields inherited from class net.groboclown.gui.paintpipe.v1.PainterThread |
frameNumber, group, isPainting, METRICS, metricsListeners, name, numberPaintAttempts, numberWaitForEvent, painter, priority, RUN_NEVER_STARTED, RUN_PAUSED, RUN_REQUESTED_PAUSE, RUN_REQUESTED_STOP, RUN_RUNNING, RUN_STOPPED, runState, sentPaintFinishedEvent, startTimeMillis, syncThis, totalPaintTimeMillis, totalWaitForEventTimeMillis |
Constructor Summary | |
RefreshPainter(PaintQueue in,
RefreshComponent rc)
Creates a new PipePainter with the given input and output PaintQueues. |
|
RefreshPainter(RefreshComponent rc)
Creates a new RefreshPainter with a new input PaintQueue, and the given refresh component. |
Method Summary | |
void |
addPainterThread(PainterThread pt)
Adds a PainterThread to the list of those known about. |
protected abstract boolean |
areMoreEvents()
Checks if any more events need to be pulled from the queue. |
RefreshComponent |
getComponent()
|
protected abstract Image |
getImage()
Returns the current state of the image being generated. |
PaintQueue |
getInputQueue()
|
protected void |
paint()
The paint method is already implemented in this case. |
void |
paintFinished(PaintFinishedEvent pfe)
Turn back on the queue at the end of the paint finished event to re-enable input checking. |
protected abstract void |
processEvent(PaintEvent pe)
Processes the next PaintEvent from the input queue. |
void |
removePainterThread(PainterThread pt)
Removes the given registered PainterThread from the list. |
protected abstract void |
setImage(Image img)
Sets the image to use for the painting phaze. |
Methods inherited from class net.groboclown.gui.paintpipe.v1.PainterThread |
addMetricsListener, canPause, canStop, cleanup, fireMetricsPaint, fireMetricsWait, getFrameNumber, getNumberPaintCalls, getNumberWaitForEventTimes, getStartTimeMillis, getTotalPaintTimeMillis, getTotalWaitForEventTimeMillis, initialize, isAlive, isInterrupted, isRunning, isStopImpending, isStopping, isSuspended, isWaitingForEvent, join, killPainting, removeMetricsListener, resume, start, stop, stopInterrupt, stopInterruptJoin, stopJoin, suspend, suspendInterrupt |
Methods inherited from class java.lang.Object |
|
Field Detail |
private PaintQueue inQ
private RefreshComponent rc
private Vector paintThreads
private PaintFinishedEvent pfe
Constructor Detail |
public RefreshPainter(RefreshComponent rc)
rc
- the component to send refresh events to.public RefreshPainter(PaintQueue in, RefreshComponent rc)
in
- the input queue, listened to by this thread.rc
- the component to send refresh events to.Method Detail |
public PaintQueue getInputQueue()
public RefreshComponent getComponent()
public void addPainterThread(PainterThread pt)
public void removePainterThread(PainterThread pt)
public void paintFinished(PaintFinishedEvent pfe) throws InterruptedException
paintFinished
in class PainterThread
protected final void paint() throws InterruptedException
Instead, the
paint method calls areMoreEvents()
to check if
any more events are needed to create the output image.
The processEvent(net.groboclown.gui.paintpipe.v1.PaintEvent)
method is called to process
a new event which was read from the input queue.
If a FlushPaintingEvent
is found in the queue,
no more events are processed for the frame.
At the end of a paint, the component is refreshed, and
the paintFinished(net.groboclown.gui.paintpipe.v1.PaintFinishedEvent)
event is called to announce to
everyone to start painting again.
paint
in class PainterThread
for more information on reasons to disable the
queue.
protected abstract void processEvent(PaintEvent pe)
pe
- the event which is to be processed.protected abstract boolean areMoreEvents()
protected abstract Image getImage()
protected abstract void setImage(Image img)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |