Class TLspLabelPlacer
- All Implemented Interfaces:
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 :
DEFAULT_DECLUTTER_GROUP
: this group is used by default for all layers and all their labels. No labels in this group can overlap.DEFAULT_NO_DECLUTTER_GROUP: this group can be used for labels that should always be shown, even if they overlap.
DEFAULT_GRID_GROUP
: this group is used for grid labels by default. Because this is a separate group, grid labels are decluttered amongst themselves, but they can still overlap with other labels.DEFAULT_REALTIME_GROUP
: this convenience group can be used when labeling dynamic data, for example tracks. This group allows them to be decluttered independently from static labels.
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.
- Since:
- 2012.0
-
Field Summary
-
Constructor Summary
ConstructorDescriptionTLspLabelPlacer
(ILspView aView) Creates a label placer with the four default groups already added :DEFAULT_DECLUTTER_GROUP
,DEFAULT_NO_DECLUTTER_GROUP
,DEFAULT_GRID_GROUP
andDEFAULT_REALTIME_GROUP
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLabelObstacleProvider
(String aPlacementGroupID, ILspLabelObstacleProvider aLabelObstacleProvider) Attaches an obstacle provider to a label group.void
addPlacementGroup
(String aPlacementGroupID, ILspLabelConflictChecker aConflictChecker) Adds a new group with the given settings to this placer.void
destroy()
Frees resources and tasks associated with this placer.Returns the label locations object.Returns a collection of all available placement groups.boolean
Indicates whether all calls toILspLabelPlacer.placeLabels()
are completely processed or not.void
Place the labels for the associated view.void
removeLabelObstacleProvider
(String aPlacementGroupID, ILspLabelObstacleProvider aLabelObstacleProvider) Detaches an obstacle provider from the group with the given id.void
removePlacementGroup
(String aPlacementGroupID) Removes a placement group from this placer.
-
Field Details
-
DEFAULT_DECLUTTER_GROUP
Default group for labels that should not overlap. This group is added to the placer by default.- See Also:
-
DEFAULT_NO_DECLUTTER_GROUP
Default group for labels that can overlap. This group is added to the placer by default.- See Also:
-
DEFAULT_GRID_GROUP
Default group for grid labels. This group is added to the placer by default.- See Also:
-
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
-
TLspLabelPlacer
Creates a label placer with the four default groups already added :DEFAULT_DECLUTTER_GROUP
,DEFAULT_NO_DECLUTTER_GROUP
,DEFAULT_GRID_GROUP
andDEFAULT_REALTIME_GROUP
.- Parameters:
aView
- The view this placer is used for
-
-
Method Details
-
addPlacementGroup
Adds a new group with the given settings to this placer. The given group id can be used to calladdLabelObstacleProvider(java.lang.String, com.luciad.view.lightspeed.label.ILspLabelObstacleProvider)
as well as in withALspLabelStyleCollector.group(String)
.Different groups are placed independently. So labels for two different groups may overlap.
- Parameters:
aPlacementGroupID
- a group identifier.aConflictChecker
- the group's conflict checker.
-
removePlacementGroup
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.
- Parameters:
aPlacementGroupID
- a group identifier.
-
getPlacementGroups
Returns a collection of all available placement groups.- Returns:
- 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.
- Parameters:
aPlacementGroupID
- the group id, seeaddPlacementGroup
.aLabelObstacleProvider
- the obstacle provider.
-
removeLabelObstacleProvider
public void removeLabelObstacleProvider(String aPlacementGroupID, ILspLabelObstacleProvider aLabelObstacleProvider) Detaches an obstacle provider from the group with the given id.- Parameters:
aPlacementGroupID
- the group id, seeaddPlacementGroup
.aLabelObstacleProvider
- the obstacle provider.
-
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 interfaceILspLabelPlacer
- Returns:
- 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 interfaceILspLabelPlacer
-
isFinished
public boolean isFinished()Indicates whether all calls toILspLabelPlacer.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 interfaceILspLabelPlacer
- Returns:
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 interfaceILspLabelPlacer
-