public class TLcdSLDLabelingAlgorithm extends TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
TLcdGXYCompositeLabelingAlgorithm
that computes label locations
for layers that have a TLcdSLDFeatureTypeStylePainter
as label painter.Constructor and Description |
---|
TLcdSLDLabelingAlgorithm()
Constructs a new labeling algorithm that prefers static labels over dynamic ones for non-curved labels
(see
TLcdSLDLabelingAlgorithm(boolean) ) and that enables label placement conflict resolution
(label decluttering). |
TLcdSLDLabelingAlgorithm(boolean aStaticLabels)
Constructs a new labeling algorithm with label placement conflict resolution (label decluttering) enabled
and with the given option to prefer static labels over dynamic ones.
|
TLcdSLDLabelingAlgorithm(boolean aStaticLabels,
boolean aConflictResolutionEnabled)
Constructs a new labeling algorithm with the given options to prefer static labels over dynamic ones for
non-curved labels and to enable label placement conflict resolution (label decluttering).
|
Modifier and Type | Method and Description |
---|---|
boolean |
canHandle(TLcdLabelIdentifier aLabel)
Returns if this algorithm can handle the given label.
|
TLcdCollectedLabelInfoList |
collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect,
Graphics aGraphics,
ILcdGXYView aGXYView)
This method returns a
TLcdCollectedLabelInfoList object based
on the given list of TLcdLabelIdentifier s. |
protected ILcdLabelPlacementEvaluator |
createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aCollectedLabelInfoList,
ILcdLabelConflictChecker aLabelConflictChecker,
ILcdGXYView aGXYView)
Creates a new
ILcdLabelPlacementEvaluator using the given parameters. |
protected TLcdSLDFeatureTypeStylePainter |
getFeatureTypeStylePainter(TLcdLabelIdentifier aLabel)
Returns the
TLcdSLDFeatureTypeStylePainter that is responsible for painting
the given label. |
clone, createLabelIterator, createLabelPlacementIterator, getLabelingAlgorithmProvider
computeLabelPlacements
public TLcdSLDLabelingAlgorithm()
TLcdSLDLabelingAlgorithm(boolean)
) and that enables label placement conflict resolution
(label decluttering).public TLcdSLDLabelingAlgorithm(boolean aStaticLabels)
aStaticLabels
- sets whether static labels are preferred over dynamic ones for non-curved labelspublic TLcdSLDLabelingAlgorithm(boolean aStaticLabels, boolean aConflictResolutionEnabled)
aStaticLabels
- sets whether static labels are preferred over dynamic ones for non-curved labelsaConflictResolutionEnabled
- sets whether label placement conflict resolution should be enabledpublic boolean canHandle(TLcdLabelIdentifier aLabel)
aLabel
- the label to handlepublic TLcdCollectedLabelInfoList collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView)
ILcdGXYLabelingAlgorithm
TLcdCollectedLabelInfoList
object based
on the given list of TLcdLabelIdentifier
s. 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.
collectLabelInfo
in interface ILcdGXYLabelingAlgorithm
collectLabelInfo
in class TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
aLabelsToCollect
- the labels for which a TLcdCollectedLabelInfoList
should
be created.aGraphics
- the graphics.aGXYView
- the view.TLcdCollectedLabelInfoList
which contains all the information needed to
place the labels.protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aCollectedLabelInfoList, ILcdLabelConflictChecker aLabelConflictChecker, ILcdGXYView aGXYView)
ALcdGXYDiscretePlacementsLabelingAlgorithm
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 :
PlacementResult.SUCCESS
:
the given label placement will be used for its label, it will be added to the list of placed
labels, and it will be added to the given ILcdLabelConflictChecker
. After that,
ILcdLabelPlacementEvaluator.placementApplied
will be called and no more placements are tried for the label.PlacementResult.FALLBACK
:
the abstract algorithm will try to find an other placements which returns
PlacementResult.SUCCESS
.
When no such placement is found, this placement will be added to the list of placed labels,
and it will be added to the given ILcdLabelConflictChecker
. After that,
ILcdLabelPlacementEvaluator.placementApplied
will be called.PlacementResult.TRY_NEW_PLACEMENT
:
the abstract algorithm will try to find an other placement which returns
PlacementResult.SUCCESS
or
PlacementResult.FALLBACK
.
When no such placement is found, ILcdLabelPlacementEvaluator.noPlacementApplied
is called.PlacementResult.FAILED
: the
abstract algorithm will immediately call ILcdLabelPlacementEvaluator.noPlacementApplied
and will not try to find other placements for the label.Override this method to provide a custom implementation.
createLabelPlacementEvaluator
in class TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
aCollectedLabelInfoList
- the info object that contains all information needed to place the labels.aLabelConflictChecker
- the bounds conflict checker to be used when evaluating label placements.aGXYView
- the viewILcdLabelPlacementEvaluator
protected TLcdSLDFeatureTypeStylePainter getFeatureTypeStylePainter(TLcdLabelIdentifier aLabel)
TLcdSLDFeatureTypeStylePainter
that is responsible for painting
the given label. If no such painter can be found, returns null
.aLabel
- the label