Class TLcdGXYCurvedPathLabelingAlgorithm

java.lang.Object
com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithm
com.luciad.view.gxy.labeling.algorithm.discrete.TLcdGXYCurvedPathLabelingAlgorithm
All Implemented Interfaces:
ILcdCloneable, ILcdGXYLabelingAlgorithm, Cloneable

public class TLcdGXYCurvedPathLabelingAlgorithm extends ALcdGXYDiscretePlacementsLabelingAlgorithm
This labeling algorithm tries to find a valid position for a curved path text label. To do this it uses a given TLcdGXYCurvedPathLabelPainter.

This labeling algorithm does not use the labelBoundsSFCT() method of the given TLcdGXYCurvedPathLabelPainter to calculate the label bounds. Instead it retrieves the settings of this label painter (halo enabled/thickness, used font, ...) to calculate the bounds itself.

This labeling algorithm depends on TLcdGXYCurvedPathLabelLocation in order to work. Only 3 fields of the label location are actually set :

  • TLcdGXYCurvedPathLabelLocation.getLocationIndex() (to -1)
  • TLcdGXYCurvedPathLabelLocation.getSubPathIndex()
  • TLcdGXYCurvedPathLabelLocation.getAWTPathParameter()
The rest of the fields are not used since these field completely determine the position of the label.

This labeling algorithm will only work when a TLcdGXYCurvedPathLabelPainter is used to actually paint the labels. This label painter also works with TLcdGXYCurvedPathLabelLocations, and uses the 'sub path index' and 'awt path parameter' fields.

The implementation of this labeling algorithm is thread-safe, as long as the ILcdGXYLabelingPathProvider set in the given TLcdGXYCurvedPathLabelPainter is thread-safe.

Since:
11.0
  • Constructor Details

    • TLcdGXYCurvedPathLabelingAlgorithm

      public TLcdGXYCurvedPathLabelingAlgorithm(ILcdGXYLabelPainterProvider aGXYCurvedPathLabelPainterProvider)
      Creates a new TLcdGXYCurvedPathLabelingAlgorithm which uses the given ILcdGXYLabelPainterProvider to retrieve a TLcdGXYCurvedPathLabelPainter. This label painter can then be used to retrieve the bounds of a label.
      Parameters:
      aGXYCurvedPathLabelPainterProvider - a label painter provider which should return TLcdGXYCurvedPathLabelPainters.
  • Method Details

    • getMinimumGap

      public double getMinimumGap()
      Returns the minimum gap between two labels on the same path.
      Returns:
      the minimum gap between two labels on the same path.
      Since:
      2021.1
      See Also:
    • setMinimumGap

      public void setMinimumGap(double aMinimumGap)
      Sets the minimum gap between two labels on the same path. This distance is expressed in pixels and should be positive.

      The default value is 100 pixels.

      Parameters:
      aMinimumGap - the minimal gap between two labels on the same path.
      Since:
      2021.1
    • isReusePreviousLocations

      public boolean isReusePreviousLocations()
      Returns if the algorithm tries to reuse the previous label location.
      Returns:
      if the algorithm tries to reuse the previous label location.
      See Also:
    • setReusePreviousLocations

      public void setReusePreviousLocations(boolean aReusePreviousLocations)
      Sets if the algorithm tries to reuse the previous label location.
      Parameters:
      aReusePreviousLocations - true if the algorithm should reuse the previous label location, and false otherwise.
      See Also:
    • 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
      See Also:
    • collectLabelInfo

      public TLcdCollectedLabelInfoList collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView)
      Description copied from interface: ILcdGXYLabelingAlgorithm
      This method returns a TLcdCollectedLabelInfoList object based on the given list of TLcdLabelIdentifiers. The returned TLcdCollectedLabelInfoList should contain a TLcdCollectedLabelInfo object for each label that should be placed.

      Each TLcdCollectedLabelInfo should also contain all information needed by computeLabelPlacements to place the labels. In order to enable correct asynchronous label placing, all calls to the layer and the (label) painters should be done in this method. The results should then be stored in the info objects.

      It is possible that the returned TLcdCollectedLabelInfoList doesn't contain a TLcdCollectedLabelInfo object for every given TLcdLabelIdentifier. In that case the missing labels are not placed.

      Specified by:
      collectLabelInfo in interface ILcdGXYLabelingAlgorithm
      Parameters:
      aLabelsToCollect - the labels for which a TLcdCollectedLabelInfoList should be created.
      aGraphics - the graphics.
      aGXYView - the view.
      Returns:
      a TLcdCollectedLabelInfoList which contains all the information needed to place the labels.
    • createLabelIterator

      protected Iterator<TLcdCollectedLabelInfo> createLabelIterator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView)
      Description copied from class: ALcdGXYDiscretePlacementsLabelingAlgorithm
      Creates a new Iterator that iterates over the TLcdCollectedLabelInfos. The abstract labeling algorithm will continue iterating over TLcdCollectedLabelInfos as long as Iterator.hasNext() returns true. When it returns false, no more labels will be tried, and computeLabelPlacements returns. Iterator.hasNext() should always be called before calling Iterator.next(), and if it returns true, Iterator.next() should never return null.

      The implementation of this method should be as independent as possible. It should not rely on createLabelPlacementIterator or createLabelPlacementEvaluator. Not respecting this might result in unexpected behaviour when wrapping or extending this class.

      The returned TLcdCollectedLabelInfo should be correctly initialized, i.e. it should contain all information needed to create valid TLcdLabelPlacements using createLabelPlacementIterator. It should also always point to its corresponding TLcdCollectedLabeledObjectInfo.

      Override this method to provide a custom implementation.

      Specified by:
      createLabelIterator in class ALcdGXYDiscretePlacementsLabelingAlgorithm
      Parameters:
      aLabelInfoList - the label infos object that contains all information needed to place the labels.
      aBoundsConflictChecker - the bounds conflict checker to be used when evaluating label placements.
      aView - the view.
      Returns:
      a new Iterator that iterates over TLcdCollectedLabelInfos.
    • createLabelPlacementIterator

      protected Iterator<TLcdLabelPlacement> createLabelPlacementIterator(TLcdCollectedLabelInfo aLabel, TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView)
      Description copied from class: ALcdGXYDiscretePlacementsLabelingAlgorithm
      Creates a new Iterator that iterates over the TLcdLabelPlacements for the given label. The abstract labeling algorithm will continue iterating over TLcdLabelPlacements as long as Iterator.hasNext() returns true. When it returns false, a new label will be tried. Iterator.hasNext() should always be called before calling Iterator.next(), and if it returns true, Iterator.next() should never return null.

      The implementation of this method should be as independent as possible. It should not rely on createLabelIterator or createLabelPlacementEvaluator. Not respecting this might result in unexpected behaviour when wrapping or extending this class.

      The returned TLcdLabelPlacement should be correctly initialized, i.e. it should at least be able to return a valid label location, bounds rectangle and bounds rotation. It should also reference its corresponding TLcdCollectedLabelInfo.

      Override this method to provide a custom implementation.

      Specified by:
      createLabelPlacementIterator in class ALcdGXYDiscretePlacementsLabelingAlgorithm
      Parameters:
      aLabel - the label for which an iterator should be created.
      aLabelInfoList - the info object that contains all information needed to place the labels.
      aBoundsConflictChecker - the bounds conflict checker to be used when evaluating label placements.
      aView - the view.
      Returns:
      a new Iterator that iterates over TLcdLabelPlacements.
    • createLabelPlacementEvaluator

      protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView)
      Description copied from class: ALcdGXYDiscretePlacementsLabelingAlgorithm
      Creates a new ILcdLabelPlacementEvaluator using the given parameters. It evaluates the placements returned by createLabelPlacementIterator, and returns a PlacementResult to denote if the placement should be used for its label or not.

      The following actions are undertaken for the following placement results :

      Override this method to provide a custom implementation.

      Specified by:
      createLabelPlacementEvaluator in class ALcdGXYDiscretePlacementsLabelingAlgorithm
      Parameters:
      aLabelInfoList - the info object that contains all information needed to place the labels.
      aBoundsConflictChecker - the bounds conflict checker to be used when evaluating label placements.
      aView - the view
      Returns:
      a new LabelPlacementEvaluator
      See Also:
    • getLabelPriorityProvider

      public ILcdGXYMultiLabelPriorityProvider getLabelPriorityProvider()
      Returns the label placing priority provider.
      Returns:
      the label placing priority provider.
      See Also:
    • setLabelPriorityProvider

      public void setLabelPriorityProvider(ILcdGXYMultiLabelPriorityProvider aLabelPriorityProvider)
      Sets the label placing priority provider, specifying the priority for individual labels. This priority provider specifies the order in which labels are placed. In the event labels overlap, those with higher priority are painted on top of labels with lower priority. So lower priority labels are the first candidates if labels need to be obscured.

      When no label priority provider is set, no label priorities are set.

      The priority provider is used to sort the list of labels before their placements are computed.

      Parameters:
      aLabelPriorityProvider - The priority provider to set.