public class TLcdGXYDependantLabelsRemovalWrapper extends ALcdGXYDiscretePlacementsLabelingAlgorithmWrapper
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 :
The implementation of this labeling algorithm is thread-safe if the wrapped labeling algorithm is thread safe.
Constructor and Description |
---|
TLcdGXYDependantLabelsRemovalWrapper(ALcdGXYDiscretePlacementsLabelingAlgorithm aDelegate,
ILcdCollectedLabelInfoDependencyProvider aDependencyProvider)
Creates a new wrapper for the given algorithm, with the given label dependency provider.
|
Modifier and Type | Method and Description |
---|---|
protected Iterator<TLcdCollectedLabelInfo> |
createLabelIterator(TLcdCollectedLabelInfoList aLabelInfoList,
ILcdLabelConflictChecker aBoundsConflictChecker,
ILcdGXYView aView)
Creates a new
Iterator that iterates over the TLcdCollectedLabelInfo s. |
protected ILcdLabelPlacementEvaluator |
createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList,
ILcdLabelConflictChecker aBoundsConflictChecker,
ILcdGXYView aView)
Creates a new
ILcdLabelPlacementEvaluator using the given parameters. |
ILcdCollectedLabelInfoDependencyProvider |
getDependencyProvider()
Returns the dependency provider used to define the dependency relation between the labels.
|
clone, collectLabelInfo, createLabelPlacementIterator, getDelegateAlgorithm
computeLabelPlacements
public TLcdGXYDependantLabelsRemovalWrapper(ALcdGXYDiscretePlacementsLabelingAlgorithm aDelegate, ILcdCollectedLabelInfoDependencyProvider aDependencyProvider)
ILcdCollectedLabelInfoDependencyProvider.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.aDelegate
- the delegate algorithm.aDependencyProvider
- a dependency provider.public ILcdCollectedLabelInfoDependencyProvider getDependencyProvider()
ILcdCollectedLabelInfoDependencyProvider.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.protected Iterator<TLcdCollectedLabelInfo> createLabelIterator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView)
ALcdGXYDiscretePlacementsLabelingAlgorithm
Iterator
that iterates over the TLcdCollectedLabelInfo
s.
The abstract labeling algorithm will continue iterating over TLcdCollectedLabelInfo
s
as long as Iterator.hasNext()
returns true
. When it returns false
,
no more labels will be tried, and computeLabelPlacements
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.
The returned TLcdCollectedLabelInfo
should be correctly initialized, i.e. it should
contain all information needed to create valid TLcdLabelPlacement
s using
createLabelPlacementIterator
. It should also always point
to its corresponding TLcdCollectedLabeledObjectInfo
.
Override this method to provide a custom implementation.
createLabelIterator
in class ALcdGXYDiscretePlacementsLabelingAlgorithmWrapper
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.Iterator
that iterates over TLcdCollectedLabelInfo
s.protected ILcdLabelPlacementEvaluator createLabelPlacementEvaluator(TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView)
ALcdGXYDiscretePlacementsLabelingAlgorithm
ILcdLabelPlacementEvaluator
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 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 given ILcdLabelConflictChecker
. 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 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 ILcdLabelConflictChecker
. After that,
ILcdLabelPlacementEvaluator.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, ILcdLabelPlacementEvaluator.noPlacementApplied
is called.PlacementResult.FAILED
: the
abstract algorithm will immediately call ILcdLabelPlacementEvaluator.noPlacementApplied
and will not try to find other placements for the label.Override this method to provide a custom implementation.
createLabelPlacementEvaluator
in class ALcdGXYDiscretePlacementsLabelingAlgorithmWrapper
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 viewILcdLabelPlacementEvaluator