Class TLspLabelPlacer

All Implemented Interfaces:

public class TLspLabelPlacer extends Object implements ILspLabelPlacer

Default implementation of ILspLabelPlacer.

This label placer defines methods that can be used to configure a placer using groups. Groups can be added using addPlacementGroup. By default, four groups are already added :

This label placer does its work asynchronously using the ILspTaskExecutor. Calls to placeLabels() simply schedule a new placement cycle. Use isFinished() to determine if any placement is still ongoing or scheduled.

  • Field Details


      public static final String DEFAULT_DECLUTTER_GROUP
      Default group for labels that should not overlap. This group is added to the placer by default.
      See Also:

      public static final String DEFAULT_NO_DECLUTTER_GROUP
      Default group for labels that can overlap. This group is added to the placer by default.
      See Also:

      public static final String DEFAULT_GRID_GROUP
      Default group for grid labels. This group is added to the placer by default.
      See Also:

      public static final String DEFAULT_REALTIME_GROUP
      Default group for realtime labels. This group can for example be used for dynamic model, e.g. tracks. This group allows them to be decluttered independently from static labels. This group is added to the placer by default.
      See Also:
  • Constructor Details

  • Method Details

    • addPlacementGroup

      public void addPlacementGroup(String aPlacementGroupID, ILspLabelConflictChecker aConflictChecker)
      Adds a new group with the given settings to this placer. The given group id can be used to call addLabelObstacleProvider(java.lang.String, com.luciad.view.lightspeed.label.ILspLabelObstacleProvider) as well as in with

      Different groups are placed independently. So labels for two different groups may overlap.

      aPlacementGroupID - a group identifier.
      aConflictChecker - the group's conflict checker.
    • removePlacementGroup

      public void removePlacementGroup(String aPlacementGroupID)
      Removes a placement group from this placer.

      The group cannot be used afterwards. If the group is still used by any label, results are unspecified.

      aPlacementGroupID - a group identifier.
    • getPlacementGroups

      public Collection<String> getPlacementGroups()
      Returns a collection of all available placement groups.
      a collection of all available placement groups.
    • addLabelObstacleProvider

      public void addLabelObstacleProvider(String aPlacementGroupID, ILspLabelObstacleProvider aLabelObstacleProvider)
      Attaches an obstacle provider to a label group.

      The label placer will try not the place labels on the areas indicated by this provider.

      Note: you are responsible for de-registering the obstacle provider.

      aPlacementGroupID - the group id, see addPlacementGroup.
      aLabelObstacleProvider - the obstacle provider.
    • removeLabelObstacleProvider

      public void removeLabelObstacleProvider(String aPlacementGroupID, ILspLabelObstacleProvider aLabelObstacleProvider)
      Detaches an obstacle provider from the group with the given id.
      aPlacementGroupID - the group id, see addPlacementGroup.
      aLabelObstacleProvider - the obstacle provider.
    • getLabelLocations

      public ALspLabelLocations getLabelLocations()
      Description copied from interface: ILspLabelPlacer
      Returns the label locations object. This object contains all information on the locations of a label.
      Specified by:
      getLabelLocations in interface ILspLabelPlacer
      the label locations object.
    • destroy

      public void destroy()
      Frees resources and tasks associated with this placer. The placer must not be used anymore after this method has been called.

      Note: this call prevents additional placements from being scheduled, but does not abort running placements. Normally, a view will shut down its ILspTaskExecutor, which will stop any running placements.

      Specified by:
      destroy in interface ILspLabelPlacer
    • isFinished

      public boolean isFinished()
      Indicates whether all calls to ILspLabelPlacer.placeLabels() are completely processed or not.

      In particular, if any placement is ongoing asyncronously, or if any placement is queued for execution, this method returns false.

      Specified by:
      isFinished in interface ILspLabelPlacer
      true if there is no placement busy or scheduled, false otherwise.
    • placeLabels

      public void placeLabels()

      Place the labels for the associated view. In this method label placement and label decluttering can be performed.

      It is advised to perform the actual work asynchronously, and have this method simply schedule a placement cycle. This is not mandatory however.

      You can use ILspLabelPlacer.isFinished() at any time to determine if this call is completely processed.

      This call schedules a placement cycle for asynchronous execution. If this placer is already busy placing labels, a new placement step is scheduled.

      Specified by:
      placeLabels in interface ILspLabelPlacer