Class TLspCompositeLabelingAlgorithm

java.lang.Object
com.luciad.view.lightspeed.label.algorithm.TLspCompositeLabelingAlgorithm
All Implemented Interfaces:
ILcdCloneable, ILspLabelingAlgorithm, Cloneable

public class TLspCompositeLabelingAlgorithm extends Object implements ILspLabelingAlgorithm

This composite labeling algorithm combines several ILspLabelingAlgorithms. It works by assigning algorithms to labels using getAlgorithmProvider(). Labels that use the same algorithm are grouped, and then handled by it.

The order in which the algorithms are executed is determined by the sortAlgorithms method. By default it sorts the algorithms based on the priorities of the view representations that are placed by them. The highest priority of all of its labels is assigned to each algorithm. The algorithms are then sorted based on this priority. When two algorithms have the same priority assigned, the original order in which the algorithms are given is respected.

The default order can be customized by overriding the sortAlgorithms method.

Since:
2012.0
  • Constructor Details

    • TLspCompositeLabelingAlgorithm

      public TLspCompositeLabelingAlgorithm(ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> aAlgorithmProvider)
      Creates a composite labeling algorithm that uses the given ILspLabelingAlgorithmProvider to assign algorithms to labels.
      Parameters:
      aAlgorithmProvider - a labeling algorithm provider that returns algorithms for a given label.
  • Method Details

    • getAlgorithmProvider

      public ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> getAlgorithmProvider()
      Returns the used labeling algorithm provider.
      Returns:
      the used labeling algorithm provider.
    • sortAlgorithms

      protected List<ILspLabelingAlgorithm> sortAlgorithms(Map<ILspLabelingAlgorithm,List<TLspLabelID>> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView)

      This method sorts the given List of algorithms. The algorithms will be used in this order to place labels. The original order of the algorithms is determined by the order of the labels in aLabels.

      The default implementation sorts the algorithms based on the priorities of the view representations that are placed by them. The highest priority of all of its representations is assigned to each algorithm. The labeling algorithms are then sorted based on this priority. When two algorithms have the same priority assigned, the original order in which the algorithms are given is respected.

      Override this method to provide a custom placement order.

      Parameters:
      aLabels - a mapping of algorithms, and the labels placed by them.
      aLabelContext - the label info object.
      aView - the view.
      Returns:
      the sorted List of algorithms.
    • clone

      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Overrides:
      clone in class Object
      See Also:
    • placeLabels

      public List<TLspLabelPlacement> placeLabels(List<TLspLabelID> aLabelIDs, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView)
      Description copied from interface: ILspLabelingAlgorithm

      This method computes a list of label placements for the given List of labels. The returned label placements should contain a valid label location and label bounds. They should also point to their corresponding TLspLabelID

      The returned List of TLspLabelPlacements contains label placements that are either visible or invisible. When a placement is present in the list, it means that the location should be stored. When a placement in the list is marked as visible, it means that its location should be marked as visible in the label placer

      Specified by:
      placeLabels in interface ILspLabelingAlgorithm
      Parameters:
      aLabelIDs - the labels to be placed.
      aLabelContext - provides context information, such as priorities, PaintState, ...
      aConflictChecker - the conflict checker that can be used to detect conflicts between labels.
      aView - the view.
      Returns:
      a list of label placements.