public class TLcdGXYAsynchronousMultiPaintQueue extends Object implements ILcdGXYAsynchronousPaintQueue
set
before setting this multi paint queue on a layer.
Note that the use of this class is not recommended: because a layer cannot be accessed simultaneously, and because the delegate ILcdGXYAsynchronousPaintQueues do not know of each other, a TLcdGXYAsynchronousMultiPaintQueue uses significantly more synchronization to enforce single-threaded access.
Instead, it is recommended to create separate layers for the same model. This allows the model to be painted in parallel on all views.
Constructor and Description |
---|
TLcdGXYAsynchronousMultiPaintQueue(ILcdGXYAsynchronousLayerWrapper aWrapper)
Creates a new multi view paint queue for the given layer wrapper.
|
Modifier and Type | Method and Description |
---|---|
void |
addGXYAsynchronousPaintListener(ILcdGXYAsynchronousPaintListener aListener)
Registers an
ILcdGXYAsynchronousPaintListener to be informed of asynchronous painting events. |
ILcdGXYAsynchronousLayerWrapper |
getGXYAsynchronousLayerWrapper()
Returns the layer for which this paint performs its delegation.
|
ILcdGXYAsynchronousPaintQueue |
getGXYAsynchronousPaintQueue(ILcdGXYView aGXYView)
Returns the
ILcdGXYAsynchronousPaintQueue that is used to paint asynchronously on the given view |
Map<ILcdGXYView,ILcdGXYAsynchronousPaintQueue> |
getGXYAsynchronousPaintQueues()
Returns all set ILcdGXYAsynchronousPaintQueue instances.
|
ILcdGXYView |
getGXYAsynchronousView(ILcdGXYAsynchronousLayerWrapper aWrapper,
int aMode,
ILcdGXYView aGXYView)
Returns the view on which the asynchronous paint requests are actually
executed.
|
void |
invokeAndWait(Runnable aRunnable)
Executes the given
Runnable synchronously, but without interfering with the paint thread. |
void |
invokeLater(Runnable aRunnable)
Executes the given
Runnable in the paint thread and returns immediately. |
void |
invokeLaterInEDT(Runnable aRunnable)
Executes the given
Runnable in the event dispatch thread and returns immediately. |
boolean |
isEmpty()
Returns true if the paint queue is not painting and it has no paint requests to finish.
|
void |
paint(Graphics aGraphics,
ILcdGXYAsynchronousLayerWrapper aWrapper,
int aMode,
ILcdGXYView aGXYView)
Paints an image of the painted layers using the given graphics.
|
void |
removeGXYAsynchronousPaintListener(ILcdGXYAsynchronousPaintListener aListener)
Stops informing the given
ILcdGXYAsynchronousPaintListener of asynchronous painting events. |
void |
reset()
Clears all cached images and paint requests.
|
void |
setGXYAsynchronousPaintQueue(ILcdGXYView aGXYView,
ILcdGXYAsynchronousPaintQueue aQueue)
Sets the
ILcdGXYAsynchronousPaintQueue that is used to paint asynchronously on the given view. |
public TLcdGXYAsynchronousMultiPaintQueue(ILcdGXYAsynchronousLayerWrapper aWrapper)
setGXYAsynchronousPaintQueue(com.luciad.view.gxy.ILcdGXYView, com.luciad.view.gxy.asynchronous.ILcdGXYAsynchronousPaintQueue)
.aWrapper
- the layer wrapper that should be painted asynchronously on several viewspublic ILcdGXYAsynchronousLayerWrapper getGXYAsynchronousLayerWrapper()
public ILcdGXYAsynchronousPaintQueue getGXYAsynchronousPaintQueue(ILcdGXYView aGXYView)
ILcdGXYAsynchronousPaintQueue
that is used to paint asynchronously on the given viewaGXYView
- the view for which to return a paint queuepublic Map<ILcdGXYView,ILcdGXYAsynchronousPaintQueue> getGXYAsynchronousPaintQueues()
setGXYAsynchronousPaintQueue(com.luciad.view.gxy.ILcdGXYView, ILcdGXYAsynchronousPaintQueue)
public void setGXYAsynchronousPaintQueue(ILcdGXYView aGXYView, ILcdGXYAsynchronousPaintQueue aQueue)
ILcdGXYAsynchronousPaintQueue
that is used to paint asynchronously on the given view.
This method should only be called before setting this multi paint queue on a layer.aGXYView
- the view for which to set the given paint queueaQueue
- the paint queue that paints this queue's layer asynchronously, or null if no paint queue is
to be used
Paint calls for the given view are delegated to the given queue.public void paint(Graphics aGraphics, ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView)
Note that the paint queue is free to decide if it will execute the paint synchronously or asynchronously (e.g. when confronted with unsupported views). This paint queue delegates to several individual paint queues to paint asynchronously on multiple views.
paint
in interface ILcdGXYAsynchronousPaintQueue
aGraphics
- the graphics to use for paintingaWrapper
- the asynchronous layer wrapper that should be paintedaMode
- the mode indicating what should be painted, see ILcdGXYLayer.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYView)
.aGXYView
- the view for which the layer should be painted.public ILcdGXYView getGXYAsynchronousView(ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView)
ILcdGXYAsynchronousPaintQueue
getGXYAsynchronousView
in interface ILcdGXYAsynchronousPaintQueue
aWrapper
- the asynchronous layer wrapper that would be paintedaMode
- the mode indicating what should be painted, see ILcdGXYLayer.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYView)
.aGXYView
- the original view for which asynchronous paints are meant to be displayed. Paints
for unsupported views are executed synchronously.public void reset() throws InterruptedException
ILcdGXYAsynchronousPaintQueue
reset
in interface ILcdGXYAsynchronousPaintQueue
InterruptedException
- when the thread is interrupted while waiting for the asynchronous paint
to completepublic boolean isEmpty()
ILcdGXYAsynchronousPaintQueue
isEmpty
in interface ILcdGXYAsynchronousPaintQueue
public void invokeLater(Runnable aRunnable)
Runnable
in the paint thread and returns immediately.
This paint queue delegates this call to one of the set paint queues.
The wrapper is synchronized on during the call.invokeLater
in interface ILcdGXYAsynchronousPaintQueue
aRunnable
- the Runnable
to execute. The run
method should take care
when waiting for another thread: if that thread in turn waits for asynchronous painting to complete,
a deadlock will occur.public void invokeLaterInEDT(Runnable aRunnable)
ILcdGXYAsynchronousPaintQueue
Runnable
in the event dispatch thread and returns immediately.invokeLaterInEDT
in interface ILcdGXYAsynchronousPaintQueue
aRunnable
- the Runnable
to execute.public void invokeAndWait(Runnable aRunnable) throws InterruptedException
Runnable
synchronously, but without interfering with the paint thread.
This call blocks until all
asynchronous paints and runnables have been processed, and the Runnable
returns.
The invocation is executed in the view's paint thread (typically the EDT).
This paint queue delegates this call to one of the set paint queues.
The wrapper is synchronized on during the call.invokeAndWait
in interface ILcdGXYAsynchronousPaintQueue
aRunnable
- the Runnable
to execute. The run
method should take care
when waiting for another thread: if that thread in turn waits for asynchronous painting to complete,
a deadlock will occur.InterruptedException
- when the thread is interrupted while waiting for the execution
to completepublic void addGXYAsynchronousPaintListener(ILcdGXYAsynchronousPaintListener aListener)
ILcdGXYAsynchronousPaintQueue
ILcdGXYAsynchronousPaintListener
to be informed of asynchronous painting events.
These events will be thrown in the asynchronous painting thread.addGXYAsynchronousPaintListener
in interface ILcdGXYAsynchronousPaintQueue
aListener
- the listener that should be notifiedpublic void removeGXYAsynchronousPaintListener(ILcdGXYAsynchronousPaintListener aListener)
ILcdGXYAsynchronousPaintQueue
ILcdGXYAsynchronousPaintListener
of asynchronous painting events.removeGXYAsynchronousPaintListener
in interface ILcdGXYAsynchronousPaintQueue
aListener
- the listener that should no longer be notified.