Class TLcdGXYCurvedPathLabelPainter
- All Implemented Interfaces:
ILcdPropertyChangeSource
,ILcdGXYLabelPainter
,ILcdGXYLabelPainter2
,ILcdGXYLabelPainterProvider
,ILcdGXYMultiLabelPainter
,Serializable
,Cloneable
TLcdGXYCurvedPathLabelLocation
is used.
Usually this is done by changing the layer's label locations. For a TLcdGXYLayer
,
this could be done as follows:
layer.setLabelLocations( new TLcdLabelLocations( layer, new TLcdGXYCurvedPathLabelLocation() ) );
The curved label location class describes an exact location on an ILcdAWTPath
.
It defines the following 3 fields:
TLcdGXYCurvedPathLabelLocation.getLocationIndex()</code> : should be <code>-1
.TLcdGXYCurvedPathLabelLocation.getSubPathIndex()
TLcdGXYCurvedPathLabelLocation.getAWTPathParameter()
TLcdGXYCurvedPathLabelingAlgorithm
can be used to place curved path labels. This labeling algorithm also works using
TLcdGXYCurvedPathLabelLocation
s, and fills in the 'sub path index' and
'awt path parameter' fields.
This label painter also supports fixed label placement (TLcdLabelLocation.getLocationIndex() >= 0)
).
In that case it drapes the label at the middle of the path (sub path index = 0 and awt path parameter = 0.5).
This allows this label painter to be used in combination with
TLcdGXYLabelPainterLocationLabelingAlgorithm
.
It also supports regular free placement, in case an invalid awt path parameter is used. I.e.
if the path parameter < 0
or > 1
and if TLcdLabelLocation.getLocationIndex() == -1
.
In that case, the label is placed as described by
TLcdLabelLocation.getRotation()
TLcdLabelLocation.getLocationX()
TLcdLabelLocation.getLocationY()
labelBoundsSFCT
method is customized using a wrapper or an extension
of this label painter, the labeling algorithm will not be able to use this information. So it
will work with other bounds than the one returned by the used label painter. This might cause
overlapping labels.- Since:
- 11.0
- See Also:
-
Field Summary
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
DEFAULT, SELECTED
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
-
Constructor Summary
ConstructorDescriptionCreates a newTLcdGXYCurvedPathLabelPainter
, usingTLcdGXYLabelingPathProvider
as path provider.TLcdGXYCurvedPathLabelPainter
(ILcdGXYLabelingPathProvider aPathProvider) Creates a newTLcdGXYCurvedPathLabelPainter
, using the given path provider. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) Adds aPropertyChangeListener
to this painter.void
Clears the entire label image cache.void
clearImageCache
(Object aObject) Clears the label image cache for the given object.clone()
Returns a new instance of thisALcdGXYLabelPainter
.double
Returns the extra spacing between each character.getFont()
Gets theFont
for drawing the labels.Gets the foreground color of the labels (text).getGXYLabelPainter
(Object aObject) Finds anILcdGXYLabelPainter
that can be used to label the object passed.Returns the algorithm that is used for rendering halo's.Returns the current halo color.int
Returns the current halo thickness.Returns the used path provider.int
getPossibleLocationCount
(Graphics aGraphics) Returns the number of possible locations where thisILcdGXYLabelPainter
can paint/draw the labels of the set domainObject
.Gets the selection color of a labelboolean
Returns true if the halo effect is on for the labels, false otherwise.boolean
isLabelTouched
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Tests if the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
is touched at view location(specified by aGXYContext.getX()
andaGXYContext.getY()
), considering the mode and theILcdGXYContext
instance.boolean
Returnstrue</code> when label image caching is enabled, <code>false
otherwise.void
labelAnchorPointSFCT
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) SetsaPointSFCT
to the anchor point of the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
.double
labelBoundsSFCT
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) Calculates the bounds of the label that can be painted.void
paintLabel
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Paints the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
onaGraphics
.void
removePropertyChangeListener
(PropertyChangeListener aPropertyChangeListener) Removes aPropertyChangeListener
from this painter.retrieveLabels
(Object aObject, int aLabelIndex, int aSubLabelIndex) This method should return the label text.void
setExtraCharacterSpacing
(double aExtraCharacterSpacing) Sets an extra spacing between each two characters in the label String.void
Sets theFont</code> for drawing the labels to <code>aFont
.void
setForeground
(Color aForegroundColor) Sets the color of the labels toaForegroundColor
.void
setHaloAlgorithm
(TLcdHaloAlgorithm aHaloAlgorithm) Sets the algorithm to be used for rendering halo's.void
setHaloColor
(Color aColor) Sets the color of the halo to be added around labels.void
setHaloEnabled
(boolean aHaloEnabled) Switches the halo effect for the labels on or off.void
setHaloThickness
(int aThickness) Sets the thickness (in pixels) of the halo to be added around labels.void
setSelectionColor
(Color aSelectionColor) Sets the selection color of a label to aSelectionColor.void
setUseImageCache
(boolean aUseCache) Sets whether or not labels with halos should be cached as images.Methods inherited from class com.luciad.view.gxy.ALcdGXYLabelPainter
firePropertyChangeEvent, getDisplayName, getLabelCount, getLabelCursor, getLabelIndex, getLabelLocation, getLocationIndex, getObject, getSubLabelCount, getSubLabelIndex, labelSnapTarget, setDisplayName, setLabelIndex, setLabelLocation, setLocationIndex, setObject, setSubLabelIndex, supportLabelSnap
-
Constructor Details
-
TLcdGXYCurvedPathLabelPainter
public TLcdGXYCurvedPathLabelPainter()Creates a newTLcdGXYCurvedPathLabelPainter
, usingTLcdGXYLabelingPathProvider
as path provider. -
TLcdGXYCurvedPathLabelPainter
Creates a newTLcdGXYCurvedPathLabelPainter
, using the given path provider.- Parameters:
aPathProvider
- a path provider.
-
-
Method Details
-
getPathProvider
Returns the used path provider.- Returns:
- the used path provider.
-
addPropertyChangeListener
Adds aPropertyChangeListener
to this painter.- Specified by:
addPropertyChangeListener
in interfaceILcdPropertyChangeSource
- Overrides:
addPropertyChangeListener
in classALcdGXYLabelPainter
- Parameters:
aPropertyChangeListener
- the receiver of property change events generated by this object- See Also:
-
removePropertyChangeListener
Removes aPropertyChangeListener
from this painter.- Specified by:
removePropertyChangeListener
in interfaceILcdPropertyChangeSource
- Overrides:
removePropertyChangeListener
in classALcdGXYLabelPainter
- Parameters:
aPropertyChangeListener
- the listener to be removed- See Also:
-
isHaloEnabled
public boolean isHaloEnabled()Returns true if the halo effect is on for the labels, false otherwise.- Returns:
- true if the halo effect is on, false otherwise
- See Also:
-
setHaloEnabled
public void setHaloEnabled(boolean aHaloEnabled) Switches the halo effect for the labels on or off.- Parameters:
aHaloEnabled
- true if halos should be added, false otherwise- See Also:
-
getHaloThickness
public int getHaloThickness()Returns the current halo thickness.- Returns:
- the current halo thickness
- See Also:
-
setHaloThickness
public void setHaloThickness(int aThickness) Sets the thickness (in pixels) of the halo to be added around labels.- Parameters:
aThickness
- the new halo thickness- See Also:
-
getHaloColor
Returns the current halo color.- Returns:
- the current halo color
- See Also:
-
setHaloColor
Sets the color of the halo to be added around labels.- Parameters:
aColor
- the new halo color- See Also:
-
setHaloAlgorithm
Sets the algorithm to be used for rendering halo's. The choice of the halo algorithm may have a major impact on the overall performance of this painter. SeeTLcdHaloAlgorithm
for more information on the available algorithms.- Parameters:
aHaloAlgorithm
- the algorithm to be used for rendering halo's.- See Also:
-
getHaloAlgorithm
Returns the algorithm that is used for rendering halo's.- Returns:
- the algorithm that is used for rendering halo's.
- See Also:
-
isUseImageCache
public boolean isUseImageCache()Returnstrue</code> when label image caching is enabled, <code>false
otherwise.- Returns:
true</code> when label image caching is enabled, <code>false
otherwise- See Also:
-
setUseImageCache
public void setUseImageCache(boolean aUseCache) Sets whether or not labels with halos should be cached as images.- Parameters:
aUseCache
- specifies whether image caching should be enabled- See Also:
-
clearImageCache
public void clearImageCache()Clears the entire label image cache. To remove the label cache from a single object, useclearImageCache(Object)
.- See Also:
-
clearImageCache
Clears the label image cache for the given object. The next time this object is painted, a new image will be created and cached for it. To remove all cached images in one go, useclearImageCache()
.- Parameters:
aObject
- the object for which the cache to be cleared.- See Also:
-
setFont
Sets theFont</code> for drawing the labels to <code>aFont
.- Parameters:
aFont
- the font to use to paint labels.- See Also:
-
getFont
Gets theFont
for drawing the labels. The default value is plain Dialog of size 10.- Returns:
- the font used to paint labels.
- See Also:
-
setForeground
Sets the color of the labels toaForegroundColor
.- Parameters:
aForegroundColor
- the color to be used to paint the labels foreground (text).- See Also:
-
getForeground
Gets the foreground color of the labels (text).- Returns:
- the foreground color of the labels (text).
- See Also:
-
setSelectionColor
Sets the selection color of a label to aSelectionColor.- Parameters:
aSelectionColor
- the color to use to paint labels for selected objects.- See Also:
-
getSelectionColor
Gets the selection color of a label- Returns:
- the selection color of a label.
- See Also:
-
getExtraCharacterSpacing
public double getExtraCharacterSpacing()Returns the extra spacing between each character.- Returns:
- the extra spacing between each character.
- See Also:
-
setExtraCharacterSpacing
public void setExtraCharacterSpacing(double aExtraCharacterSpacing) Sets an extra spacing between each two characters in the label String. The extra spacing is expressed in view coordinates (pixels). This value is0.0
by default.- Parameters:
aExtraCharacterSpacing
- the extra spacing between two characters in the label String.- See Also:
-
retrieveLabels
This method should return the label text. Override this method to return a custom string for a label.- Parameters:
aObject
- the labeled object.aLabelIndex
- the label index.aSubLabelIndex
- the sublabel index.- Returns:
- a String for the given label.
-
paintLabel
Description copied from interface:ILcdGXYLabelPainter2
Paints the label specified by
setObject
,setLabelIndex
andsetSubLabelIndex
onaGraphics
.aGXYContext
should contain theILcdGXYView
for which the label is painted andILcdGXYLayer
to which the object belongsThe implementation of this method shall define how to paint the specified label in the given mode, considering
aGXYContext
and the setTLcdLabelLocation
.The domain object, label index, sublabel index and the label location should be set before calling this method using the respective methods.
This interface extends the original contract of the paintLabel method to allow for more modes. Where in the super interface the mode could only be one of
ILcdGXYLabelPainter.DEFAULT
orILcdGXYLabelPainter.SELECTED
, the mode now can be a bitwise combination of several constants- Specified by:
paintLabel
in interfaceILcdGXYLabelPainter
- Specified by:
paintLabel
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination ofaGXYContext
- the drawing context for the label- See Also:
-
labelBoundsSFCT
public double labelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) throws TLcdNoBoundsException Description copied from interface:ILcdGXYLabelPainter2
Calculates the bounds of the label that can be painted. The bounds are set as a side effect in
aRectangleSFCT
, the orientation ofaRectangleSFCT
is returned as an angle.The bounds represent the upper left point of the label, and a width and a height. The rotation value represents the rotation of the label bounds around the upper left point.
The domain object, the label index, the sublabel index and the location of the label for which the bounds are retrieved should be set before calling this method using the respective methods.
Note that if this label painter is used in conjunction with a labeling algorithm, the bounds should preferably be independent of the location, as this will yield the best results.
- Specified by:
labelBoundsSFCT
in interfaceILcdGXYLabelPainter
- Specified by:
labelBoundsSFCT
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- theaGraphics
to consider.aMode
- the representation mode of the label.aGXYContext
- theILcdGXYContext
the drawing depends on.aRectangleSFCT
- theRectangle
containing the bounds of the label in view / graphics coordinates as side effect.- Returns:
- the angle orientation of the rectangle around the labels in RADIANs, clockwise, 0 at 3 o'clock.
- Throws:
TLcdNoBoundsException
- if the Object doesn't have any valid bounds, e.g. if it is always invisible in the current projection.- See Also:
-
isLabelTouched
Description copied from interface:ILcdGXYLabelPainter2
Tests if the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
is touched at view location(specified by aGXYContext.getX()
andaGXYContext.getY()
), considering the mode and theILcdGXYContext
instance.Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.
- Specified by:
isLabelTouched
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- the mode to consider. This is a bitwise combinations of several constants. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- theILcdGXYContext
to consider.- Returns:
- true if the representation of the Object returned by getObject() is touched, false otherwise
- See Also:
-
labelAnchorPointSFCT
public void labelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException Description copied from interface:ILcdGXYLabelPainter2
Sets
aPointSFCT
to the anchor point of the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
.If the location index is less than 0, the label anchor point is unambiguously determined by the
label location
. The actual label is to be painted somewhere around this anchor point. This method is typically called to compare the result with the label bounds, thus determining the exact relation between thelabel
and itslocation
.Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.
- Specified by:
labelAnchorPointSFCT
in interfaceILcdGXYLabelPainter2
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- The mode to consider. This can be a bitwise combination of several constants. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- TheILcdGXYContext
that can be used to retrieve extra information.aPointSFCT
- The point which will be updated to reflect the location of the anchor point.- Throws:
TLcdNoBoundsException
- if the Object doesn't have any valid anchor point, e.g. if it is always invisible in the current projection.- See Also:
-
getPossibleLocationCount
Description copied from interface:ILcdGXYLabelPainter
Returns the number of possible locations where thisILcdGXYLabelPainter
can paint/draw the labels of the set domainObject
.The domain
Object
for which the location count is retrieved should be set before calling this method using theILcdGXYLabelPainter.setObject(java.lang.Object)
method.- Specified by:
getPossibleLocationCount
in interfaceILcdGXYLabelPainter
- Parameters:
aGraphics
- the Graphics the label will be painted on.- Returns:
- the number of possible locations where this
ILcdGXYLabelPainter
can paint/draw the labels of the set Object. - See Also:
-
getGXYLabelPainter
Description copied from interface:ILcdGXYLabelPainterProvider
Finds anILcdGXYLabelPainter
that can be used to label the object passed.The label painter provider is responsible for setting the object to the label painter before returning the label painter. An implementation should therefore have the following structure:
public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject) { ILcdGXYLabelPainter labelPainter = ... // find the label painter for the object if (labelPainter != null) { labelPainter.setObject(aObject); } return labelPainter; }
- Specified by:
getGXYLabelPainter
in interfaceILcdGXYLabelPainterProvider
- Parameters:
aObject
- the object to find a label painter for- Returns:
- a label painter that can be used to label the object; or null if no label painter could be found for the given object, or the object could not be set on the retrieved label painter.
-
clone
Description copied from class:ALcdGXYLabelPainter
Returns a new instance of thisALcdGXYLabelPainter
. The label location of the clone is a clone of the label location of the original. No other objects are cloned.- Specified by:
clone
in interfaceILcdGXYLabelPainter
- Specified by:
clone
in interfaceILcdGXYLabelPainter2
- Specified by:
clone
in interfaceILcdGXYLabelPainterProvider
- Overrides:
clone
in classALcdGXYLabelPainter
- Returns:
- A new instance of this
ALcdGXYLabelPainter
of which the label location is a deep clone.
-