Class TLspDependentLabelsRemovalWrapper
- All Implemented Interfaces:
ILcdCloneable
,ILspLabelingAlgorithm
,Cloneable
It is also possible to define circular dependencies, e.g. representation 1 and representation 2 depend on each other. When representation 1 is removed, representation 2 is also removed, and vice versa.
This wrapper only supports dependencies between representations from the same object. Not respecting this will cause this wrapper to work incorrectly, i.e. representation that should disappear will not always disappear.
This wrapper works best when the labels returned by the label iterator of the delegate algorithm are ordered as follows :
- Clusters of labels should are kept together. If one representation of a representation cluster is returned, others should follow right after.
- Labels that depend on another label should be returned after it.
- Since:
- 2012.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.lightspeed.label.algorithm.ILspLabelingAlgorithm
ILspLabelingAlgorithm.LabelContext
-
Field Summary
Fields inherited from class com.luciad.view.lightspeed.label.algorithm.discrete.ALspDiscreteLabelingAlgorithm
CONSECUTIVE_LABEL_CONFLICT_FAIL_COUNT_KEY, CONSECUTIVE_LABEL_FAIL_COUNT_KEY, LABEL_ATTEMPT_COUNT_KEY, LABEL_CONFLICT_FAIL_COUNT_KEY, LABEL_FAIL_COUNT_KEY, LABEL_PLACED_COUNT_KEY, TOTAL_LABEL_COUNT_KEY
-
Constructor Summary
ConstructorDescriptionTLspDependentLabelsRemovalWrapper
(ALspDiscreteLabelingAlgorithm aDelegate, ILspLabelDependencyProvider aDependencyProvider) Creates a new wrapper for the given algorithm, with the given dependency provider. -
Method Summary
Modifier and TypeMethodDescriptionprotected Iterator
<TLspLabelID> createLabelIterator
(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Creates a newIterator
that iterates over theTLspLabelID
s.protected ILspLabelPlacementEvaluator
createLabelPlacementEvaluator
(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Creates a newILspLabelPlacementEvaluator
using the given parameters.Returns the dependency provider used to define the dependency relation between the representations.void
setDependencyProvider
(ILspLabelDependencyProvider aDependencyProvider) Sets the dependency provider used to define the dependency relation between the representations.Methods inherited from class com.luciad.view.lightspeed.label.algorithm.discrete.ALspDiscreteLabelingAlgorithmWrapper
createLabelPlacementIterator, getDelegate, getQuality, setQuality
Methods inherited from class com.luciad.view.lightspeed.label.algorithm.discrete.ALspDiscreteLabelingAlgorithm
clone, placeLabels
-
Constructor Details
-
TLspDependentLabelsRemovalWrapper
public TLspDependentLabelsRemovalWrapper(ALspDiscreteLabelingAlgorithm aDelegate, ILspLabelDependencyProvider aDependencyProvider) Creates a new wrapper for the given algorithm, with the given dependency provider. When callingILspLabelDependencyProvider.getDependingLabels
, the returned representations are those representations that depend on the given representation, i.e. if the given representation is removed, the returned representations 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 representations. When callingILspLabelDependencyProvider.getDependingLabels
, the returned representations are those representations that depend on the given representation, i.e. if the given representation is removed, the returned representations are also removed.- Returns:
- the dependency provider used to define the dependency relation between the representations.
-
setDependencyProvider
Sets the dependency provider used to define the dependency relation between the representations. When callingILspLabelDependencyProvider.getDependingLabels
, the returned representations are those representations that depend on the given representation, i.e. if the given representation is removed, the returned representations are also removed.- Parameters:
aDependencyProvider
- the dependency provider used to define the dependency relation between the representations.
-
createLabelIterator
protected Iterator<TLspLabelID> createLabelIterator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from class:ALspDiscreteLabelingAlgorithm
Creates a newIterator
that iterates over theTLspLabelID
s. The abstract algorithm will continue iterating overTLspLabelID
s as long asIterator.hasNext()
returnstrue
. When it returnsfalse
, no more label placements will be tried, andplaceLabels
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.Override this method to provide a custom implementation.
- Overrides:
createLabelIterator
in classALspDiscreteLabelingAlgorithmWrapper
- Parameters:
aLabels
- a list of labels that need to be placed.aLabelContext
- the label info object.aConflictChecker
- the conflict checker to be used when evaluating placements.aView
- the view.- Returns:
- a new
Iterator
that iterates overTLspLabelID
s.
-
createLabelPlacementEvaluator
protected ILspLabelPlacementEvaluator createLabelPlacementEvaluator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from class:ALspDiscreteLabelingAlgorithm
Creates a newILspLabelPlacementEvaluator
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 placement will be used for its label, it will be added to the list of placed representations, and it will be added to the givenILspLabelConflictChecker
. After that,ILspLabelPlacementEvaluator.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 givenILspLabelConflictChecker
. After that,ILspLabelPlacementEvaluator.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,ILspLabelPlacementEvaluator.noPlacementApplied
is called.PlacementResult.FAILED
: the abstract algorithm will immediately callILspLabelPlacementEvaluator.noPlacementApplied
and will not try to find other placements for the label.
Override this method to provide a custom implementation.
- Overrides:
createLabelPlacementEvaluator
in classALspDiscreteLabelingAlgorithmWrapper
- Parameters:
aLabels
- a list of labels.aLabelContext
- the label info object.aConflictChecker
- the conflict checker to be used when evaluating placements.aView
- the view- Returns:
- a new
ILspLabelPlacementEvaluator
. - See Also:
-