Class ALspDiscreteLabelingAlgorithmWrapper
- All Implemented Interfaces:
ILcdCloneable,ILspLabelingAlgorithm,Cloneable
- Direct Known Subclasses:
TLspDependentLabelsRemovalWrapper
This class can be used to create a labeling algorithm wrapper based on the
ALspDiscreteLabelingAlgorithm abstract algorithm.
When using this wrapper, the 'create' methods should be implemented by creating an
iterator or evaluator using the delegate algorithm, and returning a wrapped iterator of
evaluator.
- 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
ConstructorsConstructorDescriptionCreates a new algorithm wrapper wrapping the given discrete labeling algorithm. -
Method Summary
Modifier and TypeMethodDescriptionprotected Iterator<TLspLabelID> createLabelIterator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Creates a newIteratorthat iterates over theTLspLabelIDs.protected ILspLabelPlacementEvaluatorcreateLabelPlacementEvaluator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Creates a newILspLabelPlacementEvaluatorusing the given parameters.protected Iterator<TLspLabelPlacement> createLabelPlacementIterator(TLspLabelID aLabel, ALspLabelLocations aCurrentLabelLocations, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Creates a newIteratorthat iterates over theTLspLabelPlacements for the given label.Returns the wrapped algorithm.doubleReturns the quality setting.voidsetQuality(double aQuality) Sets the quality.Methods inherited from class com.luciad.view.lightspeed.label.algorithm.discrete.ALspDiscreteLabelingAlgorithm
clone, placeLabels
-
Constructor Details
-
ALspDiscreteLabelingAlgorithmWrapper
Creates a new algorithm wrapper wrapping the given discrete labeling algorithm.- Parameters:
aDelegate- a delegate labeling algorithm.
-
-
Method Details
-
getDelegate
Returns the wrapped algorithm.- Returns:
- the wrapped algorithm.
-
setQuality
public void setQuality(double aQuality) Description copied from class:ALspDiscreteLabelingAlgorithmSets the quality. If the quality setting is high, the algorithm will try to place more labels. If it is low, the algorithm will only try to place a small portion of the labels, making label placement faster. Setting the quality to e.g.
0.5can dramatically improve the label placement performance in some cases.E.g. it is possible that due to the quality setting, this algorithm will only try to place 10% of the labels. This may still result in high quality results, but this depends on the used data. In general, using a lower quality setting will still work well when the data (and its labels) are distributed uniformly over the screen.
By default, the quality is set to
1.0.- Specified by:
setQualityin classALspDiscreteLabelingAlgorithm- Parameters:
aQuality- the new quality. This is a number in [0, 1].- See Also:
-
getQuality
public double getQuality()Description copied from class:ALspDiscreteLabelingAlgorithmReturns the quality setting.- Specified by:
getQualityin classALspDiscreteLabelingAlgorithm- Returns:
- the quality setting.
- See Also:
-
createLabelIterator
protected Iterator<TLspLabelID> createLabelIterator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from class:ALspDiscreteLabelingAlgorithmCreates a newIteratorthat iterates over theTLspLabelIDs. The abstract algorithm will continue iterating overTLspLabelIDs as long asIterator.hasNext()returnstrue. When it returnsfalse, no more label placements will be tried, andplaceLabelsreturns.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
createLabelPlacementIteratororcreateLabelPlacementEvaluator. Not respecting this might result in unexpected behaviour when wrapping or extending this class.Override this method to provide a custom implementation.
- Specified by:
createLabelIteratorin classALspDiscreteLabelingAlgorithm- 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
Iteratorthat iterates overTLspLabelIDs.
-
createLabelPlacementIterator
protected Iterator<TLspLabelPlacement> createLabelPlacementIterator(TLspLabelID aLabel, ALspLabelLocations aCurrentLabelLocations, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from class:ALspDiscreteLabelingAlgorithmCreates a newIteratorthat iterates over theTLspLabelPlacements for the given label. The abstract algorithm will continue iterating overTLspLabelPlacements 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
createLabelIteratororcreateLabelPlacementEvaluator. Not respecting this might result in unexpected behaviour when wrapping or extending this class.The returned
TLspLabelPlacementshould be correctly initialized, that is it should at least be able to return a valid label location, bounds rectangle and bounds rotation. It should also reference its correspondingTLspLabelID.Override this method to provide a custom implementation.
- Specified by:
createLabelPlacementIteratorin classALspDiscreteLabelingAlgorithm- Parameters:
aLabel- the identifier for which an iterator should be created.aCurrentLabelLocations- an ALspLabelLocations object containing locations for the currently placed labels.aLabelContext- the label info object.aConflictChecker- the conflict checker to be used when evaluating placements.aView- the view.- Returns:
- a new
Iteratorthat iterates overTLspLabelPlacements.
-
createLabelPlacementEvaluator
protected ILspLabelPlacementEvaluator createLabelPlacementEvaluator(List<TLspLabelID> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from class:ALspDiscreteLabelingAlgorithmCreates a newILspLabelPlacementEvaluatorusing the given parameters. It evaluates the placements returned bycreateLabelPlacementIterator, and returns aPlacementResultto 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.placementAppliedwill 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.placementAppliedwill be called.PlacementResult.TRY_NEW_PLACEMENT: the abstract algorithm will try to find an other placement which returnsPlacementResult.SUCCESSorPlacementResult.FALLBACK. When no such placement is found,ILspLabelPlacementEvaluator.noPlacementAppliedis called.PlacementResult.FAILED: the abstract algorithm will immediately callILspLabelPlacementEvaluator.noPlacementAppliedand will not try to find other placements for the label.
Override this method to provide a custom implementation.
- Specified by:
createLabelPlacementEvaluatorin classALspDiscreteLabelingAlgorithm- 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:
-