Class TLcdGXYPolylineLabelPainter
- All Implemented Interfaces:
ILcdPropertyChangeSource
,ILcdGXYLabelEditor
,ILcdGXYLabelEditorProvider
,ILcdGXYLabelPainter
,ILcdGXYLabelPainter2
,ILcdGXYLabelPainterProvider
,ILcdGXYMultiLabelPainter
,Serializable
,Cloneable
- Direct Known Subclasses:
TLcdGXYDataObjectPolylineLabelPainter
,TLcdGXYFeaturedPolylineLabelPainter
,TLcdGXYOutlinePolylineLabelPainter
,TLcdMagneticNorthGXYLabelPainter
TLcdGXYPolylineStampLabelPainter
that displays a point list's toString() method as a text label.
The text to display can be customized by overriding retrieveLabels(int, com.luciad.view.gxy.ILcdGXYContext)
.
The text rendering can be configured in the following ways:
font
- colors:
foreground color
,background color
, andselection color
. filled background
and/orframe
vertical spacing
It is recommended to instead use
TLcdGXYOnPathLabelingAlgorithm
in combination with a general label painter (e.g. TLcdGXYLabelPainter
),
because labeling algorithms offer better placement behavior and more customization options.
- See Also:
-
Field Summary
Fields inherited from class com.luciad.view.gxy.TLcdGXYPolylineStampLabelPainter
ABOVE, BELOW, CENTER, TRACEON
Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelEditor
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
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
ConstructorDescriptionConstruct a default polyline label painter.TLcdGXYPolylineLabelPainter
(TLcdGXYPolylineLabelPainter aGXYLabelPainter) -
Method Summary
Modifier and TypeMethodDescriptionboolean
acceptSnapTargetForLabel
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
accepts the snap target in the givenILcdGXYContext
.protected void
addComponentToGXYView
(ILcdGXYView aGXYView, Component aComponent) Adds the specified interactive label to the user interface.protected int
calculateMaxLabelWidth
(String[] aLabelArray, Graphics aGraphics) Calculates the maximum width for a label when painting the given String objects in the given array on the given Graphics object.protected boolean
canAddComponentToGXYView
(ILcdGXYView aGXYView) Returns whether or not an interactive label can be added to the given view.void
Cancels the interactive label, if there is one.boolean
Returns whether or not the label interaction can be stopped.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
.boolean
editLabel
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Adapts the setTLcdLabelLocation
according to the information present in aGXYContext.protected void
firePropertyChangeEvent
(PropertyChangeEvent aPropertyChangeEvent) Notifies the registeredPropertyChangeListener
s of the specified event.Returns the color of the label frames filling.protected Component
getComponentForGXYView
(ILcdGXYView aGXYView) Gets the component that represents the givenILcdGXYView
.This default implementation returns the display name set withsetDisplayName
, ortoString()
if this was set tonull
.Returns the domain object for the interactive label, ornull
if there is no interactive label.getFont()
Returns theFont
for drawing the labels.Returns the foreground color of the labels (text).Returns the line color of the frame surrounding the labels.int
Returns the line width of the frame surrounding the labels.Returns the interactive label provider.getGXYLabelEditor
(Object aObject) Returns a validILcdGXYLabelEditor
for editing the labels of aObject.getGXYLabelPainter
(Object aObject) Finds anILcdGXYLabelPainter
that can be used to label the object passed.Returns theALcdGXYLabelStamp
that is used by this painter to paint the labels.Returns the algorithm that is used for rendering halo's.Returns the current halo color.Returns the current halo pin color.int
Returns the current halo thickness.int
Returns the number of points required to initialize the label of the setObject
.getLabelCursor
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.Returns the alignment of the lines in the label.int
Returns the amount of padding used around the text.Returns the color in which the pin is drawn.Returns the color in which the pin should be drawn of the label of a selected object.Returns the label text color for selected object's labels.int
Returns the vertical spacing in between a label's lines.final boolean
Returns if anti-aliasing is enabled.boolean
isFilled()
Returns whether to surround labels with a filled background.boolean
isFrame()
Returns whether to surround labels with a frame.boolean
Returns true if the halo effect is on for the labels, false otherwise.boolean
Returns true if the halo effect also includes the pin.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
Returns whether the labels this editor edits are made sticky.boolean
Returnstrue
when image caching for labels with a halo is enabled,false
otherwise.boolean
Returns whether to draw an anchor point atanchorPointSFCT
.boolean
Returns whether a pin is drawn from the object to the label.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.double
labelBoundsSFCT
(Graphics aGraphics, String[] aLabelArray, ILcdPointList aPointList, int aMode, Rectangle aRectangleSFCT, ILcdGXYContext aGXYContext) Deprecated.labelSnapTarget
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns anObject
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents.void
paintLabel
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Paints the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
onaGraphics
.void
paintLabels
(String[] aLabelArray, ILcdPointList aPolygon, Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Deprecated.usepaintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
in combination withsetObject(java.lang.Object)
instead.protected void
paintPin
(Graphics aGraphics, int aMode, int aStartPointX, int aStartPointY, int aEndPointX, int aEndPointY) Draws a label pin on the given graphics between the given lines.protected boolean
pinPointSFCT
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aAnchorPoint, Rectangle aLabelBounds, double aRotation, Point aPinPointSFCT) Determines where the pin attaches to the label.protected void
removeComponentFromGXYView
(ILcdGXYView aGXYView, Component aComponent) Removes the specifiedjava.awt.Component
from the user interface.protected String[]
retrieveLabels
(int aMode, ILcdGXYContext aGXYContext) Returns an array containing the lines of text for a single label.protected String[]
retrieveLabels
(ILcdGXYContext aGXYContext) Deprecated.replaced byretrieveLabels(int, ILcdGXYContext)
protected ILcdPointList
Retrieves a list of points between which it is possible to draw a label for the Object of thisTLcdGXYPolylineLabelPainter
.final void
setAntiAliased
(boolean aAntiAliased) Enable or disable anti-aliasing.void
setBackground
(Color aBackgroundColor) Sets the color of the label frames filling toaBackgroundColor
.static void
setClassTraceOn
(boolean aClassTraceOn) Deprecated.This method has been deprecated.void
setFilled
(boolean aFilled) Sets whether to surround labels with a filled background.void
Sets theFont
for drawing the labels toaFont
.void
setForeground
(Color aForegroundColor) Sets the color of the labels toaForegroundColor
.void
setFrame
(boolean aFramed) Sets whether or not to surround the labels with a frame.void
setFrameColor
(Color aFrameColor) Sets the line color of the frame surrounding the labels toaFrameColor
.void
setFrameLineWidth
(int aFrameWidth) Sets the line width of the frame surrounding the labels toaFrameWidth
.void
setGXYInteractiveLabelProvider
(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Deprecated.this is controller logic.void
setGXYLabelStamp
(ALcdGXYLabelStamp aGXYLabelStamp) Overridden to throw anUnsupportedOperationException
.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
setHaloPinColor
(Color aColor) Sets the color of the halo to be added around pins.void
setHaloPinEnabled
(boolean aHaloPinEnabled) Sets if the halo effect should be applied to the pin.void
setHaloThickness
(int aThickness) Sets the thickness (in pixels) of the halo to be added around labels.void
setLabelIndex
(int aLabelIndex) Sets the label.void
setLabelTextAlignmentMode
(ELcdHorizontalAlignment aAlignment) Sets the alignment of the lines in the label.void
setMakeLabelsStickyOnEdit
(boolean aMakeLabelsStickyOnEdit) Sets whether or not this editor should set the label edit mode of the edited labels to include the sticky flag.void
Sets the Object to be labeled by this ILcdGXYLabelPainter.void
setPadding
(int aPadding) Sets the amount of padding around the label text, in pixels.void
setPinColor
(Color aPinColor) Sets the color in which the pin should be drawn.void
setProvideInteractiveLabelOnMouseOver
(boolean aProvideInteractiveLabelOnMouseOver) Deprecated.this is controller logic.void
setSelectedPinColor
(Color aSelectedPinColor) Sets the color in which the pin of the label of a selected label should be drawn.void
setSelectionColor
(Color aSelectionColor) Sets the text label color for selected objects.void
setSubLabelIndex
(int aSubLabelIndex) Sets the sublabel index.void
setUseImageCache
(boolean aUseCache) Sets whether or not labels with halos should be cached as images.void
setVerticalSpacing
(int aVerticalSpacing) Sets the vertical distance in between a label's lines.void
setWithAnchorPoint
(boolean aWithAnchorPoint) Determines whether to draw an anchor point atanchorPointSFCT
.void
setWithPin
(boolean aWithPin) The propertywithPin
determines whether a pin should be drawn from the object to the label.void
startLabelInteraction
(Object aDomainObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) Configure an interactive label for the specified label and show it in the GUI.boolean
Stops the interactive label, if there is one.Methods inherited from class com.luciad.view.gxy.TLcdGXYPolylineStampLabelPainter
anchorPointSFCT, calculateLabelSegment, getAlignment, getMaxNumberPossibilities, getPossibleLocationCount, getPossibleLocationCount, getVGap, indexSegmentFirstPoint, isLabelOnPath, isPaintCache, isRotationAllowed, labelPositionForLocationIndexSFCT, setAlignment, setLabelOnPath, setMaxNumberPossibilities, setPaintCache, setRotationAllowed, setVGap
Methods inherited from class com.luciad.view.gxy.ALcdGXYLabelPainter
addPropertyChangeListener, getLabelCount, getLabelIndex, getLabelLocation, getLocationIndex, getObject, getSubLabelCount, getSubLabelIndex, removePropertyChangeListener, setDisplayName, setLabelLocation, setLocationIndex, supportLabelSnap
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelEditor
getLabelCount, getLabelIndex, getLabelLocation, getObject, getSubLabelCount, getSubLabelIndex, setLabelLocation
Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
getLocationIndex, getObject, setLocationIndex
Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter2
getLabelLocation, setLabelLocation, supportLabelSnap
Methods inherited from interface com.luciad.view.gxy.ILcdGXYMultiLabelPainter
getLabelCount, getLabelIndex, getSubLabelCount, getSubLabelIndex
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Constructor Details
-
TLcdGXYPolylineLabelPainter
public TLcdGXYPolylineLabelPainter()Construct a default polyline label painter. The labels created are black in a plain dialog font. -
TLcdGXYPolylineLabelPainter
-
-
Method Details
-
setAntiAliased
public final void setAntiAliased(boolean aAntiAliased) Enable or disable anti-aliasing. By default, anti-aliasing is enabled.
When activated, anti-aliasing will be applied on both the labels and the pins.
See also
ILcdGXYView.isAntiAliased()
.- Parameters:
aAntiAliased
- true to enable anti-aliasing.- Since:
- 2016.1
- See Also:
-
isAntiAliased
public final boolean isAntiAliased()Returns if anti-aliasing is enabled.- Returns:
- if anti-aliasing is enabled.
- Since:
- 2016.1
- See Also:
-
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 interfaceILcdGXYLabelEditor
- Specified by:
clone
in interfaceILcdGXYLabelEditorProvider
- Specified by:
clone
in interfaceILcdGXYLabelPainter
- Specified by:
clone
in interfaceILcdGXYLabelPainter2
- Specified by:
clone
in interfaceILcdGXYLabelPainterProvider
- Overrides:
clone
in classTLcdGXYPolylineStampLabelPainter
- Returns:
- A new instance of this
ALcdGXYLabelPainter
of which the label location is a deep clone.
-
retrievePointList
Retrieves a list of points between which it is possible to draw a label for the Object of thisTLcdGXYPolylineLabelPainter
. This method is called within thepaintLabel
method. This implementation checks for the following interfaces:- ILcdDataObject with an associated geometry property: the
ILcdShape
geometry is retrieved - ILcdShapeList: the first object is taken
ILcdPointList
. Re-define this method for getting aILcdPointList
by other means.- Overrides:
retrievePointList
in classTLcdGXYPolylineStampLabelPainter
- Returns:
- the object set to this label painter as a
ILcdPointList
- ILcdDataObject with an associated geometry property: the
-
retrieveLabels
Returns an array containing the lines of text for a single label.
This method is called to retrieve the actual label text. Each array element is treated as a line of the label defined by
setObject
,setLabelIndex
andsetSubLabelIndex
. If this method returns null or a zero-length array, no label will be painted.A text line can contain HTML commands if its content is surrounded by an
<html>
tag.By default, this method calls
retrieveLabels(com.luciad.view.gxy.ILcdGXYContext)
, which returns a single line of text (i.e. an array of oneString
) containinggetObject().toString()
, or null if the object has an empty toString() result. Override this method to return other text. Never modify the content of the returned array.This method is only called for the label painter's supported label and sublabel indices. Override the
getLabelCount
and/orgetSubLabelCount
methods if you want to define multiple labels per domain object.- Parameters:
aMode
- the label painting modeaGXYContext
- the context in which the labels should be painted- Returns:
- the set of String objects to be used as label for this object, depending on the mode.
-
retrieveLabels
Deprecated.replaced byretrieveLabels(int, ILcdGXYContext)
- Parameters:
aGXYContext
- the context in which the labels should be painted.- Returns:
- an array of length 1, containing the String representation of the object (see
Object.toString()
. - See Also:
-
setObject
Description copied from interface:ILcdGXYLabelPainter2
Sets the Object to be labeled by this ILcdGXYLabelPainter.Setting the object should set the
TLcdLabelLocation
tonull
, to ensure that older code which has not been adapted to this new interface keeps working.- Specified by:
setObject
in interfaceILcdGXYLabelEditor
- Specified by:
setObject
in interfaceILcdGXYLabelPainter
- Specified by:
setObject
in interfaceILcdGXYLabelPainter2
- Overrides:
setObject
in classALcdGXYLabelPainter
- Parameters:
aObject
- The object to be labeled.- See Also:
-
setLabelIndex
public void setLabelIndex(int aLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainter
Sets the label. The results of any subsequent method calls to
ILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
andILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
etc. will apply to the label and sublabel indicated by this label index.- Specified by:
setLabelIndex
in interfaceILcdGXYLabelEditor
- Specified by:
setLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Overrides:
setLabelIndex
in classALcdGXYLabelPainter
- Parameters:
aLabelIndex
- The label index. This should be larger than or equal to0
and less than the resultILcdGXYMultiLabelPainter.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext)
.- See Also:
-
setSubLabelIndex
public void setSubLabelIndex(int aSubLabelIndex) Description copied from interface:ILcdGXYMultiLabelPainter
Sets the sublabel index. The results of any subsequent method calls toILcdGXYLabelPainter.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
andILcdGXYLabelPainter.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
etc. will apply to the label and sublabel indicated by this sublabel index.- Specified by:
setSubLabelIndex
in interfaceILcdGXYLabelEditor
- Specified by:
setSubLabelIndex
in interfaceILcdGXYMultiLabelPainter
- Overrides:
setSubLabelIndex
in classALcdGXYLabelPainter
- Parameters:
aSubLabelIndex
- The sub label index. This should be larger than or equal to0
and less than the resultILcdGXYMultiLabelPainter.getSubLabelCount(int)
.- See Also:
-
calculateMaxLabelWidth
Calculates the maximum width for a label when painting the given String objects in the given array on the given Graphics object.- Parameters:
aLabelArray
- the String objects to be painted for this label.aGraphics
- the Graphics the label is painted on.- Returns:
- the labels width when when painting the String objects in the given array on the given Graphics object.
-
paintLabel
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
- Overrides:
paintLabel
in classTLcdGXYPolylineStampLabelPainter
- Parameters:
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination ofaGXYContext
- the drawing context for the label- See Also:
-
paintLabels
public void paintLabels(String[] aLabelArray, ILcdPointList aPolygon, Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Deprecated.usepaintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
in combination withsetObject(java.lang.Object)
instead. If custom labels are required, overrideretrieveLabels(int, com.luciad.view.gxy.ILcdGXYContext)
.Performs the label painting.- Parameters:
aLabelArray
- the label to paintaPolygon
- the polygon for which to paint the labelaGraphics
- the Graphics on which the label will be painted.aMode
- the mode for which the label should be painted. This can be either ILcdGXYLabelPainter.DEFAULT or ILcdGXYLabelPainter.SELECTED.aGXYContext
- the context in which the label is painted.
-
labelBoundsSFCT
public double labelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) throws TLcdNoBoundsException 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:
-
labelBoundsSFCT
public double labelBoundsSFCT(Graphics aGraphics, String[] aLabelArray, ILcdPointList aPointList, int aMode, Rectangle aRectangleSFCT, ILcdGXYContext aGXYContext) throws TLcdNoBoundsException Deprecated.uselabelBoundsSFCT(java.awt.Graphics, int, ILcdGXYContext, java.awt.Rectangle)
in combination withsetObject(java.lang.Object)
instead. If custom labels are required, overrideretrieveLabels(int, com.luciad.view.gxy.ILcdGXYContext)
.Calculates the bounds of the label rectangle that has to be drawn. The bounds are stored in a rectangle, the angle at which the label has to be drawn is returned.- Parameters:
aGraphics
- the Graphics on which the label bounds should be calculated.aLabelArray
- the text to be used as label.aPointList
- the polygon for which to draw the label.aMode
- the mode for which the label bounds should be calculated. This can be either ILcdGXYLabelPainter.DEFAULT or ILcdGXYLabelPainter.SELECTED.aRectangleSFCT
- the rectangle to transform to the labels bounds as a side effect.aGXYContext
- the context in which the label will be painted.- Returns:
- the angle orientation of the rectangle around the labels in RADIANs, clockwise, 0 at 3 o'clock.
- Throws:
TLcdNoBoundsException
- when the String array is null or has zero length.
-
setGXYLabelStamp
Overridden to throw anUnsupportedOperationException
. This label painter installs its own label stamp and relies on its presence for proper operation.- Parameters:
aGXYLabelStamp
- Any label stamp.
-
setFont
Sets theFont
for drawing the labels toaFont
.- Parameters:
aFont
- the font to use to paint labels.- See Also:
-
getFont
Returns 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 new color to paint the labels foreground (text).- See Also:
-
getForeground
Returns the foreground color of the labels (text).- Returns:
- the foreground color of the labels (text).
- See Also:
-
setBackground
Sets the color of the label frames filling toaBackgroundColor
.- Parameters:
aBackgroundColor
- the color to be used for the label frames filling.- See Also:
-
getBackground
Returns the color of the label frames filling.- Returns:
- the color of the label frames filling.
- See Also:
-
setSelectionColor
Sets the text label color for selected objects.- Parameters:
aSelectionColor
- the color to use to paint labels for selected objects.- See Also:
-
getSelectionColor
Returns the label text color for selected object's labels.- Returns:
- the label color for selected objects
- See Also:
-
setFrame
public void setFrame(boolean aFramed) Sets whether or not to surround the labels with a frame.- Parameters:
aFramed
- true to paint the labels in a frame.- See Also:
-
isFrame
public boolean isFrame()Returns whether to surround labels with a frame.- Returns:
- whether labels will be painted in frames.
- See Also:
-
setFrameColor
Sets the line color of the frame surrounding the labels toaFrameColor
.- Parameters:
aFrameColor
- the line color to be used for the frame surrounding the labels- Since:
- 2022.0
- See Also:
-
getFrameColor
Returns the line color of the frame surrounding the labels.- Returns:
- the line color of the frame surrounding the labels
- Since:
- 2022.0
- See Also:
-
setFrameLineWidth
public void setFrameLineWidth(int aFrameWidth) Sets the line width of the frame surrounding the labels toaFrameWidth
.- Parameters:
aFrameWidth
- the line width of the frame surrounding the labels- Since:
- 2022.0
- See Also:
-
getFrameLineWidth
public int getFrameLineWidth()Returns the line width of the frame surrounding the labels.- Returns:
- the line width of the frame surrounding the labels
- Since:
- 2022.0
- See Also:
-
setFilled
public void setFilled(boolean aFilled) Sets whether to surround labels with a filled background.- Parameters:
aFilled
- true to paint labels with a filled background.- See Also:
-
isFilled
public boolean isFilled()Returns whether to surround labels with a filled background.- Returns:
true
if labels are surround with a filled background,false
otherwise- See Also:
-
setPadding
public void setPadding(int aPadding) Sets the amount of padding around the label text, in pixels. If the frame is painted, it will be painted around this margin.- Parameters:
aPadding
- the new padding size, in pixels- See Also:
-
getPadding
public int getPadding()Returns the amount of padding used around the text.- Returns:
- the padding around the text, in pixels
- See Also:
-
setVerticalSpacing
public void setVerticalSpacing(int aVerticalSpacing) Sets the vertical distance in between a label's lines. More specifically, the distance between the tops of two successive label lines is this value + the standard height of a line of text in the set font. Negative values are allowed.- Parameters:
aVerticalSpacing
- the vertical distance to be used between lines of a label, in pixels.- See Also:
-
getVerticalSpacing
public int getVerticalSpacing()Returns the vertical spacing in between a label's lines.- Returns:
- the vertical spacing used between lines in a label, in pixels.
- See Also:
-
getLabelTextAlignmentMode
Returns the alignment of the lines in the label.- Returns:
- the alignment of the lines in the label
- See Also:
-
setLabelTextAlignmentMode
Sets the alignment of the lines in the label.- Parameters:
aAlignment
- the alignment of the lines in the label- See Also:
-
setGXYInteractiveLabelProvider
@Deprecated public void setGXYInteractiveLabelProvider(ALcdGXYInteractiveLabelProvider aGXYInteractiveLabelProvider) Deprecated.this is controller logic. UseTLcdGXYInteractiveLabelsController
instead.Sets the interactive label provider. This method can be called at most once. If the interactive label provider was previously set (with this method or in the constructor), calling this method will throw and
Note that to fully enable the functionality,IllegalStateException
.setProvideInteractiveLabelOnMouseOver
must be set totrue
.- Parameters:
aGXYInteractiveLabelProvider
- The interactive label provider that will be used to configure and show a component that can, for instance, be used to edit the properties of the labeled domain object. This cannot benull
.- Throws:
IllegalStateException
- When the interactive label provider was already set.IllegalArgumentException
- When the interactive label provider wasnull
.- See Also:
-
getGXYInteractiveLabelProvider
Returns the interactive label provider.- Returns:
- The interactive label provider.
- See Also:
-
getComponentForGXYView
Gets the component that represents the given
ILcdGXYView
. By default this is the view itself casted tojava.awt.Component
. This information is used for handling mouse events.Override this method if your
ILcdGXYView
implementation does not extend fromjava.awt.Component
.- Parameters:
aGXYView
- The view for which aComponent
must be retrieved.- Returns:
- The
java.awt.Component
which corresponds to the givenILcdGXYView
- Throws:
IllegalArgumentException
- By default whenaGXYView
is not ajava.awt.Component
- See Also:
-
canAddComponentToGXYView
Returns whether or not an interactive label can be added to the given view. If this method returns
false
,addComponentToGXYView
must not be called. By default this method checks if the givenILcdGXYView
is an instance ofjava.awt.Container
without a layout set on it.Override this method if your
ILcdGXYView
implementation is not ajava.awt.Container
or if you add components to another container than the specifiedILcdGXYView
.- Parameters:
aGXYView
- TheILcdGXYView
for which to check if a component can be added.- Returns:
true
if a component can be added,false
otherwise.- See Also:
-
addComponentToGXYView
Adds the specified interactive label to the user interface. By default this method casts the given
ILcdGXYView
tojava.awt.Container
and adds the component to the view.Override this method if your implementation of
ILcdGXYView
does not extend fromjava.awt.Container
or if you want to add the interactive label to anotherjava.awt.Container
because, for instance, you already need to add other components to the specifiedILcdGXYView
.If you override this method, you also need to override
canAddComponentToGXYView
andremoveComponentFromGXYView
as these methods are closely related to each other.This method will not be called if
canAddComponentToGXYView
returnsfalse
.- Parameters:
aGXYView
- The view to which the interactive label should be added.aComponent
- The interactive label that should be added to the user interface.- Throws:
IllegalArgumentException
- By default ifaGXYView
is not an instance ofjava.awt.Container
or if the layout ofaGXYView
is not null.- See Also:
-
removeComponentFromGXYView
Removes the specified
java.awt.Component
from the user interface. By default this method casts the specifiedILcdGXYView
tojava.awt.Container
and removes the component from that container.Override this method if you have overridden
addComponentToGXYView
.- Parameters:
aGXYView
- The view from which the interactive label should be removed.aComponent
- The interactive label that should be removed from the user interface- Throws:
IllegalArgumentException
- By default if the view does not extend fromjava.awt.Container
-
startLabelInteraction
public void startLabelInteraction(Object aDomainObject, int aLabelIndex, int aSubLabelIndex, ILcdGXYContext aGXYContext) Configure an interactive label for the specified label and show it in the GUI.- Parameters:
aDomainObject
- The domain object for which to display an interactive label.aLabelIndex
- The index of the label for which an interactive label should be displayed.aSubLabelIndex
- The index of the sublabel for which an interactive label should be displayed.aGXYContext
- An instance ofILcdGXYContext
containing the layer and the view for which the label should be made interactive
-
canStopLabelInteraction
public boolean canStopLabelInteraction()Returns whether or not the label interaction can be stopped. For instance, when the interactive label contains invalid text, this method should return
false
.- Returns:
true
if the label interaction can be stopped,false
otherwise.
-
stopLabelInteraction
public boolean stopLabelInteraction()Stops the interactive label, if there is one. The interactive label will commit any outstanding changes.
- Returns:
true
if the interactive label could be stopped or if there was no interactive label,false
otherwise.- See Also:
-
cancelLabelInteraction
public void cancelLabelInteraction()Cancels the interactive label, if there is one. This prevents the interactive label from committing any changes. -
getDomainObjectForInteractiveLabel
Returns the domain object for the interactive label, ornull
if there is no interactive label.- Returns:
- The domain object for the interactive label, or
null
if there is no interactive label.
-
setProvideInteractiveLabelOnMouseOver
@Deprecated public void setProvideInteractiveLabelOnMouseOver(boolean aProvideInteractiveLabelOnMouseOver) Deprecated.this is controller logic. UseTLcdGXYInteractiveLabelsController
instead.Enables the
ALcdGXYInteractiveLabelProvider
functionality, so that the interactive label is present when the mouse hoovers over a label. This flag is typically enabled/disabled whenever the interactive label functionality is desired/not wanted. For example, the interactive labels could only be desired when a certainILcdGXYController
is active.- Parameters:
aProvideInteractiveLabelOnMouseOver
-true
to activate theALcdGXYInteractiveLabelProvider
,false
otherwise.- 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:
-
editLabel
Description copied from interface:ILcdGXYLabelEditor
Adapts the set
TLcdLabelLocation
according to the information present in aGXYContext. If the method returnstrue
, theTLcdLabelLocation
was modified, iffalse
is returned, it wasn't changed.The implementation of this method shall define how to edit the label specified by the set domain
Object
, label index and sublabel index, considering the given mode andaGXYContext
. These should all be set before calling this method. Note that ifaMode
is one of the creating modes, the (sub) label indices are irrelevant.- Specified by:
editLabel
in interfaceILcdGXYLabelEditor
- Parameters:
aGraphics
- TheGraphics
on which the label is painted.aMode
- the mode to consider when editing aObject: aMode shall be a combination ofILcdGXYLabelEditor.TRANSLATED
,ILcdGXYLabelEditor.RESHAPED
,ILcdGXYLabelEditor.START_CREATION
,ILcdGXYLabelEditor.CREATING
,ILcdGXYLabelEditor.END_CREATION
.
aGXYContext
- contains the information to consider when editing the set Object.- Returns:
- true if the label of the set Object has changed, false otherwise.
- See Also:
-
labelSnapTarget
Description copied from class:ALcdGXYLabelPainter
Returns anObject
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents. The returnedObject
can be theObject
this ILcdGXYLabelPainter2 represents or any other (e.g. anILcdPoint
if getObject() is anILcdPointList
).This default implementation always returns
null
. Override this method if you want to support snapping.- Specified by:
labelSnapTarget
in interfaceILcdGXYLabelPainter2
- Overrides:
labelSnapTarget
in classALcdGXYLabelPainter
- Parameters:
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.- Returns:
- an
Object
that can be used as snapping target when graphically editing anotherObject
or label than the one this ILcdGXYLabelPainter2 represents (returned by getObject()). This object can benull
.
-
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.
-
getGXYLabelEditor
Description copied from interface:ILcdGXYLabelEditorProvider
Returns a valid
ILcdGXYLabelEditor
for editing the labels of aObject. The returnedILcdGXYLabelEditor
must haveaObject
set on it. The TLcdLabelLocation must not yet be set on it.- Specified by:
getGXYLabelEditor
in interfaceILcdGXYLabelEditorProvider
- Parameters:
aObject
- the Object for which to obtain aILcdGXYLabelEditor
.- Returns:
- a valid
ILcdGXYLabelEditor
for editing the labels ofaObject
withaObject
set on it. - See Also:
-
getGXYLabelStamp
Returns theALcdGXYLabelStamp
that is used by this painter to paint the labels.- Returns:
- The
ALcdGXYLabelStamp
that is used by this painter to paint the labels. - See Also:
-
firePropertyChangeEvent
Description copied from class:ALcdGXYLabelPainter
Notifies the registeredPropertyChangeListener
s of the specified event.- Overrides:
firePropertyChangeEvent
in classALcdGXYLabelPainter
- Parameters:
aPropertyChangeEvent
- The event describing the property change of which the registered listeners should be notified.- See Also:
-
getDisplayName
Description copied from class:ALcdGXYLabelPainter
This default implementation returns the display name set withsetDisplayName
, ortoString()
if this was set tonull
.- Specified by:
getDisplayName
in interfaceILcdGXYLabelEditor
- Specified by:
getDisplayName
in interfaceILcdGXYLabelPainter2
- Overrides:
getDisplayName
in classALcdGXYLabelPainter
- Returns:
- the display name of this
ILcdGXYLabelPainter2
-
getLabelCursor
Description copied from class:ALcdGXYLabelPainter
Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.This default implementation always returns
null
. Override this method if you want to display custom cursors.- Specified by:
getLabelCursor
in interfaceILcdGXYLabelPainter2
- Overrides:
getLabelCursor
in classALcdGXYLabelPainter
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- The mode to consider. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, ILcdGXYContext)
for more information.aGXYContext
- TheILcdGXYContext
containing extra information, such as the layer, the view and the mouse position.- Returns:
- a
Cursor
to indicate the type of editingaMode
andaGXYContext
. Returnsnull
if no particularCursor
is required.
-
acceptSnapTargetForLabel
Description copied from interface:ILcdGXYLabelEditor
Returns whether the label specified by
setObject
,setLabelIndex
andsetSubLabelIndex
accepts the snap target in the givenILcdGXYContext
.The snap target is the
Object
returned byaGXYContext.getSnapTarget()
, and is on theILcdGXYLayer
returned byaGXYContext.getSnapTargetLayer()
.- Specified by:
acceptSnapTargetForLabel
in interfaceILcdGXYLabelEditor
- Parameters:
aGraphics
- TheGraphics
on which the label is painted.aGXYContext
- TheILcdGXYContext
containing the snapping information.- Returns:
true
if the label accepts the snap target,false
otherwise.- See Also:
-
setMakeLabelsStickyOnEdit
public void setMakeLabelsStickyOnEdit(boolean aMakeLabelsStickyOnEdit) Sets whether or not this editor should set the label edit mode of the edited labels to include the sticky flag. This means the labels will no longer be automatically moved by the decluttering algorithm.- Parameters:
aMakeLabelsStickyOnEdit
-true
if you want the labels to be sticky after they are edited,false
otherwise.- See Also:
-
isMakeLabelsStickyOnEdit
public boolean isMakeLabelsStickyOnEdit()Returns whether the labels this editor edits are made sticky.- Returns:
true
if this editor sets the labels it edits to be sticky,false
otherwise. The default value isfalse
.- See Also:
-
getLabelCreationClickCount
public int getLabelCreationClickCount()Description copied from interface:ILcdGXYLabelEditor
Returns the number of points required to initialize the label of the setObject
.- Specified by:
getLabelCreationClickCount
in interfaceILcdGXYLabelEditor
- Returns:
- the number of points required to initialize the label of the set
Object
or -1 if this is undefined like for a polyline or a polygon. 0 means graphical creation of labels is not supported.
-
getPinColor
Returns the color in which the pin is drawn.- Returns:
- The color in which the pin is drawn.
- See Also:
-
setPinColor
Sets the color in which the pin should be drawn.- Parameters:
aPinColor
- The color in which the pin should be drawn.- See Also:
-
getSelectedPinColor
Returns the color in which the pin should be drawn of the label of a selected object.- Returns:
- The color in which the pin should be drawn of the label of a selected object.
-
setSelectedPinColor
Sets the color in which the pin of the label of a selected label should be drawn.- Parameters:
aSelectedPinColor
- The color in which the pin of the label of a selected label should be drawn.- 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:
-
isHaloPinEnabled
public boolean isHaloPinEnabled()Returns true if the halo effect also includes the pin.- Returns:
- true if the halo effect includes the pin, false otherwise
- See Also:
-
setHaloPinEnabled
public void setHaloPinEnabled(boolean aHaloPinEnabled) Sets if the halo effect should be applied to the pin. This only has effect when the pin is enabled.- Parameters:
aHaloPinEnabled
- true if the halo effect includes the pin, 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:
-
getHaloPinColor
Returns the current halo pin color.- Returns:
- the current halo pin color
- See Also:
-
setHaloPinColor
Sets the color of the halo to be added around pins.- Parameters:
aColor
- the new halo color- See Also:
-
isUseImageCache
public boolean isUseImageCache()Returnstrue
when image caching for labels with a halo is enabled,false
otherwise.- Returns:
true
when label image caching is enabled,false
otherwise- See Also:
-
setUseImageCache
public void setUseImageCache(boolean aUseCache) Sets whether or not labels with halos should be cached as images. Creating a halo for a label is an expensive operation, so enabling image caching can considerably improve performance.- Parameters:
aUseCache
- specifies whether image caching should be enabled- See Also:
-
clearImageCache
public void clearImageCache()Clears the entire label image cache. To remove a single label from the cache, 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:
-
pinPointSFCT
protected boolean pinPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aAnchorPoint, Rectangle aLabelBounds, double aRotation, Point aPinPointSFCT) Determines where the pin attaches to the label. This implementation attaches the pin on the label bounds, with the pin going towards the center of the label bounds.- Parameters:
aGraphics
- TheGraphics
instance on which the pin will be painted.aMode
- The mode in which the pin will be painted. SeeILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, ILcdGXYContext)
for more information.aGXYContext
- The instance containing the context in which the pin will be painted.aAnchorPoint
- The point in AWT coordinates where the pin attaches to the object representation (see #anchorPointSFCT)aLabelBounds
- The bounds of the label in AWT coordinates.aRotation
- The rotation of the label in radians, positive going from the x to the y axisaPinPointSFCT
- The point in AWT coordinates where the pin attaches to the label- Returns:
- Whether or not the pin needs to be drawn.
- See Also:
-
paintPin
protected void paintPin(Graphics aGraphics, int aMode, int aStartPointX, int aStartPointY, int aEndPointX, int aEndPointY) Draws a label pin on the given graphics between the given lines. Overwrite this method if you want to change the look of the pin, for example by manipulating the graphics passed.- Parameters:
aGraphics
- the graphics to paint the pin on.aMode
- the mode this objects label is painted in (e.g. ILcdGXYLabelPainter.SELECTED).aStartPointX
- the x coordinate of the start point of the pin.aStartPointY
- the y coordinate of the start point of the pin.aEndPointX
- the x coordinate of the end point of the pin.aEndPointY
- the y coordinate of the end point of the pin.- See Also:
-
setWithPin
public void setWithPin(boolean aWithPin) The propertywithPin
determines whether a pin should be drawn from the object to the label. The pin is attached to the object at theanchor point
and to the label stamp at thepin point
.- Parameters:
aWithPin
- true to paint a pin connecting the label and the object.- See Also:
-
isWithPin
public boolean isWithPin()Returns whether a pin is drawn from the object to the label.- Returns:
true
if a pin is drawn from the object to the label- See Also:
-
setWithAnchorPoint
public void setWithAnchorPoint(boolean aWithAnchorPoint) Determines whether to draw an anchor point atanchorPointSFCT
.- Parameters:
aWithAnchorPoint
- true to paint an anchor point- See Also:
-
isWithAnchorPoint
public boolean isWithAnchorPoint()Returns whether to draw an anchor point atanchorPointSFCT
.- Returns:
true
if an anchor point is painted,false
otherwise- See Also:
-
setClassTraceOn
public static void setClassTraceOn(boolean aClassTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for all instances of this class. If the argument istrue
then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.- Parameters:
aClassTraceOn
- if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
-
labelBoundsSFCT(java.awt.Graphics, int, ILcdGXYContext, java.awt.Rectangle)
in combination withsetObject(java.lang.Object)
instead.