public class TLspCompositeLabelingAlgorithm extends Object implements ILspLabelingAlgorithm
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.
ILspLabelingAlgorithm.LabelContext
Constructor and Description |
---|
TLspCompositeLabelingAlgorithm(ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> aAlgorithmProvider)
Creates a composite labeling algorithm that uses the given
ILspLabelingAlgorithmProvider to assign algorithms to labels. |
Modifier and Type | Method and Description |
---|---|
TLspCompositeLabelingAlgorithm |
clone()
Makes
Object.clone() public. |
ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> |
getAlgorithmProvider()
Returns the used labeling algorithm provider.
|
List<TLspLabelPlacement> |
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 given
List of algorithms. |
public TLspCompositeLabelingAlgorithm(ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> aAlgorithmProvider)
ILspLabelingAlgorithmProvider
to assign algorithms to labels.aAlgorithmProvider
- a labeling algorithm provider that returns algorithms for a
given label.public ILspLabelingAlgorithmProvider<ILspLabelingAlgorithm> getAlgorithmProvider()
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 in aLabels
.
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.
aLabels
- a mapping of algorithms, and the labels placed
by them.aLabelContext
- the label info object.aView
- the view.List
of algorithms.public TLspCompositeLabelingAlgorithm clone()
ILcdCloneable
Makes Object.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 );
}
}
clone
in interface ILcdCloneable
clone
in class Object
Object.clone()
public List<TLspLabelPlacement> placeLabels(List<TLspLabelID> aLabelIDs, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspLabelConflictChecker aConflictChecker, ILspView aView)
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 corresponding TLspLabelID
The returned List
of TLspLabelPlacement
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 the
label placer
placeLabels
in interface ILspLabelingAlgorithm
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.