Class TLspCompositeLabelingAlgorithm
- All Implemented Interfaces:
ILcdCloneable
,ILspLabelingAlgorithm
,Cloneable
This composite labeling algorithm combines several ILspLabelingAlgorithm
s.
It works by assigning algorithms to labels using getAlgorithmProvider()
.
Labels that use the same algorithm are grouped, and then handled by it.
The order in which the algorithms are executed is determined by the sortAlgorithms
method. By default it sorts the algorithms based on the priorities of the view
representations that are placed by them. The highest priority of all of its labels
is assigned to each algorithm. The algorithms are then sorted based on this priority. When two
algorithms have the same priority assigned, the original order in which the algorithms are given
is respected.
The default order can be customized by overriding the sortAlgorithms
method.
- Since:
- 2012.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.view.lightspeed.label.algorithm.ILspLabelingAlgorithm
ILspLabelingAlgorithm.LabelContext
-
Constructor Summary
ConstructorDescriptionTLspCompositeLabelingAlgorithm
(ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> aAlgorithmProvider) Creates a composite labeling algorithm that uses the givenILspLabelingAlgorithmProvider
to assign algorithms to labels. -
Method Summary
Modifier and TypeMethodDescriptionclone()
MakesObject.clone()
public.Returns the used labeling algorithm provider.placeLabels
(List<TLspLabelID> aLabelIDs, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) protected List
<ILspLabelingAlgorithm> sortAlgorithms
(Map<ILspLabelingAlgorithm, List<TLspLabelID>> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView) This method sorts the givenList
of algorithms.
-
Constructor Details
-
TLspCompositeLabelingAlgorithm
public TLspCompositeLabelingAlgorithm(ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> aAlgorithmProvider) Creates a composite labeling algorithm that uses the givenILspLabelingAlgorithmProvider
to assign algorithms to labels.- Parameters:
aAlgorithmProvider
- a labeling algorithm provider that returns algorithms for a given label.
-
-
Method Details
-
getAlgorithmProvider
Returns the used labeling algorithm provider.- Returns:
- the used labeling algorithm provider.
-
sortAlgorithms
protected List<ILspLabelingAlgorithm> sortAlgorithms(Map<ILspLabelingAlgorithm, List<TLspLabelID>> aLabels, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView) This method sorts the given
List
of algorithms. The algorithms will be used in this order to place labels. The original order of the algorithms is determined by the order of the labels inaLabels
.The default implementation sorts the algorithms based on the priorities of the view representations that are placed by them. The highest priority of all of its representations is assigned to each algorithm. The labeling algorithms are then sorted based on this priority. When two algorithms have the same priority assigned, the original order in which the algorithms are given is respected.
Override this method to provide a custom placement order.
- Parameters:
aLabels
- a mapping of algorithms, and the labels placed by them.aLabelContext
- the label info object.aView
- the view.- Returns:
- the sorted
List
of algorithms.
-
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 classObject
- See Also:
-
placeLabels
public List<TLspLabelPlacement> placeLabels(List<TLspLabelID> aLabelIDs, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView) Description copied from interface:ILspLabelingAlgorithm
This method computes a list of label placements for the given
List
of labels. The returned label placements should contain a valid label location and label bounds. They should also point to their correspondingTLspLabelID
The returned
List
ofTLspLabelPlacement
s contains label placements that are either visible or invisible. When a placement is present in the list, it means that the location should be stored. When a placement in the list is marked as visible, it means that its location should be marked as visible in thelabel placer
- Specified by:
placeLabels
in interfaceILspLabelingAlgorithm
- Parameters:
aLabelIDs
- the labels to be placed.aLabelContext
- provides context information, such as priorities, PaintState, ...aConflictChecker
- the conflict checker that can be used to detect conflicts between labels.aView
- the view.- Returns:
- a list of label placements.
-