public class TLcdGXYAsynchronousPaintQueueManager extends ALcdGXYAsynchronousPaintQueueManager
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.
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.
// 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 );
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.
ILcdGXYAsynchronousPaintHintProvider
,
TLcdGXYAsynchronousPaintHint
ALcdGXYAsynchronousPaintQueueManager.PaintBlock
Constructor and Description |
---|
TLcdGXYAsynchronousPaintQueueManager()
Default constructor.
|
TLcdGXYAsynchronousPaintQueueManager(ILcdGXYAsynchronousPaintHintProvider aPaintHintProvider)
Creates a new
TLcdGXYAsynchronousPaintQueueManager which retrieves the
TLcdGXYAsynchronousPaintHint instances from aPaintHintProvider . |
Modifier and Type | Method and Description |
---|---|
boolean |
canMergePaintBlocks(ALcdGXYAsynchronousPaintQueueManager.PaintBlock aPaintBlock,
ALcdGXYAsynchronousPaintQueueManager.PaintBlock aAdjacentPaintBlock)
Utility method to verify the prerequisites listed in the
mergePaintBlocks method. |
protected TLcdGXYAsynchronousPaintHint |
combine(TLcdGXYAsynchronousPaintHint aPaintHint,
TLcdGXYAsynchronousPaintHint aAnotherPaintHint)
Combine two
TLcdGXYAsynchronousPaintHint instances into a new
TLcdGXYAsynchronousPaintHint , or returns null when the two paint
hints cannot be combined. |
protected ILcdGXYAsynchronousPaintQueue |
createAsynchronousPaintQueue(List<ILcdGXYAsynchronousLayerWrapper> aLayers)
Factory method to create a new
ILcdGXYAsynchronousPaintQueue that will be used
by aLayers . |
protected ILcdGXYAsynchronousPaintQueue |
createAsynchronousPaintQueue(TLcdGXYAsynchronousPaintHint aPaintHint,
ILcdGXYAsynchronousPaintQueue aPaintQueue)
Create an
ILcdGXYAsynchronousPaintQueue matching the settings of
aPaintHint . |
void |
evaluateModifiedPaintBlocks(List<ALcdGXYAsynchronousPaintQueueManager.PaintBlock> aChangedPaintBlocks,
ILcdGXYLayer aLayer)
Method to inform the implementation that
aChangedPaintBlocks should be
re-evaluated. |
TLcdGXYAsynchronousPaintHint.Range |
getDefaultBorderFactor()
Returns a default value for the border factor.
|
TLcdGXYAsynchronousPaintHint.Range |
getDefaultIntermediateUpdateRange()
Returns a default value for the intermediate update range.
|
TLcdGXYAsynchronousPaintHint.Choice |
getDefaultInterruptMode()
Returns a default value for the interrupt mode property.
|
TLcdGXYAsynchronousPaintHint.Choice |
getDefaultInterruptPainting()
Returns a default value for the interrupt painting property.
|
TLcdGXYAsynchronousPaintHint.Choice |
getDefaultPaintingMode()
Returns a default value for the painting mode.
|
TLcdGXYAsynchronousPaintHint.Range |
getDefaultSkipDelay()
Returns a default value for the skip delay.
|
TLcdGXYAsynchronousPaintHint.Range |
getDefaultSynchronousDelay()
Returns a default value for the synchronous delay.
|
TLcdGXYAsynchronousPaintHint.Range |
getDefaultThreadPriority()
Returns a default value for the thread priority.
|
ILcdGXYAsynchronousPaintHintProvider |
getPaintHintProvider()
Returns the
ILcdGXYAsynchronousPaintHintProvider 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.
|
getGXYView, getPaintBlock, getPaintBlocks, mergePaintBlocksSFCT, replacePaintBlockSFCT, setGXYView, splitPaintBlockSFCT
public TLcdGXYAsynchronousPaintQueueManager()
Default constructor.
The created paint queue manager will use a ILcdGXYAsynchronousPaintHintProvider
,
which returns a TLcdGXYAsynchronousPaintHint
with default settings for every
ILcdGXYAsynchronousLayerWrapper
. 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.
public TLcdGXYAsynchronousPaintQueueManager(ILcdGXYAsynchronousPaintHintProvider aPaintHintProvider)
Creates a new TLcdGXYAsynchronousPaintQueueManager
which retrieves the
TLcdGXYAsynchronousPaintHint
instances from aPaintHintProvider
.
Warning: this manager will do nothing until setGXYView
is called.
aPaintHintProvider
- The paint hint provider.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
aChangedPaintBlocks
.aChangedPaintBlocks
will
contain the PaintBlock
previously containing the layer. In case the paint block is
empty and removed, the adjacent PaintBlock
instances will be contained in
aChangedPaintBlocks
.aChangedPaintBlocks
will contain the adjacent
PaintBlock
s of the removed instance.x
to index y
,
aChangedPaintBlocks
will contain the same PaintBlock
s as when the
layer was removed from index x
and added to index y
, as described
above.ILcdLayerTreeNode
with child layers, this
method is only called once with the ILcdLayerTreeNode
as parameter. The List
of changed paint blocks will then include all relevant PaintBlock
s, based on the criteria
listed above.Typically, implementations of this method will call the split
and merge
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 the
ILcdGXYLayer
instances in the changed PaintBlock
s, this method
will:
ILcdGXYLayer
instances in a PaintBlock
can
still remain in one PaintBlock
, or whether the PaintBlock
must be
split (which is determined by trying to combine the paint hints of the corresponding
ILcdGXYLayer
s). The latter could happen when the TLcdGXYAsynchronousPaintHint
s
of the ILcdGXYLayer
s have dynamic paint requirements.PaintBlock
by calling the createAsynchronousPaintQueue
method.PaintBlock
s when possible (which is determined by trying to
combine the
paint hints of the corresponding ILcdGXYLayer
s).evaluateModifiedPaintBlocks
in class ALcdGXYAsynchronousPaintQueueManager
aChangedPaintBlocks
- A List
containing all PaintBlock
s
remaining in this manager which must be re-evaluated. In case a
PaintBlock
is removed or inserted, this
List
will also include the neighbor
PaintBlock
instances. The paint queue of these PaintBlock
s will never be
null
. The PaintBlock
s in this
List
are ordered in the same way as in the ALcdGXYAsynchronousPaintQueueManager.getPaintBlocks()
List
aLayer
- The ILcdGXYLayer
in which the change, triggering the
call of this method, occurred, or null
when the change
was not triggered by a specific layer.public final boolean canMergePaintBlocks(ALcdGXYAsynchronousPaintQueueManager.PaintBlock aPaintBlock, ALcdGXYAsynchronousPaintQueueManager.PaintBlock aAdjacentPaintBlock)
Utility method to verify the prerequisites listed in the mergePaintBlocks
method. Returns true
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.
canMergePaintBlocks
in class ALcdGXYAsynchronousPaintQueueManager
aPaintBlock
- a PaintBlock
aAdjacentPaintBlock
- an adjacent PaintBlock
true
when aPaintBlock
and aAdjacentPaintBlock
can be merged, false
otherwisecombine(TLcdGXYAsynchronousPaintHint, TLcdGXYAsynchronousPaintHint)
protected final ILcdGXYAsynchronousPaintQueue createAsynchronousPaintQueue(List<ILcdGXYAsynchronousLayerWrapper> aLayers)
Factory method to create a new ILcdGXYAsynchronousPaintQueue
that will be used
by aLayers
. The returned ILcdGXYAsynchronousPaintQueue
must be a new
instance, and must not be in use by any existing PaintBlock
.
This method should always return a non-null
paint queue which may be used by
all layers in aLayers
. Either aLayers
will only contain one
ILcdGXYAsynchronousLayerWrapper
, or a set of ILcdGXYAsynchronousLayerWrapper
s
which were already part of one PaintBlock
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:
ILcdGXYAsynchronousPaintQueue
instances which only allocate resources (e.g. a
buffer and a separate Thread
) when needed, and not on creation.This method will determine the TLcdGXYAsynchronousPaintHint for every ILcdGXYLayer
, combine them and
create an ILcdGXYAsynchronousPaintQueue
for the
resulting combined TLcdGXYAsynchronousPaintHint
. This queue will then be
returned.
createAsynchronousPaintQueue
in class ALcdGXYAsynchronousPaintQueueManager
aLayers
- the ILcdGXYAsynchronousLayerWrapper
s that will use the returned
ILcdGXYAsynchronousPaintQueue
ILcdGXYAsynchronousPaintQueue
instance. Must not be
null
protected TLcdGXYAsynchronousPaintHint combine(TLcdGXYAsynchronousPaintHint aPaintHint, TLcdGXYAsynchronousPaintHint aAnotherPaintHint)
Combine two TLcdGXYAsynchronousPaintHint
instances into a new
TLcdGXYAsynchronousPaintHint
, or returns null
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 of TLcdGXYAsynchronousPaintHint.Combinable
. In case combining two
common properties returns null
, it will be considered impossible to combine
aPaintHint
and aAnotherPaintHint
and this method will return
null
.
Properties with a key which is only contained in one of the paint hints will be included in the result as well.
aPaintHint
- The first paint hint. Must not be null
.aAnotherPaintHint
- The second paint hint. Must not be null
.aPaintHint
and aAnotherPaintHint
, or
null
when both hints cannot be combined.protected ILcdGXYAsynchronousPaintQueue createAsynchronousPaintQueue(TLcdGXYAsynchronousPaintHint aPaintHint, ILcdGXYAsynchronousPaintQueue aPaintQueue)
Create an ILcdGXYAsynchronousPaintQueue
matching the settings of
aPaintHint
.
aPaintHint
- The TLcdGXYAsynchronousPaintHint
encapsulating the settings for
the ILcdGXYAsynchronousPaintQueue
which must be created.aPaintQueue
- A ILcdGXYAsynchronousPaintQueue
which may be returned (with
updated settings). Can be null
. In this case a new instance
must be created, when not null
aPaintQueue
may be
re-used as return value but this is not obligatory.ILcdGXYAsynchronousPaintQueue
matching the settings of this factorypublic ILcdGXYAsynchronousPaintHintProvider getPaintHintProvider()
ILcdGXYAsynchronousPaintHintProvider
of this manager.ILcdGXYAsynchronousPaintHintProvider
of this manager.public TLcdGXYAsynchronousPaintHint.Choice 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.
public void setDefaultPaintingMode(TLcdGXYAsynchronousPaintHint.Choice aDefaultPaintingMode)
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.
aDefaultPaintingMode
- The default paint modeTLcdGXYAsynchronousPaintHint.setPaintingMode(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Choice)
public TLcdGXYAsynchronousPaintHint.Range 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.
public void setDefaultBorderFactor(TLcdGXYAsynchronousPaintHint.Range aDefaultBorderFactor)
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.
aDefaultBorderFactor
- The default border factorTLcdGXYAsynchronousPaintHint.setBorderFactor(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Range)
public TLcdGXYAsynchronousPaintHint.Range 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.
public void setDefaultSkipDelay(TLcdGXYAsynchronousPaintHint.Range aDefaultSkipDelay)
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.
aDefaultSkipDelay
- The default skip delay.TLcdGXYAsynchronousPaintHint.setSkipDelay(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Range)
public TLcdGXYAsynchronousPaintHint.Range 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.
public void setDefaultSynchronousDelay(TLcdGXYAsynchronousPaintHint.Range aDefaultSynchronousDelay)
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.
aDefaultSynchronousDelay
- The default value for the synchronous delayTLcdGXYAsynchronousPaintHint.setSynchronousDelay(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Range)
public TLcdGXYAsynchronousPaintHint.Range 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.
public void setDefaultThreadPriority(TLcdGXYAsynchronousPaintHint.Range aDefaultThreadPriority)
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.
aDefaultThreadPriority
- The default value for the thread priorityTLcdGXYAsynchronousPaintHint.setThreadPriority(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Range)
public TLcdGXYAsynchronousPaintHint.Range 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.
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.
aDefaultIntermediateUpdateRange
- The default value for the intermediate update rangeTLcdGXYAsynchronousPaintHint.setIntermediateUpdateRange(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Range)
public TLcdGXYAsynchronousPaintHint.Choice 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.
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.
aDefaultInterruptPainting
- The default value for the interrupt painting propertyTLcdGXYAsynchronousPaintHint.setInterruptPainting(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Choice)
public TLcdGXYAsynchronousPaintHint.Choice 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.
public void setDefaultInterruptMode(TLcdGXYAsynchronousPaintHint.Choice aDefaultInterruptMode)
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.
aDefaultInterruptMode
- The default value for the interrupt mode propertyTLcdGXYAsynchronousPaintHint.setInterruptMode(com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintHint.Choice)