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
ConstructorsConstructorDescriptionConstructs 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 TypeMethodDescriptionbooleancanHandle(TLcdLabelIdentifier aLabel) Returns if this algorithm can handle the given label.collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView) This method returns aTLcdCollectedLabelInfoListobject based on the given list ofTLcdLabelIdentifiers.protected ILcdLabelPlacementEvaluatorcreateLabelPlacementEvaluator(TLcdCollectedLabelInfoList aCollectedLabelInfoList, ILcdLabelConflictChecker aLabelConflictChecker, ILcdGXYView aGXYView) Creates a newILcdLabelPlacementEvaluatorusing the given parameters.protected TLcdSLDFeatureTypeStylePainterReturns theTLcdSLDFeatureTypeStylePainterthat is responsible for painting the given label.Methods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
clone, createLabelIterator, createLabelPlacementIterator, getLabelingAlgorithmProviderMethods 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:ILcdGXYLabelingAlgorithmThis method returns aTLcdCollectedLabelInfoListobject based on the given list ofTLcdLabelIdentifiers. The returnedTLcdCollectedLabelInfoListshould contain aTLcdCollectedLabelInfoobject for each label that should be placed.Each
TLcdCollectedLabelInfoshould also contain all information needed bycomputeLabelPlacementsto 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
TLcdCollectedLabelInfoListdoesn't contain aTLcdCollectedLabelInfoobject for every givenTLcdLabelIdentifier. In that case the missing labels are not placed.- Specified by:
collectLabelInfoin interfaceILcdGXYLabelingAlgorithm- Overrides:
collectLabelInfoin classTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm- Parameters:
aLabelsToCollect- the labels for which aTLcdCollectedLabelInfoListshould be created.aGraphics- the graphics.aGXYView- the view.- Returns:
- a
TLcdCollectedLabelInfoListwhich contains all the information needed to place the labels.
-
createLabelPlacementEvaluator
protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aCollectedLabelInfoList, ILcdLabelConflictChecker aLabelConflictChecker, ILcdGXYView aGXYView) Description copied from class:ALcdGXYDiscretePlacementsLabelingAlgorithmCreates a newILcdLabelPlacementEvaluatorusing the given parameters. It evaluates the placements returned bycreateLabelPlacementIterator, and returns aPlacementResultto 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.placementAppliedwill 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.placementAppliedwill be called.PlacementResult.TRY_NEW_PLACEMENT: the abstract algorithm will try to find an other placement which returnsPlacementResult.SUCCESSorPlacementResult.FALLBACK. When no such placement is found,ILcdLabelPlacementEvaluator.noPlacementAppliedis called.PlacementResult.FAILED: the abstract algorithm will immediately callILcdLabelPlacementEvaluator.noPlacementAppliedand will not try to find other placements for the label.
Override this method to provide a custom implementation.
- Overrides:
createLabelPlacementEvaluatorin 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 theTLcdSLDFeatureTypeStylePainterthat 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
-