public interface ILcdGXYLabelPainter2 extends ILcdGXYMultiLabelPainter, ILcdPropertyChangeSource
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), ...
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:
labelAnchorPointSFCT
and specified by the TLcdLabelLocation
.labelBoundsSFCT
.
The relationship with the label anchor point is determined by the label painter implementation.TLcdLabelLocation
uses absolute positioning
ILcdGXYPainter.anchorPointSFCT
,
determining the base offset of the label anchor point when the TLcdLabelLocation
uses relative positioning.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
.
ILcdGXYEditableLabelsLayer
,
ALcdLabelLocations
Modifier and Type | Field and Description |
---|---|
static int |
BODY
The body of the label.
|
static int |
CREATING
The label when it is being created.
|
static int |
HANDLES
The handles of the label.
|
static int |
RESHAPING
The label when it is being reshaped.
|
static int |
SNAPS
The snaps of the label.
|
static int |
TRANSLATING
The label when it is being translated.
|
DEFAULT, SELECTED
Modifier and Type | Method and Description |
---|---|
Object |
clone()
Redefines
Object.clone to make it public. |
String |
getDisplayName() |
Cursor |
getLabelCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor to indicate the type of editing aMode and
aGXYContext . |
TLcdLabelLocation |
getLabelLocation()
Returns the
TLcdLabelLocation 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 by
setObject , setLabelIndex and
setSubLabelIndex is touched at view location (specified by
aGXYContext.getX() and aGXYContext.getY() ), considering the mode and the
ILcdGXYContext instance. |
void |
labelAnchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Sets
aPointSFCT to the anchor point of the label specified by
setObject , setLabelIndex and setSubLabelIndex . |
double |
labelBoundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Rectangle aRectangleSFCT)
Calculates the bounds of the label that can be painted.
|
Object |
labelSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns an
Object that can be used as snapping target when graphically editing
another Object or label than the one this ILcdGXYLabelPainter2 represents. |
void |
paintLabel(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Paints the label specified by
setObject , setLabelIndex and
setSubLabelIndex on aGraphics . |
void |
setLabelLocation(TLcdLabelLocation aLabelLocation)
Sets the label location of the label.
|
void |
setObject(Object aObject)
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 by
setObject , setLabelIndex and setSubLabelIndex ,
considering the given ILcdGXYContext instance. |
getLabelCount, getLabelIndex, getSubLabelCount, getSubLabelIndex, setLabelIndex, setSubLabelIndex
getLocationIndex, getObject, getPossibleLocationCount, setLocationIndex
addPropertyChangeListener, removePropertyChangeListener
static final int BODY
static final int HANDLES
static final int SNAPS
static final int TRANSLATING
static final int RESHAPING
static final int CREATING
void setLabelLocation(TLcdLabelLocation aLabelLocation)
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 the ILcdGXYLabelPainter.getLocationIndex()
of the super interface. Contrary to the location
index returned by getLocationIndex
, the location index in
aLabelLocation
can be less than 0
, in which case the labels are
freely placed.
This method has to be called after setObject(java.lang.Object)
has been called, as calling
setObject
clears this label location.
aLabelLocation
- The TLcdLabelLocation
instance containing all the
information about the location of the label.setObject(java.lang.Object)
void setObject(Object aObject)
Setting the object should set the TLcdLabelLocation
to null
, to
ensure that older code which has not been adapted to this new interface keeps working.
setObject
in interface ILcdGXYLabelPainter
aObject
- The object to be labeled.ILcdGXYLabelPainter.getObject()
TLcdLabelLocation getLabelLocation()
TLcdLabelLocation
that was previously set that contains the
information on the whereabouts of the label.setLabelLocation(com.luciad.view.TLcdLabelLocation)
void paintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
Paints the label specified by setObject
, setLabelIndex
and
setSubLabelIndex
on aGraphics
. aGXYContext
should
contain the ILcdGXYView
for which the label is painted and
ILcdGXYLayer
to which the object belongs
The implementation of this method shall define how to paint the specified label in the given
mode, considering aGXYContext
and the set TLcdLabelLocation
.
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
or ILcdGXYLabelPainter.SELECTED
, the mode now can be a
bitwise combination of several constants
paintLabel
in interface ILcdGXYLabelPainter
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination of ILcdGXYLabelPainter.DEFAULT
or ILcdGXYLabelPainter.SELECTED
BODY
, HANDLES
or SNAPS
TRANSLATING
, RESHAPING
, CREATING
or
nothingaGXYContext
- the drawing context for the labelILcdGXYLabelPainter.DEFAULT
,
ILcdGXYLabelPainter.SELECTED
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 of aRectangleSFCT
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.
labelBoundsSFCT
in interface ILcdGXYLabelPainter
aGraphics
- the aGraphics
to consider.aMode
- the representation mode of the label.aGXYContext
- the ILcdGXYContext
the drawing depends on.aRectangleSFCT
- the Rectangle
containing the bounds of the label in view /
graphics coordinates as side effect.TLcdNoBoundsException
- if the Object doesn't have any valid bounds, e.g. if it is always
invisible in the current projection.ILcdGXYViewLabelPainter
,
ILcdGXYLayerLabelPainter
,
labelAnchorPointSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Point)
boolean isLabelTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
setObject
, setLabelIndex
and
setSubLabelIndex
is touched at view location (specified by
aGXYContext.getX()
and aGXYContext.getY()
), considering the mode and the
ILcdGXYContext
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.
aGraphics
- The Graphics
instance on which the label is painted.aMode
- the mode to consider. This is a bitwise combinations of several constants.
See paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- the ILcdGXYContext
to consider.ILcdGXYContext
void labelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
Sets aPointSFCT
to the anchor point of the label specified by
setObject
, setLabelIndex
and setSubLabelIndex
.
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 the label
and its location
.
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.
aGraphics
- The Graphics
instance on which the label is painted.aMode
- The mode to consider. This can be a bitwise combination of several
constants. See paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- The ILcdGXYContext
that can be used to retrieve extra
information.aPointSFCT
- The point which will be updated to reflect the location of the anchor
point.TLcdNoBoundsException
- if the Object doesn't have any valid anchor point, e.g. if it is
always invisible in the current projection.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
getLabelLocation()
,
labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
boolean supportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
Returns whether this label painter supports snapping for the label specified by
setObject
, setLabelIndex
and setSubLabelIndex
,
considering the given ILcdGXYContext
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.
aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.true
if this label painter supports snapping for the specified label.labelSnapTarget
Object labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
Object
that can be used as snapping target when graphically editing
another Object
or label than the one this ILcdGXYLabelPainter2 represents. The
returned Object
can be the Object
this ILcdGXYLabelPainter2
represents or any other (e.g. an ILcdPoint
if getObject() is an
ILcdPointList
).aGraphics
- the Graphics on which is worked.aGXYContext
- the ILcdGXYContext of the snapping.Object
that can be used as snapping target when graphically editing
another Object
or label than the one this ILcdGXYLabelPainter2 represents
(returned by getObject()). This object can be null
.Cursor getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
Cursor
to indicate the type of editing aMode
and
aGXYContext
.aGraphics
- The Graphics
instance on which the label is painted.aMode
- The mode to consider. See paintLabel(java.awt.Graphics, int,
ILcdGXYContext)
for more information.aGXYContext
- The ILcdGXYContext
containing extra information, such as the
layer, the view and the mouse position.Cursor
to indicate the type of editing aMode
and
aGXYContext
. Returns null
if no particular
Cursor
is required.String getDisplayName()
ILcdGXYLabelPainter2
Object clone()
Object.clone
to make it public.clone
in interface ILcdGXYLabelPainter