public class TLspFixedInPathLabelLocationProvider extends ALspLabelLocationProvider
This label location provider calculates a single location inside the anchor object of a label. For example for polygons, it calculates a location inside the polygon. For arc-bands, it calculates a location in between the start and end angle, and between the min and max radius. For some shapes it may use the focus point.
This algorithm works when the anchor object is an ILcdShape
. For the following shapes, there is extra
functionality to calculate a point inside the shape:
When the anchor object of the label is a composite shape, like an ILcdShapeList
or
ILcdComplexPolygon
, this label location provider first tries to find the largest sub-shape
and then finds a location for this sub-shape.
This label location provider only calculates a single label location. So if this label overlaps with an other label, no alternative locations are available.
Unlike TLspInPathLabelingAlgorithm
, this label location provider doesn't try to keep the label inside the
view. When navigating away from the label location, no label location within the view bounds is
calculated. Because of this, this labeling location provider works more efficiently CPU-wise.
The used label painter must be an ILspStampLocationLabelPainter
.
If not, the label will not be placed. The placed label location will be a
ALspStampLabelLocation
.
To use this label location provider to create a labeling algorithm, the following code can be used:
TLspFixedInPathLabelLocationProvider provider = new TLspFixedInPathLabelLocationProvider();
TLspLabelingAlgorithm algorithm = new TLspLabelingAlgorithm(provider);
Constructor and Description |
---|
TLspFixedInPathLabelLocationProvider() |
Modifier and Type | Method and Description |
---|---|
TLspLabelPlacement |
getLocation(TLspLabelID aLabel,
int aLocationIndex,
ALspLabelLocations aCurrentLabelLocations,
TLspPaintState aPaintState,
ILspLabelingAlgorithm.LabelContext aLabelContext,
ILspView aView)
This method returns a location for the given label using the given location index.
|
boolean |
isValidLocation(TLspLabelPlacement aLocation,
ALspLabelLocations aCurrentLabelLocations,
TLspPaintState aPaintState,
ILspLabelingAlgorithm.LabelContext aLabelContext,
ILspView aView)
Checks if the given location is a valid location.
|
String |
toString() |
getMaxLocationCount
public TLspFixedInPathLabelLocationProvider()
public TLspLabelPlacement getLocation(TLspLabelID aLabel, int aLocationIndex, ALspLabelLocations aCurrentLabelLocations, TLspPaintState aPaintState, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView)
ALspLabelLocationProvider
getLocation
in class ALspLabelLocationProvider
aLabel
- a label.aLocationIndex
- the location index.aCurrentLabelLocations
- an ALspLabelLocations object containing locations for the
currently placed labels.aPaintState
- the paint stateaLabelContext
- provides context information, such as priorities, PaintState, ...aView
- the view.null
if no location
could be calculated.public boolean isValidLocation(TLspLabelPlacement aLocation, ALspLabelLocations aCurrentLabelLocations, TLspPaintState aPaintState, ILspLabelingAlgorithm.LabelContext aLabelContext, ILspView aView)
ALspLabelLocationProvider
true
.isValidLocation
in class ALspLabelLocationProvider
aLocation
- the location to check.aCurrentLabelLocations
- an ALspLabelLocations object containing locations for the
currently placed labels.aPaintState
- the paint state.aLabelContext
- provides context information, such as priorities, PaintState, ...aView
- the view.