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
TLcdGXYCurvedPathLabelLocations, 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, SELECTEDFields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newTLcdGXYCurvedPathLabelPainter, usingTLcdGXYLabelingPathProvideras path provider.TLcdGXYCurvedPathLabelPainter(ILcdGXYLabelingPathProvider aPathProvider) Creates a newTLcdGXYCurvedPathLabelPainter, using the given path provider. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Adds aPropertyChangeListenerto this painter.voidClears the entire label image cache.voidclearImageCache(Object aObject) Clears the label image cache for the given object.clone()Returns a new instance of thisALcdGXYLabelPainter.doubleReturns the extra spacing between each character.getFont()Gets theFontfor drawing the labels.Gets the foreground color of the labels (text).getGXYLabelPainter(Object aObject) Finds anILcdGXYLabelPainterthat can be used to label the object passed.Returns the algorithm that is used for rendering halo's.Returns the current halo color.intReturns the current halo thickness.Returns the used path provider.intgetPossibleLocationCount(Graphics aGraphics) Returns the number of possible locations where thisILcdGXYLabelPaintercan paint/draw the labels of the set domainObject.Gets the selection color of a labelbooleanReturns true if the halo effect is on for the labels, false otherwise.booleanisLabelTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Tests if the label specified bysetObject,setLabelIndexandsetSubLabelIndexis touched at view location(specified by aGXYContext.getX()andaGXYContext.getY()), considering the mode and theILcdGXYContextinstance.booleanReturnstrue</code> when label image caching is enabled, <code>falseotherwise.voidlabelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) SetsaPointSFCTto the anchor point of the label specified bysetObject,setLabelIndexandsetSubLabelIndex.doublelabelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) Calculates the bounds of the label that can be painted.voidpaintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Paints the label specified bysetObject,setLabelIndexandsetSubLabelIndexonaGraphics.voidremovePropertyChangeListener(PropertyChangeListener aPropertyChangeListener) Removes aPropertyChangeListenerfrom this painter.retrieveLabels(Object aObject, int aLabelIndex, int aSubLabelIndex) This method should return the label text.voidsetExtraCharacterSpacing(double aExtraCharacterSpacing) Sets an extra spacing between each two characters in the label String.voidSets theFont</code> for drawing the labels to <code>aFont.voidsetForeground(Color aForegroundColor) Sets the color of the labels toaForegroundColor.voidsetHaloAlgorithm(TLcdHaloAlgorithm aHaloAlgorithm) Sets the algorithm to be used for rendering halo's.voidsetHaloColor(Color aColor) Sets the color of the halo to be added around labels.voidsetHaloEnabled(boolean aHaloEnabled) Switches the halo effect for the labels on or off.voidsetHaloThickness(int aThickness) Sets the thickness (in pixels) of the halo to be added around labels.voidsetSelectionColor(Color aSelectionColor) Sets the selection color of a label to aSelectionColor.voidsetUseImageCache(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, usingTLcdGXYLabelingPathProvideras 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 aPropertyChangeListenerto this painter.- Specified by:
addPropertyChangeListenerin interfaceILcdPropertyChangeSource- Overrides:
addPropertyChangeListenerin classALcdGXYLabelPainter- Parameters:
aPropertyChangeListener- the receiver of property change events generated by this object- See Also:
-
removePropertyChangeListener
Removes aPropertyChangeListenerfrom this painter.- Specified by:
removePropertyChangeListenerin interfaceILcdPropertyChangeSource- Overrides:
removePropertyChangeListenerin 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. SeeTLcdHaloAlgorithmfor 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>falseotherwise.- Returns:
true</code> when label image caching is enabled, <code>falseotherwise- 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 theFontfor 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.0by 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:ILcdGXYLabelPainter2Paints the label specified by
setObject,setLabelIndexandsetSubLabelIndexonaGraphics.aGXYContextshould contain theILcdGXYViewfor which the label is painted andILcdGXYLayerto which the object belongsThe implementation of this method shall define how to paint the specified label in the given mode, considering
aGXYContextand 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.DEFAULTorILcdGXYLabelPainter.SELECTED, the mode now can be a bitwise combination of several constants- Specified by:
paintLabelin interfaceILcdGXYLabelPainter- Specified by:
paintLabelin 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:ILcdGXYLabelPainter2Calculates the bounds of the label that can be painted. The bounds are set as a side effect in
aRectangleSFCT, the orientation ofaRectangleSFCTis 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:
labelBoundsSFCTin interfaceILcdGXYLabelPainter- Specified by:
labelBoundsSFCTin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- theaGraphicsto consider.aMode- the representation mode of the label.aGXYContext- theILcdGXYContextthe drawing depends on.aRectangleSFCT- theRectanglecontaining 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:ILcdGXYLabelPainter2Tests if the label specified bysetObject,setLabelIndexandsetSubLabelIndexis touched at view location(specified by aGXYContext.getX()andaGXYContext.getY()), considering the mode and theILcdGXYContextinstance.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:
isLabelTouchedin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- TheGraphicsinstance 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- theILcdGXYContextto 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:ILcdGXYLabelPainter2Sets
aPointSFCTto the anchor point of the label specified bysetObject,setLabelIndexandsetSubLabelIndex.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 thelabeland 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:
labelAnchorPointSFCTin interfaceILcdGXYLabelPainter2- Parameters:
aGraphics- TheGraphicsinstance 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- TheILcdGXYContextthat 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:ILcdGXYLabelPainterReturns the number of possible locations where thisILcdGXYLabelPaintercan paint/draw the labels of the set domainObject.The domain
Objectfor which the location count is retrieved should be set before calling this method using theILcdGXYLabelPainter.setObject(java.lang.Object)method.- Specified by:
getPossibleLocationCountin interfaceILcdGXYLabelPainter- Parameters:
aGraphics- the Graphics the label will be painted on.- Returns:
- the number of possible locations where this
ILcdGXYLabelPaintercan paint/draw the labels of the set Object. - See Also:
-
getGXYLabelPainter
Description copied from interface:ILcdGXYLabelPainterProviderFinds anILcdGXYLabelPainterthat 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:
getGXYLabelPainterin 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:ALcdGXYLabelPainterReturns 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:
clonein interfaceILcdGXYLabelPainter- Specified by:
clonein interfaceILcdGXYLabelPainter2- Specified by:
clonein interfaceILcdGXYLabelPainterProvider- Overrides:
clonein classALcdGXYLabelPainter- Returns:
- A new instance of this
ALcdGXYLabelPainterof which the label location is a deep clone.
-