public class TLcdGXYLabelPainterAdapter extends ALcdGXYLabelPainter implements ILcdGXYLabelPainterProvider, ILcdGXYLabelEditor, ILcdGXYLabelEditorProvider
ILcdGXYPainter
into an ILcdGXYLabelPainter2
.
It uses a set of fixed label positions to position the label. It also offers the possibility
to place a pin.
If an ILcdGXYEditor
is passed in the constructor, this class will also implement
the ILcdGXYLabelEditor
behaviour.
Modifier and Type | Field and Description |
---|---|
static int |
CENTER
Integer code to place label at center of the anchor point.
|
static int |
EAST
Integer code to place label at east of the anchor point.
|
static int |
MAXIMUM_AVAILABLE_LOCATIONS
Maximum number of available locations.
|
static int |
NORTH
Integer code to place label at north of the anchor point.
|
static int |
NORTH_EAST
Integer code to place label at north east of the anchor point.
|
static int |
NORTH_WEST
Integer code to place label at north west of the anchor point.
|
static int |
SOUTH
Integer code to place label at south of the anchor point.
|
static int |
SOUTH_EAST
Integer code to place label at south east of the anchor point.
|
static int |
SOUTH_WEST
Integer code to place label at south west of the anchor point.
|
static int |
WEST
Integer code to place label at west of the anchor point.
|
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
DEFAULT, SELECTED
Constructor and Description |
---|
TLcdGXYLabelPainterAdapter(ILcdGXYPainter aDelegatePainter)
Creates a new label painter adapter that makes a label painter out of an
ILcdGXYPainter . |
TLcdGXYLabelPainterAdapter(ILcdGXYPainter aDelegatePainter,
ILcdGXYEditor aDelegateEditor)
Creates a new label painter adapter that makes a label painter out of an
ILcdGXYPainter and a ILcdGXYEditor . |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTargetForLabel(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the label specified by
setObject , setLabelIndex and
setSubLabelIndex accepts the snap target in the given
ILcdGXYContext . |
protected void |
anchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aContext,
Point aPointSFCT)
This method retrieves an anchor point using the corresponding
ILcdGXYPainter for
the Object to be painted (aGXYContext.getGXYLayer().getGXYPainter( aObject ) ). |
Object |
clone()
Returns a new instance of this
ALcdGXYLabelPainter . |
boolean |
editLabel(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Adapts the set
TLcdLabelLocation according to the information present in
aGXYContext. |
ILcdGXYPainter |
getDelegatePainter()
Returns the delegate painter.
|
ILcdGXYLabelEditor |
getGXYLabelEditor(Object aObject)
Returns a valid
ILcdGXYLabelEditor for editing the labels of aObject. |
ILcdGXYLabelPainter |
getGXYLabelPainter(Object aObject)
Finds an
ILcdGXYLabelPainter that can be used to label the object passed. |
int |
getLabelCount(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Return the number of labels for the currently set object.
|
int |
getLabelCreationClickCount()
Returns the number of points required to initialize the label of the set
Object . |
Cursor |
getLabelCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Returns a
Cursor to indicate the type of editing aMode and
aGXYContext . |
ILcdGXYPainterStyle |
getPinStyle()
Returns the painter style that is used when drawing the pin.
|
int[] |
getPositionList()
Returns the list of possible positions to place the labels.
|
int |
getPossibleLocationCount(Graphics aGraphics)
Returns the number of possible locations where this
ILcdGXYLabelPainter can
paint/draw the labels of the set domain Object . |
int |
getShiftLabelPosition()
Returns how many pixels the label must be removed from the anchor point of the domain object
when labels are not placed freely (i.e.
|
int |
getSubLabelCount(int aLabelIndex)
Returns the number of sublabels for the set object and the given label index.
|
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. |
boolean |
isMakeLabelsStickyOnEdit()
Returns whether this editor makes a label sticky when it edits this label.
|
boolean |
isWithPin()
Returns whether or not this painter draws a line (the "pin") from the label to the
anchor point of the domain object.
|
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.
|
void |
paintLabel(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Paints the label specified by
setObject , setLabelIndex and
setSubLabelIndex on aGraphics . |
static void |
setClassTraceOn(boolean aClassTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setMakeLabelsStickyOnEdit(boolean aMakeLabelsStickyOnEdit)
Determines whether this editor makes a label sticky when it edits this label.
|
void |
setPinStyle(ILcdGXYPainterStyle aPinStyle)
Sets the painter style to be used when painting the pin.
|
void |
setPositionList(int[] aPositionList)
Sets a new position list.
|
void |
setShiftLabelPosition(int aShift)
Sets how many pixels the label must be removed from the anchor point of the domain object
when labels are not placed freely (i.e.
|
void |
setWithPin(boolean aWithPin)
Specifies whether or not a line (the "pin") should be drawn from the label to the anchor
point of the domain object.
|
addPropertyChangeListener, firePropertyChangeEvent, getDisplayName, getLabelIndex, getLabelLocation, getLocationIndex, getObject, getSubLabelIndex, labelSnapTarget, removePropertyChangeListener, setDisplayName, setLabelIndex, setLabelLocation, setLocationIndex, setObject, setSubLabelIndex, supportLabelSnap
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getDisplayName, getLabelIndex, getLabelLocation, getObject, getSubLabelIndex, setLabelIndex, setLabelLocation, setObject, setSubLabelIndex
addPropertyChangeListener, removePropertyChangeListener
public static final int SOUTH_EAST
public static final int NORTH_WEST
public static final int NORTH_EAST
public static final int SOUTH_WEST
public static final int EAST
public static final int WEST
public static final int NORTH
public static final int SOUTH
public static final int CENTER
public static int MAXIMUM_AVAILABLE_LOCATIONS
public TLcdGXYLabelPainterAdapter(ILcdGXYPainter aDelegatePainter)
ILcdGXYPainter
. No ILcdGXYEditor
is set.aDelegatePainter
- the delegate painter.public TLcdGXYLabelPainterAdapter(ILcdGXYPainter aDelegatePainter, ILcdGXYEditor aDelegateEditor)
ILcdGXYPainter
and a ILcdGXYEditor
.aDelegatePainter
- the delegate painter.aDelegateEditor
- the delegate editor.public ILcdGXYPainter getDelegatePainter()
public boolean isWithPin()
true
if the pin is drawn, false
if not.public void setWithPin(boolean aWithPin)
aWithPin
- true
if the pin should be drawn, false
if not.public void setPinStyle(ILcdGXYPainterStyle aPinStyle)
setupGraphics
method
will be called right before the pin is drawn.aPinStyle
- The pin style to use when drawing the pin. This must not be null
.public ILcdGXYPainterStyle getPinStyle()
null
.public boolean isMakeLabelsStickyOnEdit()
false
true
if this label editor makes a label sticky when it edits this label,
false
otherwise.TLcdLabelLocation.STICKY_LABEL_LOCATION
public void setMakeLabelsStickyOnEdit(boolean aMakeLabelsStickyOnEdit)
aMakeLabelsStickyOnEdit
- true
if the label should be made sticky,
false
otherwise.isMakeLabelsStickyOnEdit()
public void paintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYLabelPainter2
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
paintLabel
in interface ILcdGXYLabelPainter2
aGraphics
- The graphics object to paint the label onaMode
- A bitwise combination of aGXYContext
- the drawing context for the labelILcdGXYLabelPainter.DEFAULT
,
ILcdGXYLabelPainter.SELECTED
protected void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aContext, Point aPointSFCT) throws TLcdNoBoundsException
ILcdGXYPainter
for
the Object to be painted (aGXYContext.getGXYLayer().getGXYPainter( aObject )
).
When the set TLcdLabelLocation
can retrieve an anchor point, this anchor
point should be returned.
aGraphics
- the Graphics for which the labels anchor point should be calculated.aMode
- the mode for the which the label anchor point should be calculated. Can be
ILcdGXYLabelPainter.SELECTED or ILcdGXYLabelPainter.DEFAULT.aContext
- the context in which this label will be painted.aPointSFCT
- the point that will be moved to the anchor point computed.TLcdNoBoundsException
- if the Object doesn't have any valid anchor point, e.g. if it is
always invisible in the current projection.public int getPossibleLocationCount(Graphics aGraphics)
ILcdGXYLabelPainter
ILcdGXYLabelPainter
can
paint/draw the labels of the set domain Object
.
The domain Object
for which the location count is retrieved should be set
before calling this method using the ILcdGXYLabelPainter.setObject(java.lang.Object)
method.
getPossibleLocationCount
in interface ILcdGXYLabelPainter
aGraphics
- the Graphics the label will be painted on.ILcdGXYLabelPainter
can
paint/draw the labels of the set Object.ILcdGXYLabelPainter.setLocationIndex(int)
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 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.
Please refer to paintLabel
for documentation
on which information is passed to the delegate painters.
labelBoundsSFCT
in interface ILcdGXYLabelPainter
labelBoundsSFCT
in interface ILcdGXYLabelPainter2
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
,
ILcdGXYLabelPainter2.labelAnchorPointSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Point)
public 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.
Please refer to paintLabel
for documentation
on which information is passed to the delegate painters.
isLabelTouched
in interface ILcdGXYLabelPainter2
aGraphics
- The Graphics
instance on which the label is painted.aMode
- the mode to consider. This is a bitwise combinations of several constants.
See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
for more information.aGXYContext
- the ILcdGXYContext
to consider.ILcdGXYContext
public 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.
Please refer to paintLabel
for documentation
on which information is passed to the delegate painters.
labelAnchorPointSFCT
in interface ILcdGXYLabelPainter2
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 ILcdGXYLabelPainter2.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.ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext)
,
ILcdGXYLabelPainter2.getLabelLocation()
,
ILcdGXYLabelPainter2.labelBoundsSFCT(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext, java.awt.Rectangle)
public Cursor getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ALcdGXYLabelPainter
Cursor
to indicate the type of editing aMode
and
aGXYContext
.
This default implementation always returns null
. Override this method if you want
to display custom cursors.
getLabelCursor
in interface ILcdGXYLabelPainter2
getLabelCursor
in class ALcdGXYLabelPainter
aGraphics
- The Graphics
instance on which the label is painted.aMode
- The mode to consider. See ILcdGXYLabelPainter2.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.public int getLabelCount(Graphics aGraphics, ILcdGXYContext aGXYContext)
Return the number of labels for the currently set object. The default implementation returns
1
. Override this method if you need to support multiple labels.
This implementation always returns 1.
getLabelCount
in interface ILcdGXYLabelEditor
getLabelCount
in interface ILcdGXYMultiLabelPainter
getLabelCount
in class ALcdGXYLabelPainter
aGraphics
- The Graphics
instance on which the labels would be painted.aGXYContext
- The context containing information about the layer and the view for which
the label would be drawn.0
.public int getSubLabelCount(int aLabelIndex)
Returns the number of sublabels for the set object and the given label index. The default
implementation returns 1
. Override this method if you need to support multiple
sublabels.
This implementation always returns 1.
getSubLabelCount
in interface ILcdGXYLabelEditor
getSubLabelCount
in interface ILcdGXYMultiLabelPainter
getSubLabelCount
in class ALcdGXYLabelPainter
aLabelIndex
- The label index for which you need to know the number of sublabels.0
.ALcdGXYLabelPainter.getLabelCount(java.awt.Graphics, com.luciad.view.gxy.ILcdGXYContext)
public ILcdGXYLabelEditor getGXYLabelEditor(Object aObject)
ILcdGXYLabelEditorProvider
Returns a valid ILcdGXYLabelEditor
for editing the labels of aObject. The
returned ILcdGXYLabelEditor
must have aObject
set on it. The
TLcdLabelLocation must not yet be set on it.
getGXYLabelEditor
in interface ILcdGXYLabelEditorProvider
aObject
- the Object for which to obtain a ILcdGXYLabelEditor
.ILcdGXYLabelEditor
for editing the labels of aObject
with aObject
set on it.ILcdGXYLabelEditor.setObject(java.lang.Object)
public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
ILcdGXYLabelPainterProvider
ILcdGXYLabelPainter
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;
}
getGXYLabelPainter
in interface ILcdGXYLabelPainterProvider
aObject
- the object to find a label painter forpublic boolean editLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYLabelEditor
Adapts the set TLcdLabelLocation
according to the information present in
aGXYContext. If the method returns true
, the TLcdLabelLocation
was
modified, if false
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 and
aGXYContext
. These should all be set before calling this method. Note that
if aMode
is one of the creating modes, the (sub) label indices are irrelevant.
editLabel
in interface ILcdGXYLabelEditor
aGraphics
- The Graphics
on which the label is painted.aMode
- the mode to consider when editing aObject: aMode shall be a combination of
ILcdGXYLabelEditor.TRANSLATED
,ILcdGXYLabelEditor.RESHAPED
, ILcdGXYLabelEditor.START_CREATION
,ILcdGXYLabelEditor.CREATING
, ILcdGXYLabelEditor.END_CREATION
.aGXYContext
- contains the information to consider when editing the set Object.ILcdGXYContext
public int getLabelCreationClickCount()
Object
.
This implementation always returns 0
.
getLabelCreationClickCount
in interface ILcdGXYLabelEditor
Object
or
-1 if this is undefined like for a polyline or a polygon. 0 means graphical creation
of labels is not supported.public boolean acceptSnapTargetForLabel(Graphics aGraphics, ILcdGXYContext aGXYContext)
ILcdGXYLabelEditor
Returns whether the label specified by setObject
, setLabelIndex
and
setSubLabelIndex
accepts the snap target in the given
ILcdGXYContext
.
The snap target is the Object
returned by aGXYContext.getSnapTarget()
,
and is on the ILcdGXYLayer
returned by aGXYContext.getSnapTargetLayer()
.
acceptSnapTargetForLabel
in interface ILcdGXYLabelEditor
aGraphics
- The Graphics
on which the label is painted.aGXYContext
- The ILcdGXYContext
containing the snapping information.true
if the label accepts the snap target, false
otherwise.ILcdGXYContext.getSnapTarget()
,
ILcdGXYContext.getSnapTargetLayer()
public Object clone()
ALcdGXYLabelPainter
ALcdGXYLabelPainter
. The label location
of the clone is a clone of the label location of the original. No other objects
are cloned.clone
in interface ILcdGXYLabelEditor
clone
in interface ILcdGXYLabelEditorProvider
clone
in interface ILcdGXYLabelPainter
clone
in interface ILcdGXYLabelPainter2
clone
in interface ILcdGXYLabelPainterProvider
clone
in class ALcdGXYLabelPainter
ALcdGXYLabelPainter
of which the label location
is a deep clone.public void setPositionList(int[] aPositionList)
Sets a new position list. This list is only used when the labels are not placed freely.
aPositionList
- the list of possible positions to place the labels.getPositionList()
public int[] getPositionList()
setPositionList(int[])
public void setShiftLabelPosition(int aShift)
Sets how many pixels the label must be removed from the anchor point of the domain object
when labels are not placed freely (i.e. getLabelLocation().getLocationIndex() != -1
).
If the position of the label is east
or west
, this shift is applied in
horizontal direction; if the position is north
or south
, this
shift is applied in vertical direction. In case of north east
, south east
, south west
or north west
, this
shift is applied in both directions. If the location of the label is center
,
the shift is ignored.
The default for this value is 20
pixels.
aShift
- the distance, expressed in pixels, that the label must be removed from the domain
object.getShiftLabelPosition()
public int getShiftLabelPosition()
getLabelLocation().getLocationIndex() != -1
).setShiftLabelPosition(int)
public static void setClassTraceOn(boolean aClassTraceOn)
true
then all log messages are recorded, otherwise only
the informative, warning and error messages are recorded.aClassTraceOn
- if true then all log messages are recorded,
otherwise only the informative, warning and error messages are recorded.