Package com.luciad.ogc.sld.view.gxy
Class TLcdSLDLabelingAlgorithm
java.lang.Object
com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithm
com.luciad.view.gxy.labeling.algorithm.discrete.TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
com.luciad.ogc.sld.view.gxy.TLcdSLDLabelingAlgorithm
- All Implemented Interfaces:
ILcdCloneable
,ILcdGXYLabelingAlgorithm
,Cloneable
Extension of
TLcdGXYCompositeLabelingAlgorithm
that computes label locations
for layers that have a TLcdSLDFeatureTypeStylePainter
as label painter.- Since:
- 11.0
-
Constructor Summary
ConstructorDescriptionConstructs a new labeling algorithm that prefers static labels over dynamic ones for non-curved labels (seeTLcdSLDLabelingAlgorithm(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). -
Method Summary
Modifier and TypeMethodDescriptionboolean
canHandle
(TLcdLabelIdentifier aLabel) Returns if this algorithm can handle the given label.collectLabelInfo
(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView) This method returns aTLcdCollectedLabelInfoList
object based on the given list ofTLcdLabelIdentifier
s.protected ILcdLabelPlacementEvaluator
createLabelPlacementEvaluator
(TLcdCollectedLabelInfoList aCollectedLabelInfoList, ILcdLabelConflictChecker aLabelConflictChecker, ILcdGXYView aGXYView) Creates a newILcdLabelPlacementEvaluator
using the given parameters.protected TLcdSLDFeatureTypeStylePainter
Returns theTLcdSLDFeatureTypeStylePainter
that is responsible for painting the given label.Methods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
clone, createLabelIterator, createLabelPlacementIterator, getLabelingAlgorithmProvider
Methods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithm
computeLabelPlacements
-
Constructor Details
-
TLcdSLDLabelingAlgorithm
public TLcdSLDLabelingAlgorithm()Constructs a new labeling algorithm that prefers static labels over dynamic ones for non-curved labels (seeTLcdSLDLabelingAlgorithm(boolean)
) and that enables label placement conflict resolution (label decluttering). -
TLcdSLDLabelingAlgorithm
public 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. Static labels are labels that don't move during navigation or due to decluttering. This is for example useful for cases where you need consistent consistent label positions over multiple repaints, such as in a (Tiled) WMS or WMTS server implementation. An exception is made for curved labels, for which the placement is always dynamic: their target use case is the labeling of paths (like streets, rivers ...), which benefits from dynamic placement to optimize the label readability and to support label repeating.- Parameters:
aStaticLabels
- sets whether static labels are preferred over dynamic ones for non-curved labels- Since:
- 2017.0
-
TLcdSLDLabelingAlgorithm
public 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).- Parameters:
aStaticLabels
- sets whether static labels are preferred over dynamic ones for non-curved labelsaConflictResolutionEnabled
- sets whether label placement conflict resolution should be enabled- Since:
- 2021.0
-
-
Method Details
-
canHandle
Returns if this algorithm can handle the given label. Returns true if a TLcdSLDFeatureTypeStylePainter is used as label painter for the layer of the given label.- Parameters:
aLabel
- the label to handle- Returns:
- if this algorithm can handle the label
-
collectLabelInfo
public TLcdCollectedLabelInfoList collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView) Description copied from interface:ILcdGXYLabelingAlgorithm
This method returns aTLcdCollectedLabelInfoList
object based on the given list ofTLcdLabelIdentifier
s. The returnedTLcdCollectedLabelInfoList
should contain aTLcdCollectedLabelInfo
object for each label that should be placed.Each
TLcdCollectedLabelInfo
should also contain all information needed bycomputeLabelPlacements
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 aTLcdCollectedLabelInfo
object for every givenTLcdLabelIdentifier
. In that case the missing labels are not placed.- Specified by:
collectLabelInfo
in interfaceILcdGXYLabelingAlgorithm
- Overrides:
collectLabelInfo
in classTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
- Parameters:
aLabelsToCollect
- the labels for which aTLcdCollectedLabelInfoList
should be created.aGraphics
- the graphics.aGXYView
- the view.- Returns:
- a
TLcdCollectedLabelInfoList
which contains all the information needed to place the labels.
-
createLabelPlacementEvaluator
protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aCollectedLabelInfoList, ILcdLabelConflictChecker aLabelConflictChecker, ILcdGXYView aGXYView) Description copied from class:ALcdGXYDiscretePlacementsLabelingAlgorithm
Creates a newILcdLabelPlacementEvaluator
using the given parameters. It evaluates the placements returned bycreateLabelPlacementIterator
, and returns aPlacementResult
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 givenILcdLabelConflictChecker
. 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 returnsPlacementResult.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 givenILcdLabelConflictChecker
. After that,ILcdLabelPlacementEvaluator.placementApplied
will be called.PlacementResult.TRY_NEW_PLACEMENT
: the abstract algorithm will try to find an other placement which returnsPlacementResult.SUCCESS
orPlacementResult.FALLBACK
. When no such placement is found,ILcdLabelPlacementEvaluator.noPlacementApplied
is called.PlacementResult.FAILED
: the abstract algorithm will immediately callILcdLabelPlacementEvaluator.noPlacementApplied
and will not try to find other placements for the label.
Override this method to provide a custom implementation.
- Overrides:
createLabelPlacementEvaluator
in classTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
- Parameters:
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 view- Returns:
- a new LabelPlacementEvaluator
- See Also:
-
getFeatureTypeStylePainter
Returns theTLcdSLDFeatureTypeStylePainter
that is responsible for painting the given label. If no such painter can be found, returnsnull
.- Parameters:
aLabel
- the label- Returns:
- the feature type style painter for the given label
-