Class TLspFixedInPathLabelLocationProvider

java.lang.Object
com.luciad.view.lightspeed.label.algorithm.ALspLabelLocationProvider
com.luciad.view.lightspeed.label.algorithm.TLspFixedInPathLabelLocationProvider

public class TLspFixedInPathLabelLocationProvider extends ALspLabelLocationProvider

This label location provider calculates a single location inside the anchor object of a label. For example for polygons, it calculates a location inside the polygon. For arc-bands, it calculates a location in between the start and end angle, and between the min and max radius. For some shapes it may use the focus point.

This algorithm works when the anchor object is an ILcdShape. For the following shapes, there is extra functionality to calculate a point inside the shape:

  • ILcdPointList
  • ILcdBounds
  • ILcdGeoBuffer
  • ILcdArcBand

When the anchor object of the label is a composite shape, like an ILcdShapeList or ILcdComplexPolygon, this label location provider first tries to find the largest sub-shape and then finds a location for this sub-shape.

This label location provider only calculates a single label location. So if this label overlaps with an other label, no alternative locations are available.

Unlike TLspInPathLabelingAlgorithm, this label location provider doesn't try to keep the label inside the view. When navigating away from the label location, no label location within the view bounds is calculated. Because of this, this labeling location provider works more efficiently CPU-wise.

The used label painter must be an ILspStampLocationLabelPainter. If not, the label will not be placed. The placed label location will be a ALspStampLabelLocation.

To use this label location provider to create a labeling algorithm, the following code can be used:


 TLspFixedInPathLabelLocationProvider provider = new TLspFixedInPathLabelLocationProvider();
 TLspLabelingAlgorithm algorithm = new TLspLabelingAlgorithm(provider);
 
Since:
2016.0
  • Constructor Details

    • TLspFixedInPathLabelLocationProvider

      public TLspFixedInPathLabelLocationProvider()
  • Method Details

    • getLocation

      public TLspLabelPlacement getLocation(TLspLabelID aLabel, int aLocationIndex, ALspLabelLocations aCurrentLabelLocations, TLspPaintState aPaintState, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView)
      Description copied from class: ALspLabelLocationProvider
      This method returns a location for the given label using the given location index. Override this method to create custom locations for a label.
      Specified by:
      getLocation in class ALspLabelLocationProvider
      Parameters:
      aLabel - a label.
      aLocationIndex - the location index.
      aCurrentLabelLocations - an ALspLabelLocations object containing locations for the currently placed labels.
      aPaintState - the paint state
      aLabelContext - provides context information, such as priorities, PaintState, ...
      aView - the view.
      Returns:
      the label location for the given label and index, or null if no location could be calculated.
    • isValidLocation

      public boolean isValidLocation(TLspLabelPlacement aLocation, ALspLabelLocations aCurrentLabelLocations, TLspPaintState aPaintState, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView)
      Description copied from class: ALspLabelLocationProvider
      Checks if the given location is a valid location. This check should be used if this label location provider is capable of producing the given location. Labeling algorithms may use this method for previous label locations. I.e. when using a previous label locations, this method can be used to verify if the previous label location can be used.

      By default, this method returns true.

      Overrides:
      isValidLocation in class ALspLabelLocationProvider
      Parameters:
      aLocation - the location to check.
      aCurrentLabelLocations - an ALspLabelLocations object containing locations for the currently placed labels.
      aPaintState - the paint state.
      aLabelContext - provides context information, such as priorities, PaintState, ...
      aView - the view.
      Returns:
      if the given location is a valid location.
    • toString

      public String toString()
      Overrides:
      toString in class Object