Class TLcdGXYDependantLabelsRemovalWrapper
- All Implemented Interfaces:
ILcdCloneable,ILcdGXYLabelingAlgorithm,Cloneable
It is also possible to define circular dependencies, e.g. label 1 and label 2 depend on each other. When label 1 is removed, label 2 is also removed, and vice versa.
This wrapper only supports dependencies between labels and sublabels from the same object. Not respecting this will cause this wrapper to perform worse, labels that should disappear will not always disappear.
This wrapper works best when the labels returned by the LabelIterator of the delegate algorithm are ordered as follows :
- Clusters of labels should are kept together. If one label of a label cluster is returned, others should follow right after.
- Labels that depend on another label should be returned after this label.
The implementation of this labeling algorithm is thread-safe if the wrapped labeling algorithm is thread safe.
- Since:
- 10.1
-
Constructor Summary
ConstructorsConstructorDescriptionTLcdGXYDependantLabelsRemovalWrapper(ALcdGXYDiscretePlacementsLabelingAlgorithm aDelegate, ILcdCollectedLabelInfoDependencyProvider aDependencyProvider) Creates a new wrapper for the given algorithm, with the given label dependency provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected Iterator<TLcdCollectedLabelInfo> createLabelIterator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Creates a newIteratorthat iterates over theTLcdCollectedLabelInfos.protected ILcdLabelPlacementEvaluatorcreateLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Creates a newILcdLabelPlacementEvaluatorusing the given parameters.Returns the dependency provider used to define the dependency relation between the labels.Methods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithmWrapper
clone, collectLabelInfo, createLabelPlacementIterator, getDelegateAlgorithmMethods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithm
computeLabelPlacements
-
Constructor Details
-
TLcdGXYDependantLabelsRemovalWrapper
public TLcdGXYDependantLabelsRemovalWrapper(ALcdGXYDiscretePlacementsLabelingAlgorithm aDelegate, ILcdCollectedLabelInfoDependencyProvider aDependencyProvider) Creates a new wrapper for the given algorithm, with the given label dependency provider. When callingILcdCollectedLabelInfoDependencyProvider.getDependingLabels, the returned labels are those labels that depend on the given label, i.e. if the given label is removed, the returned labels are also removed.- Parameters:
aDelegate- the delegate algorithm.aDependencyProvider- a dependency provider.
-
-
Method Details
-
getDependencyProvider
Returns the dependency provider used to define the dependency relation between the labels. When callingILcdCollectedLabelInfoDependencyProvider.getDependingLabels, the returned labels are those labels that depend on the given label, i.e. if the given label is removed, the returned labels are also removed.- Returns:
- the dependency provider used to define the dependency relation between the labels.
-
createLabelIterator
protected Iterator<TLcdCollectedLabelInfo> createLabelIterator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Description copied from class:ALcdGXYDiscretePlacementsLabelingAlgorithmCreates a newIteratorthat iterates over theTLcdCollectedLabelInfos. The abstract labeling algorithm will continue iterating overTLcdCollectedLabelInfos as long asIterator.hasNext()returnstrue. When it returnsfalse, no more labels will be tried, andcomputeLabelPlacementsreturns.Iterator.hasNext()should always be called before callingIterator.next(), and if it returnstrue,Iterator.next()should never returnnull.The implementation of this method should be as independent as possible. It should not rely on
createLabelPlacementIteratororcreateLabelPlacementEvaluator. Not respecting this might result in unexpected behaviour when wrapping or extending this class.The returned
TLcdCollectedLabelInfoshould be correctly initialized, i.e. it should contain all information needed to create validTLcdLabelPlacements usingcreateLabelPlacementIterator. It should also always point to its correspondingTLcdCollectedLabeledObjectInfo.Override this method to provide a custom implementation.
- Overrides:
createLabelIteratorin classALcdGXYDiscretePlacementsLabelingAlgorithmWrapper- Parameters:
aLabelInfoList- the label infos object that contains all information needed to place the labels.aBoundsConflictChecker- the bounds conflict checker to be used when evaluating label placements.aView- the view.- Returns:
- a new
Iteratorthat iterates overTLcdCollectedLabelInfos.
-
createLabelPlacementEvaluator
protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) 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 classALcdGXYDiscretePlacementsLabelingAlgorithmWrapper- Parameters:
aLabelInfoList- the info object that contains all information needed to place the labels.aBoundsConflictChecker- the bounds conflict checker to be used when evaluating label placements.aView- the view- Returns:
- a new LabelPlacementEvaluator
- See Also:
-