public class TLspDependentLabelsRemovalWrapper extends ALspDiscreteLabelingAlgorithmWrapper
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 :
ILspLabelingAlgorithm.LabelContext
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 and Description |
---|
TLspDependentLabelsRemovalWrapper(ALspDiscreteLabelingAlgorithm aDelegate,
ILspLabelDependencyProvider aDependencyProvider)
Creates a new wrapper for the given algorithm, with the given dependency provider.
|
Modifier and Type | Method and Description |
---|---|
protected Iterator<TLspLabelID> |
createLabelIterator(List<TLspLabelID> aLabels,
ILspLabelingAlgorithm.LabelContext aLabelContext,
ILspLabelConflictChecker aConflictChecker,
ILspView aView)
Creates a new
Iterator that iterates over the TLspLabelID s. |
protected ILspLabelPlacementEvaluator |
createLabelPlacementEvaluator(List<TLspLabelID> aLabels,
ILspLabelingAlgorithm.LabelContext aLabelContext,
ILspLabelConflictChecker aConflictChecker,
ILspView aView)
Creates a new
ILspLabelPlacementEvaluator using the given parameters. |
ILspLabelDependencyProvider |
getDependencyProvider()
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.
|
createLabelPlacementIterator, getDelegate, getQuality, setQuality
clone, placeLabels
public TLspDependentLabelsRemovalWrapper(ALspDiscreteLabelingAlgorithm aDelegate, ILspLabelDependencyProvider aDependencyProvider)
ILspLabelDependencyProvider.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.aDelegate
- the delegate algorithm.aDependencyProvider
- a dependency provider.public ILspLabelDependencyProvider getDependencyProvider()
ILspLabelDependencyProvider.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.public void setDependencyProvider(ILspLabelDependencyProvider aDependencyProvider)
ILspLabelDependencyProvider.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.aDependencyProvider
- the dependency provider used to define the dependency relation
between the representations.protected Iterator<TLspLabelID> createLabelIterator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView)
ALspDiscreteLabelingAlgorithm
Iterator
that iterates over the TLspLabelID
s. The abstract algorithm will continue
iterating over TLspLabelID
s as long as Iterator.hasNext()
returns true
. When it returns false
, no more label placements will be
tried, and placeLabels
returns. Iterator.hasNext()
should always be called before
calling Iterator.next()
, and if it returns true
, Iterator.next()
should never return null
. The implementation of
this method should be as independent as possible. It should not rely on createLabelPlacementIterator
or createLabelPlacementEvaluator
. Not respecting this might result
in unexpected behaviour when wrapping or extending this class.
Override this method to provide a custom implementation.
createLabelIterator
in class ALspDiscreteLabelingAlgorithmWrapper
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.Iterator
that iterates over TLspLabelID
s.protected ILspLabelPlacementEvaluator createLabelPlacementEvaluator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView)
ALspDiscreteLabelingAlgorithm
ILspLabelPlacementEvaluator
using the given parameters. It evaluates
the placements returned by createLabelPlacementIterator
,
and returns a PlacementResult
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 given ILspLabelConflictChecker
. 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 returns PlacementResult.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 given ILspLabelConflictChecker
. After that, ILspLabelPlacementEvaluator.placementApplied
will
be called.PlacementResult.TRY_NEW_PLACEMENT
: the abstract algorithm will try to find an other placement
which returns PlacementResult.SUCCESS
or PlacementResult.FALLBACK
. When no such placement is found, ILspLabelPlacementEvaluator.noPlacementApplied
is called.PlacementResult.FAILED
: the abstract algorithm will immediately call ILspLabelPlacementEvaluator.noPlacementApplied
and will not try to find other placements for the label.Override this method to provide a custom implementation.
createLabelPlacementEvaluator
in class ALspDiscreteLabelingAlgorithmWrapper
aLabels
- a list of labels.aLabelContext
- the label info object.aConflictChecker
- the conflict checker to be used when evaluating placements.aView
- the viewILspLabelPlacementEvaluator
.ILspLabelPlacementEvaluator