public interface ILcdGXYAsynchronousLayerWrapper extends ILcdGXYLayer
ILcdGXYLayer
.
Instead of painting synchronously in the event dispatch thread, this wrapper delegates its paint requests to an
ILcdGXYAsynchronousPaintQueue
. The paint queue has its own asynchronous thread in which it paints
the wrapped layer. This image will then be painted again in the event dispatch thread.
create(com.luciad.view.gxy.ILcdGXYLayer)
method.
When using asynchronous layer painting, please take the following into consideration:
TLcdGXYAsynchronousViewLabelPainterWrapper
);This interface offers the following invocation methods to access and manipulate the wrapped layer's state:
invokeAndWaitOnGXYLayer(com.luciad.view.gxy.asynchronous.ILcdGXYAsynchronousLayerRunnable)
for safe, blocked access;invokeLaterOnGXYLayer(com.luciad.view.gxy.asynchronous.ILcdGXYAsynchronousLayerRunnable)
to safe, asynchronous access;invokeNowOnGXYLayer(com.luciad.view.gxy.asynchronous.ILcdGXYAsynchronousLayerRunnable)
for synchronous access that does not interfere with asynchronous painting.
If the wrapper itself exposes the wrapped layer's state (i.e. by implementing some interface),
this state must be duplicated and synchronized.
For example, if someone calls ILcdGXYAsynchronousLayerWrapper#setVisible( false )
,
it is expected that the wrapped layer will also change its visibility.
Here, the layer wrapper's responsibility is to duplicate and track state changes (i.e. what to synchronize).
The paint queue determines a safe point in time for synchronizing these changes (i.e. when to synchronize).
The paint queue accesses this functionality through the getSynchronousGXYLayerChangeTracker()
and
getAsynchronousGXYLayerChangeTracker()
methods.
The former method retrieves and applies changes for this wrapper,
the latter retrieves and applies changes for the wrapped layer.
To illustrate the state synchronization mechanism, consider a visibility change in the layer wrapper:
ILcdGXYAsynchronousLayerWrapper#getSynchronousGXYLayerChangeTracker#getChanges()
.
Here, the changed state will consist of the change in visibility.
ILcdGXYAsynchronousLayerWrapper#getAsynchronousGXYLayerChangeTracker#applyChanges()
.
Hence, the wrapped layer will become invisible.
ILcdGXYAsynchronousLayerWrapper#getAsynchronousGXYLayerChangeTracker#getChanges()
ILcdGXYAsynchronousLayerWrapper#getSynchronousGXYLayerChangeTracker#applyChanges()
ILcdGXYAsynchronousPaintQueue
Modifier and Type | Method and Description |
---|---|
static ILcdGXYAsynchronousLayerWrapper |
create(ILcdGXYLayer aLayer)
Utility method to wrap
aLayer with a default ILcdGXYAsynchronousLayerWrapper implementation. |
ILcdGXYLayerChangeTracker |
getAsynchronousGXYLayerChangeTracker()
Returns a state change synchronizer for the wrapped layer.
|
ILcdGXYAsynchronousPaintQueue |
getGXYAsynchronousPaintQueue()
Returns the paint queue handling the asynchronous paints.
|
ILcdGXYLayer |
getGXYLayer()
Returns the layer that contains the actual paint logic.
|
ILcdGXYLayerChangeTracker |
getSynchronousGXYLayerChangeTracker()
Returns a state change synchronizer for this wrapper.
|
void |
invokeAndWaitOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation)
Executes the given layer runnable so that the invocation does not interfere with the asynchronous painting.
|
void |
invokeLaterOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation)
Executes the given layer runnable so that the invocation does not interfere with the asynchronous painting.
|
void |
invokeLaterOnGXYLayerInEDT(ILcdGXYAsynchronousLayerRunnable aInvocation)
Executes the given layer runnable so that the invocation does not interfere with the asynchronous painting.
|
void |
invokeNowOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation)
Executes the given layer runnable so that the invocation does not interfere with state synchronization.
|
boolean |
isAsynchronous()
Returns whether the wrapped layer is configured to be painted asynchronously.
|
void |
setAsynchronous(boolean aAsynchronous)
Disables or enables the asynchronous drawing.
|
void |
setGXYAsynchronousPaintQueue(ILcdGXYAsynchronousPaintQueue aQueue)
Sets the paint queue to delegate asynchronous paint requests to.
|
applyOnInteract, getBounds, getGXYEditor, getGXYLabelPainter, getGXYPainter, getGXYPen, getLabelMapScaleRange, getLabelScaleRange, getMapScaleRange, getModelXYWorldTransfoClass, getScaleRange, isLabeled, isLabeledSupported, paint, setLabeled, stopPainting
clearSelection, fireCollectedSelectionChanges, getIcon, getLabel, getModel, isEditable, isEditableSupported, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setIcon, setLabel, setSelectable, setVisible
addSelectionListener, getSelectedObjects, getSelectionCount, isSelected, removeSelectionListener, selectedObjects
addPropertyChangeListener, removePropertyChangeListener
ILcdGXYAsynchronousPaintQueue getGXYAsynchronousPaintQueue()
void setGXYAsynchronousPaintQueue(ILcdGXYAsynchronousPaintQueue aQueue)
aQueue
- the asynchronous paint queue responsible for executing the paint calls.ILcdGXYLayer getGXYLayer()
invokeAndWaitOnGXYLayer(ILcdGXYAsynchronousLayerRunnable)
and invokeLaterOnGXYLayer(ILcdGXYAsynchronousLayerRunnable)
provide safe alternatives.void setAsynchronous(boolean aAsynchronous) throws InterruptedException
aAsynchronous
- if false, paints synchronously, if true, paints asynchronouslyInterruptedException
- when the thread is interrupted while waiting for the asynchronous paint to completeboolean isAsynchronous()
void invokeAndWaitOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation) throws InterruptedException
aInvocation
- the invocation to run. The invocation will pass the original layer.InterruptedException
- when the thread is interrupted while waiting for the asynchronous painting
to completevoid invokeLaterOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation)
The invocation should take care when waiting for another thread: if that thread in turn waits for asynchronous painting to complete, a deadlock will occur.
To avoid concurrency problems with property change listeners, layer property changes will be fired on the event dispatch thread, not on the asynchronous paint thread.
aInvocation
- the invocation to run. The invocation will pass the original layer.void invokeLaterOnGXYLayerInEDT(ILcdGXYAsynchronousLayerRunnable aInvocation)
aInvocation
- the invocation to run. The invocation will pass the original layer.void invokeNowOnGXYLayer(ILcdGXYAsynchronousLayerRunnable aInvocation)
aInvocation
- the invocation to run. The invocation will pass the original layer.ILcdGXYLayerChangeTracker getSynchronousGXYLayerChangeTracker()
ILcdGXYLayerChangeTracker getAsynchronousGXYLayerChangeTracker()
static ILcdGXYAsynchronousLayerWrapper create(ILcdGXYLayer aLayer)
Utility method to wrap aLayer
with a default ILcdGXYAsynchronousLayerWrapper
implementation.
The used wrapper depends on the interfaces that aLayer
implements.
This method supports:
ILcdGXYLayer
instances.ILcdLayerTreeNode
instances.ILcdGXYEditableLabelsLayer
implementations: the returned asynchronous wrapper will also implement the ILcdGXYEditableLabelsLayer
interface.
Any other interfaces the ILcdGXYLayer
implements will not be exposed by the returned asynchronous wrapper.
aLayer
- The layer (structure) to wrap