Class TLcdGXYAsynchronousPaintQueueManager
- Direct Known Subclasses:
TLcdGXYLspAsynchronousPaintQueueManager
Implementation of ALcdGXYAsynchronousPaintQueueManager
based on an ILcdGXYAsynchronousPaintHintProvider
and the TLcdGXYAsynchronousPaintHint
instances it provides. Such a paint
hint encapsulates paint requirements for an asynchronously painted layer and allows this paint
queue manager to create a paint queue with the
correct settings. Combining those paint hints also determines which asynchronous
layers can use the same paint queue.
Typical usage and behavior
When using the empty constructor, the manager will use a default paint hint provider that paints layers in the same paint queue as much as possible.
This manager includes getters and setters for the default values of properties used in the created asynchronous paint queues. A default property value is used if a paint queue needs to be created for a set of layers where no value of the property can be obtained for any of the layers, because no paint hint could be retrieved or because the paint hint did not specify the property. This does not influence the process of deciding which layers share a paint queue.
Sample code
// Create or obtain an ILcdGXYAsynchronousPaintHintProvider
ILcdGXYAsynchronousPaintHintProvider provider = ...
// Create a manager which uses the paint hint provider
TLcdGXYAsynchronousPaintQueueManager manager = new
TLcdGXYAsynchronousPaintQueueManager( provider );
// Adjust some default settings (optional)
manager.setDefaultBorderFactor( new Range( 0.2, 0.2 ) ); ...
// Set the view on the manager
manager.setGXYView( aGXYView );
Adding custom properties
Typically, if the ILcdGXYAsynchronousPaintHintProvider
returns custom extensions
of TLcdGXYAsynchronousPaintHint
, or TLcdGXYAsynchronousPaintHint
instances containing custom properties, you should override the combine
and create
method to take those customizations into account.
- Since:
- 10.1
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.luciad.view.gxy.asynchronous.manager.ALcdGXYAsynchronousPaintQueueManager
ALcdGXYAsynchronousPaintQueueManager.PaintBlock
-
Constructor Summary
ConstructorDescriptionDefault constructor.TLcdGXYAsynchronousPaintQueueManager
(ILcdGXYAsynchronousPaintHintProvider aPaintHintProvider) Creates a newTLcdGXYAsynchronousPaintQueueManager
which retrieves theTLcdGXYAsynchronousPaintHint
instances fromaPaintHintProvider
. -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
canMergePaintBlocks
(ALcdGXYAsynchronousPaintQueueManager.PaintBlock aPaintBlock, ALcdGXYAsynchronousPaintQueueManager.PaintBlock aAdjacentPaintBlock) Utility method to verify the prerequisites listed in themergePaintBlocks
method.protected TLcdGXYAsynchronousPaintHint
combine
(TLcdGXYAsynchronousPaintHint aPaintHint, TLcdGXYAsynchronousPaintHint aAnotherPaintHint) Combine twoTLcdGXYAsynchronousPaintHint
instances into a newTLcdGXYAsynchronousPaintHint
, or returnsnull
when the two paint hints cannot be combined.protected ILcdGXYAsynchronousPaintQueue
createAsynchronousPaintQueue
(TLcdGXYAsynchronousPaintHint aPaintHint, ILcdGXYAsynchronousPaintQueue aPaintQueue) Create anILcdGXYAsynchronousPaintQueue
matching the settings ofaPaintHint
.protected final ILcdGXYAsynchronousPaintQueue
Factory method to create a newILcdGXYAsynchronousPaintQueue
that will be used byaLayers
.final void
evaluateModifiedPaintBlocks
(List<ALcdGXYAsynchronousPaintQueueManager.PaintBlock> aChangedPaintBlocks, ILcdGXYLayer aLayer) Method to inform the implementation thataChangedPaintBlocks
should be re-evaluated.Returns a default value for the border factor.Returns a default value for the intermediate update range.Returns a default value for the interrupt mode property.Returns a default value for the interrupt painting property.Returns a default value for the painting mode.Returns a default value for the skip delay.Returns a default value for the synchronous delay.Returns a default value for the thread priority.Returns theILcdGXYAsynchronousPaintHintProvider
of this manager.void
setDefaultBorderFactor
(TLcdGXYAsynchronousPaintHint.Range aDefaultBorderFactor) Sets the default value for the border factor.void
setDefaultIntermediateUpdateRange
(TLcdGXYAsynchronousPaintHint.Range aDefaultIntermediateUpdateRange) Sets a default value for the intermediate update range.void
setDefaultInterruptMode
(TLcdGXYAsynchronousPaintHint.Choice aDefaultInterruptMode) Sets a default value for the interrupt mode property.void
setDefaultInterruptPainting
(TLcdGXYAsynchronousPaintHint.Choice aDefaultInterruptPainting) Sets a default value for the interrupt painting property.void
setDefaultPaintingMode
(TLcdGXYAsynchronousPaintHint.Choice aDefaultPaintingMode) Sets the default value for the painting mode.void
setDefaultSkipDelay
(TLcdGXYAsynchronousPaintHint.Range aDefaultSkipDelay) Sets a default value for the skip delay.void
setDefaultSynchronousDelay
(TLcdGXYAsynchronousPaintHint.Range aDefaultSynchronousDelay) Sets a default value for the synchronous delay.void
setDefaultThreadPriority
(TLcdGXYAsynchronousPaintHint.Range aDefaultThreadPriority) Sets a default value for the thread priority.Methods inherited from class com.luciad.view.gxy.asynchronous.manager.ALcdGXYAsynchronousPaintQueueManager
getGXYView, getPaintBlock, getPaintBlocks, mergePaintBlocksSFCT, replacePaintBlockSFCT, setGXYView, splitPaintBlockSFCT
-
Constructor Details
-
TLcdGXYAsynchronousPaintQueueManager
public TLcdGXYAsynchronousPaintQueueManager()Default constructor.
The created paint queue manager will use a
ILcdGXYAsynchronousPaintHintProvider
, which returns aTLcdGXYAsynchronousPaintHint
with default settings for everyILcdGXYAsynchronousLayerWrapper
. In practice, this means that asynchronous layers will be painted in the same paint queue as much as possible.Warning: this manager will do nothing until
setGXYView
is called. -
TLcdGXYAsynchronousPaintQueueManager
public TLcdGXYAsynchronousPaintQueueManager(ILcdGXYAsynchronousPaintHintProvider aPaintHintProvider) Creates a new
TLcdGXYAsynchronousPaintQueueManager
which retrieves theTLcdGXYAsynchronousPaintHint
instances fromaPaintHintProvider
.Warning: this manager will do nothing until
setGXYView
is called.- Parameters:
aPaintHintProvider
- The paint hint provider.
-
-
Method Details
-
evaluateModifiedPaintBlocks
public final void evaluateModifiedPaintBlocks(List<ALcdGXYAsynchronousPaintQueueManager.PaintBlock> aChangedPaintBlocks, ILcdGXYLayer aLayer) Method to inform the implementation that
aChangedPaintBlocks
should be re-evaluated. This method is called by the manager- when a new asynchronous layer is added to the view. For every new asynchronous layer a new paint queue is created, and a corresponding paint block is inserted. This method is then called including that new block and its neighbor blocks.
- when a synchronous layer is added to the view, causing an existing paint block to split.
Both parts of the split paint block will be included in
aChangedPaintBlocks
. - when an asynchronous layer is removed from the view.
aChangedPaintBlocks
will contain thePaintBlock
previously containing the layer. In case the paint block is empty and removed, the adjacentPaintBlock
instances will be contained inaChangedPaintBlocks
. - when a synchronous layer is removed, and the corresponding paint block becomes empty and is
removed as well.
aChangedPaintBlocks
will contain the adjacentPaintBlock
s of the removed instance. - when a layer is moved from index
x
to indexy
,aChangedPaintBlocks
will contain the samePaintBlock
s as when the layer was removed from indexx
and added to indexy
, as described above. - when the numberOfCachedBackgroundLayers property of the view changes. The list of changed paint blocks will contain the paint blocks which were split due to the original value of that property, and the paint blocks which are now split due to the new value of that property.
- when adding, removing and/or moving an
ILcdLayerTreeNode
with child layers, this method is only called once with theILcdLayerTreeNode
as parameter. TheList
of changed paint blocks will then include all relevantPaintBlock
s, based on the criteria listed above.
Typically, implementations of this method will call the
split
andmerge
methods of the manager to indicate which layers should share a paint queue.An example implementation of this method is one which tries to minimize the number of paint queues, by always merging adjacent paint blocks with a non-
null
queue.This method may be called from outside the manager as well, e.g. when the criteria to share a paint queue have been changed.
Note that this method will not be called when manual changes are applied to the paint blocks. For example, calling the merge, split and/or replace methods will not trigger this method.
Based on the retrieved
TLcdGXYAsynchronousPaintHint
instances of theILcdGXYLayer
instances in the changedPaintBlock
s, this method will:- Verify whether all
ILcdGXYLayer
instances in aPaintBlock
can still remain in onePaintBlock
, or whether thePaintBlock
must be split (which is determined by trying to combine the paint hints of the correspondingILcdGXYLayer
s). The latter could happen when theTLcdGXYAsynchronousPaintHint
s of theILcdGXYLayer
s have dynamic paint requirements. - Update the paint queue of every changed
PaintBlock
by calling thecreateAsynchronousPaintQueue
method. - Merge all adjacent
PaintBlock
s when possible (which is determined by trying to combine the paint hints of the correspondingILcdGXYLayer
s).
- Specified by:
evaluateModifiedPaintBlocks
in classALcdGXYAsynchronousPaintQueueManager
- Parameters:
aChangedPaintBlocks
- AList
containing allPaintBlock
s remaining in this manager which must be re-evaluated. In case aPaintBlock
is removed or inserted, thisList
will also include the neighborPaintBlock
instances. The paint queue of thesePaintBlock
s will never benull
. ThePaintBlock
s in thisList
are ordered in the same way as in theALcdGXYAsynchronousPaintQueueManager.getPaintBlocks()
List
aLayer
- TheILcdGXYLayer
in which the change, triggering the call of this method, occurred, ornull
when the change was not triggered by a specific layer.
-
canMergePaintBlocks
public final boolean canMergePaintBlocks(ALcdGXYAsynchronousPaintQueueManager.PaintBlock aPaintBlock, ALcdGXYAsynchronousPaintQueueManager.PaintBlock aAdjacentPaintBlock) Utility method to verify the prerequisites listed in the
mergePaintBlocks
method. Returnstrue
when the mergePaintBlocks method can be called with the same arguments,false
otherwise.Only
PaintBlock
instances of which the paint hints of the layers can be combined can be merged. This is checked as well in this method.- Overrides:
canMergePaintBlocks
in classALcdGXYAsynchronousPaintQueueManager
- Parameters:
aPaintBlock
- aPaintBlock
aAdjacentPaintBlock
- an adjacentPaintBlock
- Returns:
true
whenaPaintBlock
andaAdjacentPaintBlock
can be merged,false
otherwise- See Also:
-
createAsynchronousPaintQueue
protected final ILcdGXYAsynchronousPaintQueue createAsynchronousPaintQueue(List<ILcdGXYAsynchronousLayerWrapper> aLayers) Factory method to create a new
ILcdGXYAsynchronousPaintQueue
that will be used byaLayers
. The returnedILcdGXYAsynchronousPaintQueue
must be a new instance, and must not be in use by any existingPaintBlock
.This method should always return a non-
null
paint queue which may be used by all layers inaLayers
. EitheraLayers
will only contain oneILcdGXYAsynchronousLayerWrapper
, or a set ofILcdGXYAsynchronousLayerWrapper
s which were already part of onePaintBlock
with a non-null
paint queue. Therefore this method should always be able to return a non-null
paint queue.The manager may wrap paint queues, so it may be that the returned
ILcdGXYAsynchronousPaintQueue
is not set directly as paint queue on the layers.The manager calls this method:
- Every time an asynchronous layer is added to the view, or moved outside its current paint
block. In such cases, the evaluateModifiedPaintBlocks can decided to merge the new
paint queue immediately with an existing one. Therefore it is recommended to return
ILcdGXYAsynchronousPaintQueue
instances which only allocate resources (e.g. a buffer and a separateThread
) when needed, and not on creation. - From the merge and split methods when no paint queue was specified for the resulting paint block.
This method will determine the TLcdGXYAsynchronousPaintHint for every
ILcdGXYLayer
, combine them and create anILcdGXYAsynchronousPaintQueue
for the resulting combinedTLcdGXYAsynchronousPaintHint
. This queue will then be returned.- Specified by:
createAsynchronousPaintQueue
in classALcdGXYAsynchronousPaintQueueManager
- Parameters:
aLayers
- theILcdGXYAsynchronousLayerWrapper
s that will use the returnedILcdGXYAsynchronousPaintQueue
- Returns:
- a new
ILcdGXYAsynchronousPaintQueue
instance. Must not benull
- Every time an asynchronous layer is added to the view, or moved outside its current paint
block. In such cases, the evaluateModifiedPaintBlocks can decided to merge the new
paint queue immediately with an existing one. Therefore it is recommended to return
-
combine
protected TLcdGXYAsynchronousPaintHint combine(TLcdGXYAsynchronousPaintHint aPaintHint, TLcdGXYAsynchronousPaintHint aAnotherPaintHint) Combine two
TLcdGXYAsynchronousPaintHint
instances into a newTLcdGXYAsynchronousPaintHint
, or returnsnull
when the two paint hints cannot be combined.By default, this method performs an attempt to combine the key-value pairs of the properties. Properties with a common key will be combined if possible by using the
combine
method ofTLcdGXYAsynchronousPaintHint.Combinable
. In case combining two common properties returnsnull
, it will be considered impossible to combineaPaintHint
andaAnotherPaintHint
and this method will returnnull
.Properties with a key which is only contained in one of the paint hints will be included in the result as well.
- Parameters:
aPaintHint
- The first paint hint. Must not benull
.aAnotherPaintHint
- The second paint hint. Must not benull
.- Returns:
- A combination of
aPaintHint
andaAnotherPaintHint
, ornull
when both hints cannot be combined.
-
createAsynchronousPaintQueue
protected ILcdGXYAsynchronousPaintQueue createAsynchronousPaintQueue(TLcdGXYAsynchronousPaintHint aPaintHint, ILcdGXYAsynchronousPaintQueue aPaintQueue) Create an
ILcdGXYAsynchronousPaintQueue
matching the settings ofaPaintHint
.- Parameters:
aPaintHint
- TheTLcdGXYAsynchronousPaintHint
encapsulating the settings for theILcdGXYAsynchronousPaintQueue
which must be created.aPaintQueue
- AILcdGXYAsynchronousPaintQueue
which may be returned (with updated settings). Can benull
. In this case a new instance must be created, when notnull
aPaintQueue
may be re-used as return value but this is not obligatory.- Returns:
- an
ILcdGXYAsynchronousPaintQueue
matching the settings of this factory
-
getPaintHintProvider
Returns theILcdGXYAsynchronousPaintHintProvider
of this manager.- Returns:
- the
ILcdGXYAsynchronousPaintHintProvider
of this manager.
-
getDefaultPaintingMode
Returns a default value for the painting mode.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the painting mode
-
setDefaultPaintingMode
Sets the default value for the painting mode.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultPaintingMode
- The default paint mode- See Also:
-
getDefaultBorderFactor
Returns a default value for the border factor.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the border factor
-
setDefaultBorderFactor
Sets the default value for the border factor.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultBorderFactor
- The default border factor- See Also:
-
getDefaultSkipDelay
Returns a default value for the skip delay.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the skip delay
-
setDefaultSkipDelay
Sets a default value for the skip delay.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultSkipDelay
- The default skip delay.- See Also:
-
getDefaultSynchronousDelay
Returns a default value for the synchronous delay.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the synchronous delay
-
setDefaultSynchronousDelay
Sets a default value for the synchronous delay.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultSynchronousDelay
- The default value for the synchronous delay- See Also:
-
getDefaultThreadPriority
Returns a default value for the thread priority.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- A default value for the thread priority
-
setDefaultThreadPriority
Sets a default value for the thread priority.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultThreadPriority
- The default value for the thread priority- See Also:
-
getDefaultIntermediateUpdateRange
Returns a default value for the intermediate update range.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the intermediate update range
-
setDefaultIntermediateUpdateRange
public void setDefaultIntermediateUpdateRange(TLcdGXYAsynchronousPaintHint.Range aDefaultIntermediateUpdateRange) Sets a default value for the intermediate update range.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultIntermediateUpdateRange
- The default value for the intermediate update range- See Also:
-
getDefaultInterruptPainting
Returns a default value for the interrupt painting property.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the interrupt painting property
-
setDefaultInterruptPainting
public void setDefaultInterruptPainting(TLcdGXYAsynchronousPaintHint.Choice aDefaultInterruptPainting) Sets a default value for the interrupt painting property.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultInterruptPainting
- The default value for the interrupt painting property- See Also:
-
getDefaultInterruptMode
Returns a default value for the interrupt mode property.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Returns:
- a default value for the interrupt mode property
-
setDefaultInterruptMode
Sets a default value for the interrupt mode property.
This default value will be used when creating a new paint queue and the value is not specified in the paint hint or no paint hint is available.
- Parameters:
aDefaultInterruptMode
- The default value for the interrupt mode property- See Also:
-