Package com.luciad.view.gxy.asynchronous
Class TLcdGXYAsynchronousMultiPaintQueue
java.lang.Object
com.luciad.view.gxy.asynchronous.TLcdGXYAsynchronousMultiPaintQueue
- All Implemented Interfaces:
ILcdGXYAsynchronousPaintQueue
public class TLcdGXYAsynchronousMultiPaintQueue
extends Object
implements ILcdGXYAsynchronousPaintQueue
A paint queue for multiple views, delegating to several ILcdGXYAsynchronousPaintQueue instances.
A multi paint queue is linked to a single layer. However, the delegated paint queues may be shared
by several layers.
The ILcdGXYAsynchronousPaintQueue instances to use should be
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.
- Since:
- 8.0
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new multi view paint queue for the given layer wrapper. -
Method Summary
Modifier and TypeMethodDescriptionvoidRegisters anILcdGXYAsynchronousPaintListenerto be informed of asynchronous painting events.Returns the layer for which this paint performs its delegation.getGXYAsynchronousPaintQueue(ILcdGXYView aGXYView) Returns theILcdGXYAsynchronousPaintQueuethat is used to paint asynchronously on the given viewReturns all set ILcdGXYAsynchronousPaintQueue instances.getGXYAsynchronousView(ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView) Returns the view on which the asynchronous paint requests are actually executed.voidinvokeAndWait(Runnable aRunnable) Executes the givenRunnablesynchronously, but without interfering with the paint thread.voidinvokeLater(Runnable aRunnable) Executes the givenRunnablein the paint thread and returns immediately.voidinvokeLaterInEDT(Runnable aRunnable) Executes the givenRunnablein the event dispatch thread and returns immediately.booleanisEmpty()Returns true if the paint queue is not painting and it has no paint requests to finish.voidpaint(Graphics aGraphics, ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView) Paints an image of the painted layers using the given graphics.voidStops informing the givenILcdGXYAsynchronousPaintListenerof asynchronous painting events.voidreset()Clears all cached images and paint requests.voidsetGXYAsynchronousPaintQueue(ILcdGXYView aGXYView, ILcdGXYAsynchronousPaintQueue aQueue) Sets theILcdGXYAsynchronousPaintQueuethat is used to paint asynchronously on the given view.
-
Constructor Details
-
TLcdGXYAsynchronousMultiPaintQueue
Creates a new multi view paint queue for the given layer wrapper. For each view to paint asynchronously on, an appropriate paint queue should be set usingsetGXYAsynchronousPaintQueue(com.luciad.view.gxy.ILcdGXYView, com.luciad.view.gxy.asynchronous.ILcdGXYAsynchronousPaintQueue).- Parameters:
aWrapper- the layer wrapper that should be painted asynchronously on several views
-
-
Method Details
-
getGXYAsynchronousLayerWrapper
Returns the layer for which this paint performs its delegation.- Returns:
- the layer wrapper that is painted asynchronously
-
getGXYAsynchronousPaintQueue
Returns theILcdGXYAsynchronousPaintQueuethat is used to paint asynchronously on the given view- Parameters:
aGXYView- the view for which to return a paint queue- Returns:
- the paint queue that paints this queue's layer asynchronously for the given view
-
getGXYAsynchronousPaintQueues
Returns all set ILcdGXYAsynchronousPaintQueue instances.- Returns:
- all set ILcdGXYAsynchronousPaintQueue instances
- See Also:
-
setGXYAsynchronousPaintQueue
public void setGXYAsynchronousPaintQueue(ILcdGXYView aGXYView, ILcdGXYAsynchronousPaintQueue aQueue) Sets theILcdGXYAsynchronousPaintQueuethat is used to paint asynchronously on the given view. This method should only be called before setting this multi paint queue on a layer.- Parameters:
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.
-
paint
public void paint(Graphics aGraphics, ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView) Paints an image of the painted layers using the given graphics. If a valid image is not available for the mode, this operation queues an asynchronous paint request, in order to create one. The parent view will then be asked to repaint itself when the asynchronous painting is completed.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.
- Specified by:
paintin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aGraphics- the graphics to use for paintingaWrapper- the asynchronous layer wrapper that should be paintedaMode- the mode indicating what should be painted, seeILcdGXYLayer.paint(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYView).aGXYView- the view for which the layer should be painted.
-
getGXYAsynchronousView
public ILcdGXYView getGXYAsynchronousView(ILcdGXYAsynchronousLayerWrapper aWrapper, int aMode, ILcdGXYView aGXYView) Description copied from interface:ILcdGXYAsynchronousPaintQueueReturns the view on which the asynchronous paint requests are actually executed. In the painting thread, the asynchronous view replaces the given view when painting the given asynchronous layer with the given painting mode. Its images are then used as image buffers that can be composited in the actual view.- Specified by:
getGXYAsynchronousViewin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aWrapper- the asynchronous layer wrapper that would be paintedaMode- the mode indicating what should be painted, seeILcdGXYLayer.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.- Returns:
- the view that is used for asynchronous painting
-
reset
Description copied from interface:ILcdGXYAsynchronousPaintQueueClears all cached images and paint requests. Waits for asynchronous painting to finish.- Specified by:
resetin interfaceILcdGXYAsynchronousPaintQueue- Throws:
InterruptedException- when the thread is interrupted while waiting for the asynchronous paint to complete
-
isEmpty
public boolean isEmpty()Description copied from interface:ILcdGXYAsynchronousPaintQueueReturns true if the paint queue is not painting and it has no paint requests to finish. When called on the event dispatch thread, it should guarantee that no painting occurs while the caller holds the thread.- Specified by:
isEmptyin interfaceILcdGXYAsynchronousPaintQueue- Returns:
- true when no painting will occur while the caller holds the thread
-
invokeLater
Executes the givenRunnablein 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.- Specified by:
invokeLaterin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aRunnable- theRunnableto execute. Therunmethod should take care when waiting for another thread: if that thread in turn waits for asynchronous painting to complete, a deadlock will occur.
-
invokeLaterInEDT
Description copied from interface:ILcdGXYAsynchronousPaintQueueExecutes the givenRunnablein the event dispatch thread and returns immediately.- Specified by:
invokeLaterInEDTin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aRunnable- theRunnableto execute.
-
invokeAndWait
Executes the givenRunnablesynchronously, but without interfering with the paint thread. This call blocks until all asynchronous paints and runnables have been processed, and theRunnablereturns. 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.- Specified by:
invokeAndWaitin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aRunnable- theRunnableto execute. Therunmethod should take care when waiting for another thread: if that thread in turn waits for asynchronous painting to complete, a deadlock will occur.- Throws:
InterruptedException- when the thread is interrupted while waiting for the execution to complete
-
addGXYAsynchronousPaintListener
Description copied from interface:ILcdGXYAsynchronousPaintQueueRegisters anILcdGXYAsynchronousPaintListenerto be informed of asynchronous painting events. These events will be thrown in the asynchronous painting thread.- Specified by:
addGXYAsynchronousPaintListenerin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aListener- the listener that should be notified
-
removeGXYAsynchronousPaintListener
Description copied from interface:ILcdGXYAsynchronousPaintQueueStops informing the givenILcdGXYAsynchronousPaintListenerof asynchronous painting events.- Specified by:
removeGXYAsynchronousPaintListenerin interfaceILcdGXYAsynchronousPaintQueue- Parameters:
aListener- the listener that should no longer be notified.
-