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
ConstructorDescriptionTLcdGXYDependantLabelsRemovalWrapper
(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 newIterator
that iterates over theTLcdCollectedLabelInfo
s.protected ILcdLabelPlacementEvaluator
createLabelPlacementEvaluator
(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Creates a newILcdLabelPlacementEvaluator
using 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, getDelegateAlgorithm
Methods 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:ALcdGXYDiscretePlacementsLabelingAlgorithm
Creates a newIterator
that iterates over theTLcdCollectedLabelInfo
s. The abstract labeling algorithm will continue iterating overTLcdCollectedLabelInfo
s as long asIterator.hasNext()
returnstrue
. When it returnsfalse
, no more labels will be tried, andcomputeLabelPlacements
returns.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
createLabelPlacementIterator
orcreateLabelPlacementEvaluator
. Not respecting this might result in unexpected behaviour when wrapping or extending this class.The returned
TLcdCollectedLabelInfo
should be correctly initialized, i.e. it should contain all information needed to create validTLcdLabelPlacement
s usingcreateLabelPlacementIterator
. It should also always point to its correspondingTLcdCollectedLabeledObjectInfo
.Override this method to provide a custom implementation.
- Overrides:
createLabelIterator
in 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
Iterator
that iterates overTLcdCollectedLabelInfo
s.
-
createLabelPlacementEvaluator
protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) 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 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:
-