Interface ILcdGXYLabelPainter2
- All Superinterfaces:
Cloneable
,ILcdGXYLabelPainter
,ILcdGXYMultiLabelPainter
,ILcdPropertyChangeSource
,Serializable
- All Known Implementing Classes:
ALcdGXYLabelPainter
,TLcdAIXM51AirspaceLabelPainter
,TLcdAIXM51NavaidLabelPainter
,TLcdAIXM51XPathLabelPainter
,TLcdGXYCompositeLabelPainter
,TLcdGXYCurvedPathLabelPainter
,TLcdGXYDataObjectLabelPainter
,TLcdGXYDataObjectPolygonLabelPainter
,TLcdGXYDataObjectPolylineLabelPainter
,TLcdGXYFeaturedLabelPainter
,TLcdGXYFeaturedPolygonLabelPainter
,TLcdGXYFeaturedPolylineLabelPainter
,TLcdGXYHaloLabelPainter2
,TLcdGXYLabelPainter
,TLcdGXYLabelPainterAdapter
,TLcdGXYMultiFontLabelPainter
,TLcdGXYOffsetIconPainter
,TLcdGXYOutlinePolylineLabelPainter
,TLcdGXYPolygonLabelPainter
,TLcdGXYPolygonStampLabelPainter
,TLcdGXYPolylineLabelPainter
,TLcdGXYPolylineStampLabelPainter
,TLcdGXYStampLabelPainter
,TLcdICAOAirspaceDetailedLabelPainter
,TLcdICAOAirspaceLabelPainter
,TLcdICAOAreaMinimumAltitudeLabelPainter
,TLcdICAODMELabelPainter
,TLcdICAONavaidLabelPainter
,TLcdICAONDBLabelPainter
,TLcdICAOTACANLabelPainter
,TLcdICAOVORLabelPainter
,TLcdMagneticNorthGXYLabelPainter
,TLcdSLDFeatureTypeStylePainter
,TLcdSLDRulePainter
Extension of ILcdGXYMultiLabelPainter
that allows free label placement next to
the discrete label placement offered by the super interface. This interface also adds methods
similar to those in ILcdGXYPainter
to support better interaction with the labels, such as
checking if a label is touched (selection), snapping, painting labels in an editing state
(translating), ...
Free label placement
With the discrete placement of the super interface, one had to choose one label location
(setLocationIndex
), from a set of label locations (getPossibleLocationCount
) offered by the label painter itself.
This interface supports both free and discrete placement by setting
a TLcdLabelLocation
to it. This TLcdLabelLocation
contains
all needed information on where to put the label: at one of the possible discrete locations or at
a free location (specified in pixels on the view).
Free locations determine the label location as shown in the following figure of a labeled point:
- the label anchor point, retrieved through
labelAnchorPointSFCT
and specified by theTLcdLabelLocation
. - the label's upper left corner, retrieved through
labelBoundsSFCT
. The relationship with the label anchor point is determined by the label painter implementation. - the AWT origin, determining the base offset of the label anchor point when the
TLcdLabelLocation
usesabsolute positioning
- the object anchor point, as retrieved through
ILcdGXYPainter.anchorPointSFCT
, determining the base offset of the label anchor point when theTLcdLabelLocation
uses relative positioning.
Usage
Implementations of this interface require that the object,
the label location
and the label- and
sublabel-index are set (in that order) before the other methods can be used. Setting the location index
is no longer needed.
Typically, users of this interface will retrieve and store the TLcdLabelLocation
of a particular label using the ALcdLabelLocations
of an ILcdGXYEditableLabelsLayer
.
- Since:
- 7.0
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The body of the label.static final int
The label when it is being created.static final int
The handles of the label.static final int
The label when it is being reshaped.static final int
The snaps of the label.static final int
The label when it is being translated.Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
DEFAULT, SELECTED
-
Method Summary
Modifier and TypeMethodDescriptionclone()
RedefinesObject.clone
to make it public.getLabelCursor
(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.Returns theTLcdLabelLocation
that was previously set that contains the information on the whereabouts of the label.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.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.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
setLabelLocation
(TLcdLabelLocation aLabelLocation) Sets the label location of the label.void
Sets the Object to be labeled by this ILcdGXYLabelPainter.boolean
supportLabelSnap
(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether this label painter supports snapping for the label specified bysetObject
,setLabelIndex
andsetSubLabelIndex
, considering the givenILcdGXYContext
instance.Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
getLocationIndex, getObject, getPossibleLocationCount, setLocationIndex
Methods inherited from interface com.luciad.view.gxy.ILcdGXYMultiLabelPainter
getLabelCount, getLabelIndex, getSubLabelCount, getSubLabelIndex, setLabelIndex, setSubLabelIndex
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
-
Field Details
-
BODY
static final int BODYThe body of the label.- See Also:
-
HANDLES
static final int HANDLESThe handles of the label.- See Also:
-
SNAPS
static final int SNAPSThe snaps of the label.- See Also:
-
TRANSLATING
static final int TRANSLATINGThe label when it is being translated.- See Also:
-
RESHAPING
static final int RESHAPINGThe label when it is being reshaped.- See Also:
-
CREATING
static final int CREATINGThe label when it is being created.- See Also:
-
-
Method Details
-
setLabelLocation
Sets the label location of the label. This label location will be used to determine what the bounds of the label are, where it must be painted, etc.
Note that
aLabelLocation
also contains a label location index. This is independent of theILcdGXYLabelPainter.getLocationIndex()
of the super interface. Contrary to the location index returned bygetLocationIndex
, the location index inaLabelLocation
can be less than0
, in which case the labels are freely placed.This method has to be called after
setObject(java.lang.Object)
has been called, as callingsetObject
clears this label location.- Parameters:
aLabelLocation
- TheTLcdLabelLocation
instance containing all the information about the location of the label.- See Also:
-
setObject
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 interfaceILcdGXYLabelPainter
- Parameters:
aObject
- The object to be labeled.- See Also:
-
getLabelLocation
TLcdLabelLocation getLabelLocation()Returns theTLcdLabelLocation
that was previously set that contains the information on the whereabouts of the label.- Returns:
- The label location that was previously set.
- See Also:
-
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
- Parameters:
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination of- either
ILcdGXYLabelPainter.DEFAULT
orILcdGXYLabelPainter.SELECTED
- either
BODY
,HANDLES
orSNAPS
- either
TRANSLATING
,RESHAPING
,CREATING
or nothing
- either
aGXYContext
- the drawing context for the label- See Also:
-
labelBoundsSFCT
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
- 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
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.
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- the mode to consider. This is a bitwise combinations of several constants. SeepaintLabel(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
void labelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException 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.
- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- The mode to consider. This can be a bitwise combination of several constants. SeepaintLabel(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:
-
supportLabelSnap
Returns whether this label painter supports snapping for the label specified by
setObject
,setLabelIndex
andsetSubLabelIndex
, considering the givenILcdGXYContext
instance. When the label painter supports snap for the specified label and context, it can return a snap target for this label and context.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.
- Parameters:
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.- Returns:
true
if this label painter supports snapping for the specified label.- See Also:
-
labelSnapTarget
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
).- 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
.
-
getLabelCursor
Returns aCursor
to indicate the type of editingaMode
andaGXYContext
.- Parameters:
aGraphics
- TheGraphics
instance on which the label is painted.aMode
- The mode to consider. SeepaintLabel(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.
-
getDisplayName
String getDisplayName()- Returns:
- the display name of this
ILcdGXYLabelPainter2
-
clone
Object clone()RedefinesObject.clone
to make it public.- Specified by:
clone
in interfaceILcdGXYLabelPainter
-