Package com.luciad.view.gxy
Class TLcdGXYLayerLabelPainter
java.lang.Object
com.luciad.view.gxy.TLcdGXYLayerLabelPainter
- All Implemented Interfaces:
ILcdCloneable,ILcdGXYLayerLabelPainter,Cloneable
public class TLcdGXYLayerLabelPainter
extends Object
implements ILcdGXYLayerLabelPainter, ILcdCloneable
A greedy layer label painter based on the label locations provided by
each label's
label painter.
It tries to place all labels one by one, and when a label cannot be placed without overlap, it
is omitted. If a sublabel of a label is dropped, all the sublabels of that label are dropped.
The user can control the quality versus the labeling speed through the
properties fineTuning, overLappingAllowed and allowedCluttering.
Note that this painter does not know of a layer's TLcdGXYLayer.setSelectionLabeled(boolean) property.
See setSelectionLabeled(boolean) instead.
For other labeling algorithms, see
ILcdGXYViewLabelPlacer.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TLcdGXYLayerLabelPainter.Qualitystatic final TLcdGXYLayerLabelPainter.QualityFields inherited from interface com.luciad.view.gxy.ILcdGXYLayerLabelPainter
ALL, SELECTION -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()RedefinesObject.cloneto make it public.doubleallowedClutteringdefines the fraction (a double located between 0 and 1 ) of the area (pixels) that the labels may occupy.intReturns the threshold priority for forced label painting.Returns theILcdGXYLabelPriorityProviderthat is used by this label painter.Returns the quality of the placement of the labels.voidInvalidate any stored information about label locations in order to recalculate the label positions.booleanfineTuning determines whether to apply fine grain (thus more time consuming) label placement algorithms.booleanDeprecated.Use a layer implementing ILcdGXYEditableLabelsLayer instead.booleanbooleansomewhatOverlapping determines whether the labels may overlap a bit, thus allowing for more labels to be placed.voidpaintLabel(Graphics aGraphics, ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, int aLayerLabelPainterMode) This method shall try to paint the labels of all the objects of all layers in the givenILcdGXYView, in the given mode aMode, considering the aGXYContext.voidsetAllowedCluttering(double aCluttering) allowedClutteringdefines the fraction (a double located between 0 and 1 ) of the area (pixels) that the labels may occupy.voidsetFineTuning(boolean aFineTune) fineTuning determines whether to apply fine grain (thus more time consuming) label placement algorithms.voidsetForcedPaintingThresholdPriority(int aPriority) Sets the threshold priority for forced label painting.voidsetLabelPriorityProvider(ILcdGXYLabelPriorityProvider aLabelPriorityProvider) Sets theILcdGXYLabelPriorityProviderto be used by this label painter.voidsetQuality(TLcdGXYLayerLabelPainter.Quality aQuality) Sets the quality of the algorithm to place the labels.voidsetReusePreviousLocation(boolean aReusePreviousLocation) Deprecated.Use a layer implementing ILcdGXYEditableLabelsLayer instead.voidsetSelectionLabeled(boolean aSelectionLabeled) selectionLabeled determines whether an object should be labeled anyhow.voidsetSomewhatOverlapping(boolean aOverlap) somewhatOverlapping determines whether the labels may overlap a bit, thus allowing for more labels to be placed.
-
Field Details
-
LOW
-
HIGH
-
-
Constructor Details
-
TLcdGXYLayerLabelPainter
public TLcdGXYLayerLabelPainter() -
TLcdGXYLayerLabelPainter
-
-
Method Details
-
getQuality
Returns the quality of the placement of the labels. Can be either LOW or HIGH.- Returns:
- the quality of the placement of the labels. Can be either LOW or HIGH.
- See Also:
-
setQuality
Sets the quality of the algorithm to place the labels. Accepted values are LOW and HIGH. The HIGH quality algorithm will place more labels without overlapping, while the LOW quality algorithm is faster. The default value is LOW.- Parameters:
aQuality- LOW or HIGH- See Also:
-
paintLabel
public void paintLabel(Graphics aGraphics, ILcdGXYLayer aGXYLayer, ILcdGXYView aGXYView, int aLayerLabelPainterMode) This method shall try to paint the labels of all the objects of all layers in the givenILcdGXYView, in the given mode aMode, considering the aGXYContext.- Specified by:
paintLabelin interfaceILcdGXYLayerLabelPainter- Parameters:
aGraphics- TheGraphicsinstance on which to paint the labels.aGXYLayer- The layer for which to paint the labels. If this layer is an instance ofILcdGXYEditableLabelsLayer, itsALcdLabelLocationsshould be informed of which labels have been drawn and which haven't.aGXYView- The view in which the layer is contained.aLayerLabelPainterMode- Determines which labels should be painted. Should be one ofILcdGXYLayerLabelPainter.ALLorILcdGXYLayerLabelPainter.SELECTION- See Also:
-
isFineTuning
public boolean isFineTuning()fineTuning determines whether to apply fine grain (thus more time consuming) label placement algorithms.- Returns:
trueif fineTuning istrue, elsefalseis returned.
-
setFineTuning
public void setFineTuning(boolean aFineTune) fineTuning determines whether to apply fine grain (thus more time consuming) label placement algorithms. Sets fineTuning to aFineTune. -
isSomewhatOverlapping
public boolean isSomewhatOverlapping()somewhatOverlapping determines whether the labels may overlap a bit, thus allowing for more labels to be placed. The amount of overlap depends on the width and the height of the label. It varies between a few percent to up to twenty percent of the surface of the label.- Returns:
trueif somewhatOverlapping istrue, elsefalseis returned.
-
setSomewhatOverlapping
public void setSomewhatOverlapping(boolean aOverlap) somewhatOverlapping determines whether the labels may overlap a bit, thus allowing for more labels to be placed. The amount of overlap depends on the width and the height of the label. It varies between a few percent to up to twenty percent of the surface of the label. Sets somewhatOverlapping to aOverlap. -
getAllowedCluttering
public double getAllowedCluttering()allowedClutteringdefines the fraction (a double located between 0 and 1 ) of the area (pixels) that the labels may occupy.allowedClutteringequal to zero means no labels may be drawn.allowedClutteringequal to one allows the view to be filled by labels.- Returns:
- allowedCluttering.
-
setAllowedCluttering
public void setAllowedCluttering(double aCluttering) allowedClutteringdefines the fraction (a double located between 0 and 1 ) of the area (pixels) that the labels may occupy.allowedClutteringequal to zero means no labels may be drawn.allowedClutteringequal to one allows the view to be filled by labels. SetsallowedClutteringto aCluttering. -
setReusePreviousLocation
public void setReusePreviousLocation(boolean aReusePreviousLocation) Deprecated.Use a layer implementing ILcdGXYEditableLabelsLayer instead. ALcdLabelLocations is more flexible and its default implementation automatically removes locations for removed objects.reusePreviousLocation determines whether the same relative location for a label should be used if there is one available. Note:previous locations are cached for objects, without reference to the objects model. Therefor if an object is removed from the model, the view label painter is not notified automatically. Use the methodinvalidate()to clear the cached positions of all objects.- Parameters:
aReusePreviousLocation- true to cache relative label position.- See Also:
-
isReusePreviousLocation
public boolean isReusePreviousLocation()Deprecated.Use a layer implementing ILcdGXYEditableLabelsLayer instead. ALcdLabelLocations is more flexible and its default implementation automatically removes locations for removed objects.Returns whether relative positions for labels were cached.- Returns:
- true if relative positions for labels were cached.
- See Also:
-
setSelectionLabeled
public void setSelectionLabeled(boolean aSelectionLabeled) selectionLabeled determines whether an object should be labeled anyhow. If false, an object will be labeled in selected mode only if it has a location in default mode. If true, a selected object will always be labeled even if this would cause overlap. should be used if there is one available. -
isSelectionLabeled
public boolean isSelectionLabeled()- See Also:
-
setLabelPriorityProvider
Sets theILcdGXYLabelPriorityProviderto be used by this label painter. Ifnull, no priorities will be used (default behavior).- Parameters:
aLabelPriorityProvider- theILcdGXYLabelPriorityProviderto be used.- See Also:
-
getLabelPriorityProvider
Returns theILcdGXYLabelPriorityProviderthat is used by this label painter.- Returns:
- the
ILcdGXYLabelPriorityProviderthat is used. - See Also:
-
setForcedPaintingThresholdPriority
public void setForcedPaintingThresholdPriority(int aPriority) Sets the threshold priority for forced label painting. The labels of objects with a priority value less than or equal to the threshold priority value will always be painted, even if the decluttering algorithm could not find any suitable place for the label. The default value is-1, in which case no forced painting is done.- Parameters:
aPriority- the threshold priority for forced label painting.- See Also:
-
getForcedPaintingThresholdPriority
public int getForcedPaintingThresholdPriority()Returns the threshold priority for forced label painting.- Returns:
- the threshold priority for forced label painting.
- See Also:
-
invalidate
public void invalidate()Invalidate any stored information about label locations in order to recalculate the label positions. To be used in cooperation with the propertyreusePreviousLocationif it is true. -
clone
Description copied from interface:ILcdGXYLayerLabelPainterRedefinesObject.cloneto make it public.- Specified by:
clonein interfaceILcdCloneable- Specified by:
clonein interfaceILcdGXYLayerLabelPainter- Overrides:
clonein classObject- See Also:
-