Class TLcdGXYContinuousLabelingAlgorithm

java.lang.Object
com.luciad.realtime.gxy.labeling.TLcdGXYContinuousLabelingAlgorithm
All Implemented Interfaces:
ILcdCloneable, ILcdGXYLabelingAlgorithm, Cloneable

public class TLcdGXYContinuousLabelingAlgorithm extends Object implements ILcdGXYLabelingAlgorithm
Implementation of ILcdGXYLabelingAlgorithm that offers continuously decluttered labels, ideally suited for labeling moving objects (e.g., tracks).

When the objects move, the labels move along and avoid overlap in a continuous fashion by moving the labels around gently. The locations of the labels are not limited to a fixed number of possible locations, instead a label can be put everywhere on the map. By default there is no hard constraint on the distance between the label and the object. The labels do tend to move to their desired label location though.

Using this class, the desired location of the labels can be specified for all labels at once or for every label individually.

Which labels are removed in the labeling process is defined by the label coverage property. Which labels should be dropped first is influenced by the order in which labels are retrieved from the label infos object, see TLcdCollectedLabelInfoList.getLabels(). The default is to never drop any labels.

You can configure the positioning of the labels in various ways:

This algorithm uses the obstacles and placements from the given ILcdLabelConflictChecker to avoid placing labels at these locations.

For smooth visual results, the layer/view using this painter should be refreshed regularly. This can for example be done by using the TLcdSimulator, or by refreshing the map using a timer, e.g. for a gxy layer/view :


   Timer timer = new Timer( 50, new ActionListener() {
     public void actionPerformed( ActionEvent e ) {
       ILcdGXYView view = ...;
       ILcdGXYLayer track_layer = ...;
       view.invalidateGXYLayer( track_layer, true, this, "Invalidating track layer" );
       }
     }
   } );
   timer.setRepeats( true );
   timer.start();
 

Using such a timer, it might be important with respect to performance to set the correct number of background layers (see ILcdGXYView.getNumberOfCachedBackgroundLayers()). The TLcdSimulator does this automatically (see TLcdSimulator.isManageNumberOfCachedBackgroundLayers()).

Notes:

  • This labeling algorithm never drops labels. This means that in some cases, when many labels need to be displayed, labels can overlap.
  • This algorithm assumes the ILcdGXYLabelPainter of the layer implements ILcdGXYLabelPainter2 as it can only declutter labels if they can be placed freely, not when placement is limited to a fixed number of locations.
  • The bounds returned by the ILcdGXYLabelPainter2 need to be independent of the location of the label for this algorithm to work well. Therefore the option setConsiderPinForBounds of TLcdGXYStampLabelPainter is not supported in combination with this algorithm, as the pin varies in size depending on the label location.
  • This class supports rotated labels and rotated obstacles. However for performance reasons the axis aligned bounds of these labels are used in most calculations. Because of this, labels might not be optimally placed.
  • The implementation of this labeling algorithm is thread-safe if the set master-slave dependency provider is thread-safe, the label priority provider is thread-safe and all overridden methods are implemented in a thread-safe manner.
Since:
10.1