Class TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
- All Implemented Interfaces:
ILcdCloneable
,ILcdGXYLabelingAlgorithm
,Cloneable
- Direct Known Subclasses:
TLcdSLDLabelingAlgorithm
ALcdGXYDiscretePlacementsLabelingAlgorithm
s
into one labeling algorithm.
The difference with TLcdGXYCompositeLabelingAlgorithm
is that although multiple algorithms are combined, this composite labeling algorithm respects the original
label order as given TLcdCollectedLabelInfoList.getLabels()
.
Labels will be decluttered in this order, provided that the delegate labeling algorithms respect
the order in which they receive the labels.
This composite labeling algorithm uses a ILcdGXYLabelLabelingAlgorithmProvider
to
assign labeling algorithms to labels. It works by creating a composite label iterator
using createLabelIterator
for each algorithm. It also does
this using createLabelPlacementIterator
and
createLabelPlacementEvaluator
.
The implementation of this labeling algorithm is thread-safe as long as the set labeling algorithm provider is thread-safe.
- Since:
- 10.1
-
Constructor Summary
ConstructorDescriptionTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
(ILcdGXYLabelLabelingAlgorithmProvider<? extends ALcdGXYDiscretePlacementsLabelingAlgorithm> aAlgorithmProvider) Creates a newTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
using the given labeling algorithm provider. -
Method Summary
Modifier and TypeMethodDescriptionclone()
MakesObject.clone()
public.collectLabelInfo
(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView) This method returns aTLcdCollectedLabelInfoList
object based on the given list ofTLcdLabelIdentifier
s.protected 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.protected Iterator
<TLcdLabelPlacement> createLabelPlacementIterator
(TLcdCollectedLabelInfo aLabel, TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Creates a newIterator
that iterates over theTLcdLabelPlacement
s for the given label.Returns the used labeling algorithm provider.Methods inherited from class com.luciad.view.gxy.labeling.algorithm.discrete.ALcdGXYDiscretePlacementsLabelingAlgorithm
computeLabelPlacements
-
Constructor Details
-
TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
public TLcdGXYCompositeDiscretePlacementsLabelingAlgorithm(ILcdGXYLabelLabelingAlgorithmProvider<? extends ALcdGXYDiscretePlacementsLabelingAlgorithm> aAlgorithmProvider) Creates a newTLcdGXYCompositeDiscretePlacementsLabelingAlgorithm
using the given labeling algorithm provider.- Parameters:
aAlgorithmProvider
- a given labeling algorithm provider.
-
-
Method Details
-
getLabelingAlgorithmProvider
public ILcdGXYLabelLabelingAlgorithmProvider<? extends ALcdGXYDiscretePlacementsLabelingAlgorithm> getLabelingAlgorithmProvider()Returns the used labeling algorithm provider.- Returns:
- the used labeling algorithm provider.
-
clone
Description copied from interface:ILcdCloneable
Makes
When for example extending fromObject.clone()
public.java.lang.Object
, it can be implemented like this:public Object clone() { try { return super.clone(); } catch ( CloneNotSupportedException e ) { // Cannot happen: extends from Object and implements Cloneable (see also Object.clone) throw new RuntimeException( e ); } }
- Specified by:
clone
in interfaceILcdCloneable
- Overrides:
clone
in classALcdGXYDiscretePlacementsLabelingAlgorithm
- See Also:
-
collectLabelInfo
public TLcdCollectedLabelInfoList collectLabelInfo(List<TLcdLabelIdentifier> aLabelsToCollect, Graphics aGraphics, ILcdGXYView aGXYView) Description copied from interface:ILcdGXYLabelingAlgorithm
This method returns aTLcdCollectedLabelInfoList
object based on the given list ofTLcdLabelIdentifier
s. The returnedTLcdCollectedLabelInfoList
should contain aTLcdCollectedLabelInfo
object for each label that should be placed.Each
TLcdCollectedLabelInfo
should also contain all information needed bycomputeLabelPlacements
to place the labels. In order to enable correct asynchronous label placing, all calls to the layer and the (label) painters should be done in this method. The results should then be stored in the info objects.It is possible that the returned
TLcdCollectedLabelInfoList
doesn't contain aTLcdCollectedLabelInfo
object for every givenTLcdLabelIdentifier
. In that case the missing labels are not placed.- Specified by:
collectLabelInfo
in interfaceILcdGXYLabelingAlgorithm
- Overrides:
collectLabelInfo
in classALcdGXYDiscretePlacementsLabelingAlgorithm
- Parameters:
aLabelsToCollect
- the labels for which aTLcdCollectedLabelInfoList
should be created.aGraphics
- the graphics.aGXYView
- the view.- Returns:
- a
TLcdCollectedLabelInfoList
which contains all the information needed to place 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.
- Specified by:
createLabelIterator
in classALcdGXYDiscretePlacementsLabelingAlgorithm
- 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.
-
createLabelPlacementIterator
protected Iterator<TLcdLabelPlacement> createLabelPlacementIterator(TLcdCollectedLabelInfo aLabel, TLcdCollectedLabelInfoList aLabelInfoList, ILcdLabelConflictChecker aBoundsConflictChecker, ILcdGXYView aView) Description copied from class:ALcdGXYDiscretePlacementsLabelingAlgorithm
Creates a newIterator
that iterates over theTLcdLabelPlacement
s for the given label. The abstract labeling algorithm will continue iterating overTLcdLabelPlacement
s as long asIterator.hasNext()
returnstrue
. When it returnsfalse
, a new label will be tried.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
createLabelIterator
orcreateLabelPlacementEvaluator
. Not respecting this might result in unexpected behaviour when wrapping or extending this class.The returned
TLcdLabelPlacement
should be correctly initialized, i.e. it should at least be able to return a valid label location, bounds rectangle and bounds rotation. It should also reference its correspondingTLcdCollectedLabelInfo
.Override this method to provide a custom implementation.
- Specified by:
createLabelPlacementIterator
in classALcdGXYDiscretePlacementsLabelingAlgorithm
- Parameters:
aLabel
- the label for which an iterator should be created.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
Iterator
that iterates overTLcdLabelPlacement
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.
- Specified by:
createLabelPlacementEvaluator
in classALcdGXYDiscretePlacementsLabelingAlgorithm
- 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:
-