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
labelAnchorPointSFCTand 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
TLcdLabelLocationusesabsolute positioning - the object anchor point, as retrieved through
ILcdGXYPainter.anchorPointSFCT, determining the base offset of the label anchor point when theTLcdLabelLocationuses 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
FieldsModifier and TypeFieldDescriptionstatic final intThe body of the label.static final intThe label when it is being created.static final intThe handles of the label.static final intThe label when it is being reshaped.static final intThe snaps of the label.static final intThe label when it is being translated.Fields inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
DEFAULT, SELECTED -
Method Summary
Modifier and TypeMethodDescriptionclone()RedefinesObject.cloneto make it public.getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Returns aCursorto indicate the type of editingaModeandaGXYContext.Returns theTLcdLabelLocationthat was previously set that contains the information on the whereabouts of the label.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.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.labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns anObjectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents.voidpaintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext) Paints the label specified bysetObject,setLabelIndexandsetSubLabelIndexonaGraphics.voidsetLabelLocation(TLcdLabelLocation aLabelLocation) Sets the label location of the label.voidSets the Object to be labeled by this ILcdGXYLabelPainter.booleansupportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext) Returns whether this label painter supports snapping for the label specified bysetObject,setLabelIndexandsetSubLabelIndex, considering the givenILcdGXYContextinstance.Methods inherited from interface com.luciad.view.gxy.ILcdGXYLabelPainter
getLocationIndex, getObject, getPossibleLocationCount, setLocationIndexMethods inherited from interface com.luciad.view.gxy.ILcdGXYMultiLabelPainter
getLabelCount, getLabelIndex, getSubLabelCount, getSubLabelIndex, setLabelIndex, setSubLabelIndexMethods 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
aLabelLocationalso 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 inaLabelLocationcan 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 callingsetObjectclears this label location.- Parameters:
aLabelLocation- TheTLcdLabelLocationinstance 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
TLcdLabelLocationtonull, to ensure that older code which has not been adapted to this new interface keeps working.- Specified by:
setObjectin interfaceILcdGXYLabelPainter- Parameters:
aObject- The object to be labeled.- See Also:
-
getLabelLocation
TLcdLabelLocation getLabelLocation()Returns theTLcdLabelLocationthat 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,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- Parameters:
aGraphics- The graphics object to paint the label onaMode- A bitwise combination of- either
ILcdGXYLabelPainter.DEFAULTorILcdGXYLabelPainter.SELECTED - either
BODY,HANDLESorSNAPS - either
TRANSLATING,RESHAPING,CREATINGor 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 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- 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
Tests 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.
- Parameters:
aGraphics- TheGraphicsinstance 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- theILcdGXYContextto 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
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.
- Parameters:
aGraphics- TheGraphicsinstance 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- 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:
-
supportLabelSnap
Returns whether this label painter supports snapping for the label specified by
setObject,setLabelIndexandsetSubLabelIndex, considering the givenILcdGXYContextinstance. 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:
trueif this label painter supports snapping for the specified label.- See Also:
-
labelSnapTarget
Returns anObjectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents. The returnedObjectcan be theObjectthis ILcdGXYLabelPainter2 represents or any other (e.g. anILcdPointif getObject() is anILcdPointList).- Parameters:
aGraphics- the Graphics on which is worked.aGXYContext- the ILcdGXYContext of the snapping.- Returns:
- an
Objectthat can be used as snapping target when graphically editing anotherObjector label than the one this ILcdGXYLabelPainter2 represents (returned by getObject()). This object can benull.
-
getLabelCursor
Returns aCursorto indicate the type of editingaModeandaGXYContext.- Parameters:
aGraphics- TheGraphicsinstance on which the label is painted.aMode- The mode to consider. SeepaintLabel(java.awt.Graphics, int, ILcdGXYContext)for more information.aGXYContext- TheILcdGXYContextcontaining extra information, such as the layer, the view and the mouse position.- Returns:
- a
Cursorto indicate the type of editingaModeandaGXYContext. Returnsnullif no particularCursoris required.
-
getDisplayName
String getDisplayName()- Returns:
- the display name of this
ILcdGXYLabelPainter2
-
clone
Object clone()RedefinesObject.cloneto make it public.- Specified by:
clonein interfaceILcdGXYLabelPainter
-