Class TLcdGXYAsynchronousPaintQueueManager

java.lang.Object
com.luciad.view.gxy.asynchronous.manager.ALcdGXYAsynchronousPaintQueueManager
com.luciad.view.gxy.asynchronous.manager.TLcdGXYAsynchronousPaintQueueManager
Direct Known Subclasses:
TLcdGXYLspAsynchronousPaintQueueManager

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.

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:
  • Constructor Details

    • TLcdGXYAsynchronousPaintQueueManager

      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.

    • TLcdGXYAsynchronousPaintQueueManager

      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.

      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 the PaintBlock previously containing the layer. In case the paint block is empty and removed, the adjacent PaintBlock instances will be contained in aChangedPaintBlocks.
      • when a synchronous layer is removed, and the corresponding paint block becomes empty and is removed as well. aChangedPaintBlocks will contain the adjacent PaintBlocks of the removed instance.
      • when a layer is moved from index x to index y, aChangedPaintBlocks will contain the same PaintBlocks as when the layer was removed from index x and added to index y, 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 the ILcdLayerTreeNode as parameter. The List of changed paint blocks will then include all relevant PaintBlocks, 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 PaintBlocks, this method will:

      1. Verify whether all 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 ILcdGXYLayers). The latter could happen when the TLcdGXYAsynchronousPaintHints of the ILcdGXYLayers have dynamic paint requirements.
      2. Update the paint queue of every changed PaintBlock by calling the createAsynchronousPaintQueue method.
      3. Merge all adjacent PaintBlocks when possible (which is determined by trying to combine the paint hints of the corresponding ILcdGXYLayers).
      Specified by:
      evaluateModifiedPaintBlocks in class ALcdGXYAsynchronousPaintQueueManager
      Parameters:
      aChangedPaintBlocks - A List containing all PaintBlocks 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 PaintBlocks will never be null. The PaintBlocks 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.
    • canMergePaintBlocks

      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.

      Overrides:
      canMergePaintBlocks in class ALcdGXYAsynchronousPaintQueueManager
      Parameters:
      aPaintBlock - a PaintBlock
      aAdjacentPaintBlock - an adjacent PaintBlock
      Returns:
      true when aPaintBlock and aAdjacentPaintBlock 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 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 ILcdGXYAsynchronousLayerWrappers 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:

      • 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 separate Thread) 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 an ILcdGXYAsynchronousPaintQueue for the resulting combined TLcdGXYAsynchronousPaintHint. This queue will then be returned.

      Specified by:
      createAsynchronousPaintQueue in class ALcdGXYAsynchronousPaintQueueManager
      Parameters:
      aLayers - the ILcdGXYAsynchronousLayerWrappers that will use the returned ILcdGXYAsynchronousPaintQueue
      Returns:
      a new ILcdGXYAsynchronousPaintQueue instance. Must not be null
    • combine

      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.

      Parameters:
      aPaintHint - The first paint hint. Must not be null.
      aAnotherPaintHint - The second paint hint. Must not be null.
      Returns:
      A combination of aPaintHint and aAnotherPaintHint, or null when both hints cannot be combined.
    • createAsynchronousPaintQueue

      protected ILcdGXYAsynchronousPaintQueue createAsynchronousPaintQueue(TLcdGXYAsynchronousPaintHint aPaintHint, ILcdGXYAsynchronousPaintQueue aPaintQueue)

      Create an ILcdGXYAsynchronousPaintQueue matching the settings of aPaintHint.

      Parameters:
      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.
      Returns:
      an ILcdGXYAsynchronousPaintQueue matching the settings of this factory
    • getPaintHintProvider

      public ILcdGXYAsynchronousPaintHintProvider getPaintHintProvider()
      Returns the ILcdGXYAsynchronousPaintHintProvider of this manager.
      Returns:
      the ILcdGXYAsynchronousPaintHintProvider of this manager.
    • getDefaultPaintingMode

      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.

      Returns:
      a default value for the painting mode
    • setDefaultPaintingMode

      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.

      Parameters:
      aDefaultPaintingMode - The default paint mode
      See Also:
    • getDefaultBorderFactor

      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.

      Returns:
      a default value for the border factor
    • setDefaultBorderFactor

      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.

      Parameters:
      aDefaultBorderFactor - The default border factor
      See Also:
    • getDefaultSkipDelay

      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.

      Returns:
      a default value for the skip delay
    • setDefaultSkipDelay

      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.

      Parameters:
      aDefaultSkipDelay - The default skip delay.
      See Also:
    • getDefaultSynchronousDelay

      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.

      Returns:
      a default value for the synchronous delay
    • setDefaultSynchronousDelay

      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.

      Parameters:
      aDefaultSynchronousDelay - The default value for the synchronous delay
      See Also:
    • getDefaultThreadPriority

      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.

      Returns:
      A default value for the thread priority
    • setDefaultThreadPriority

      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.

      Parameters:
      aDefaultThreadPriority - The default value for the thread priority
      See Also:
    • getDefaultIntermediateUpdateRange

      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.

      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

      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.

      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

      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.

      Returns:
      a default value for the interrupt mode property
    • setDefaultInterruptMode

      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.

      Parameters:
      aDefaultInterruptMode - The default value for the interrupt mode property
      See Also: