|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.groboclown.gui.paintpipe.v1.PaintQueue
A Queue designed for a multi-threaded painting environment. It only allows paint events to pass through.
A problem may occur when a painting thread has just finished recieving all the incoming events it needs to draw the given image. A situation could arise where the posting thread(s) continue to send events to the queue. Then when the new frame is triggered, the listening thread would read the past frame's events in before the events for the current frame.
To prevent this from happening, we have a current frame number variable. This way, if events are posted from an earlier frame, they are ignored. This means that we want to keep track of future frame events as well in another list, and move them over when the frame number changes. Also, when the frame updates, we need to clear out all the old events relating to previous frames.
In the current architecture, the frame number is updated in the PainterThread.paintFinished(net.groboclown.gui.paintpipe.v1.PaintFinishedEvent)
routine. All other events posted need to have
their frame number stamped to the current painter's frame number.
Field Summary | |
private int |
frameNumber
|
private Vector |
futureEvents
|
private SynchQueue |
tq
|
Constructor Summary | |
PaintQueue()
Creates a new thread queue. |
|
PaintQueue(SynchQueue queue)
Uses the given queue as the internal representation of a queue. |
Method Summary | |
PaintEvent |
dequeue()
Removes a paint event from the queue, and waits if the queue is empty. |
void |
enqueue(PaintEvent pe)
Puts a paint event at the tail of the queue. |
int |
getFrame()
Returns the state of the queue to allow input or not. |
boolean |
isEmpty()
Checks if the queue is empty. |
void |
removeAll()
Empties the queue, and the future list. |
void |
setFrame(int f)
Sets the current frame number, and adjusts the queues accordingly. |
int |
size()
Returns the number of events waiting in the queue with the same frame number as the queue. |
Methods inherited from class java.lang.Object |
|
Field Detail |
private SynchQueue tq
private int frameNumber
private Vector futureEvents
Constructor Detail |
public PaintQueue()
public PaintQueue(SynchQueue queue)
queue
- Description of ParameterMethod Detail |
public boolean isEmpty()
public int getFrame()
public void enqueue(PaintEvent pe)
pe
- Description of Parameterpublic PaintEvent dequeue() throws InterruptedException
InterruptedException
- thrown when the thread was interrupted
by another thread.public void removeAll()
public int size()
public void setFrame(int f) throws InterruptedException
f
- The new Frame valueInterruptedException
- thrown when the thread was interrupted
by another thread.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |