public class TLcdGXYOffsetIconPainter extends ALcdGXYLabelPainter implements ILcdGXYLabelPainter2, ILcdGXYLabelPainterProvider, ILcdGXYLabelEditor, ILcdGXYLabelEditorProvider, ILcdGXYPainter, ILcdGXYPainterProvider, ILcdGXYEditor, ILcdGXYEditorProvider
ILcdGXYPainter
that paints objects at a certain offset.
This typically applies to objects which are painted as icons. This can be useful to avoid clutter in areas on the map where there
are a lot of domain object clustered together, by moving the representations away from each
other.
The offset icon is painted as a label, so that existing label decluttering algorithms can be
reused to declutter the icons. It paints this label when the label
index
and sublabel index
are both 0
.
This painter is
ILcdGXYPainter
, to draw the anchor points (where the icon would normally
be located). The painting of this anchor point is delegated to the ILcdGXYPainter
specified in the constructor.ILcdGXYLabelPainter
to draw the offset icon as a label and to draw the labels of the
delegate label painter. The painting of the offset icon is delegated to the ILcdGXYPainter
specified in the constructor. The painting of the other labels is delegated to the ILcdGXYLabelPainter
specified in the constructor, if there is one.ILcdGXYEditor
so that the domain object can be moved. This editing is delegated to the
ILcdGXYEditor
specified in the constructor.ILcdGXYLabelEditor
so that the domain object can be moved when the label is moved and so that
the icon offset can be changed using the mouse. This label editing is not delegated.Following image illustrates the usage of the delegate painters:
The offset icon is always painted as the label specified by the label index 0
and
the sublabel index 0
.
This class supports snapping:
ILcdGXYEditor
specified in the constructor of this class. When the context
contains a snapping target accepted by that editor, the editor will snap the domain object
to that snap target.This painter must be used as ILcdGXYPainter
, ILcdGXYEditor
,
ILcdGXYLabelPainter
and ILcdGXYLabelEditor
for correct
operation.
This painter is also a provider for all of these interfaces. It always returns itself as painter, editor, label painter and label editor.
Remarks:
( null, null )
to the delegate label painter's
getLabelCount
method when this offset icon painter is configured to paint all labels
as sublabels (cfr. TLcdGXYOffsetIconPainter
) ; the delegate label
painter should take this possibility into account.TLcdGXYStampLabelPainter
. The interactive labels will be positioned as if there
was no offset, which results in erratic behavior.setLabeled(true)
on the layer.TLcdGXYSelectController2
.setLabelsEditable(true)
on the layer is required because the offset icons are treated as labels.TLcdGXYEditController2
.paintLabel
,
Serialized FormModifier 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.
|
BODY, CREATING, HANDLES, RESHAPING, SNAPS, TRANSLATING
DEFAULT, SELECTED
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
BODY, CREATING, DEFAULT, HANDLES, RESHAPING, SELECTED, SNAPS, TRANSLATING
CREATING, END_CREATION, RESHAPED, START_CREATION, TRANSLATED
Constructor and Description |
---|
TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter,
ILcdGXYPainter aDelegateOffsetIconPainter,
ILcdGXYEditor aDelegateOffsetEditor,
ILcdGXYLabelPainter aDelegateLabelPainter)
Creates an offset icon painter that delegates its operations to the specified painters and
editor.
|
TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter,
ILcdGXYPainter aDelegateOffsetIconPainter,
ILcdGXYEditor aDelegateOffsetEditor,
ILcdGXYLabelPainter aDelegateLabelPainter,
boolean aMapAllToSublabels)
Creates an offset icon painter that delegates its operations to the specified painters and
editor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
acceptSnapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the object set to the editor can be edited so that (part of) the object snaps to the object passed
as snap target in the context.
|
boolean |
acceptSnapTargetForLabel(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the label specified by
setObject , setLabelIndex and
setSubLabelIndex accepts the snap target in the given
ILcdGXYContext . |
void |
anchorPointSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
Point aPointSFCT)
Moves the Point passed to the location (in view coordinates, pixels) of the anchor point of the representation of
the object in the given mode taking into account the given context.
|
void |
boundsSFCT(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext,
ILcd2DEditableBounds aBoundsSFCT)
Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object
in the given mode taking into account the given context.
|
Object |
clone()
Returns a new instance of this
ALcdGXYLabelPainter . |
boolean |
edit(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Defines how an object shall be edited by this editor, taking into account the mode and the
context passed.
|
boolean |
editLabel(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Adapts the set
TLcdLabelLocation according to the information present in
aGXYContext. |
int |
getCreationClickCount()
Returns the number user interactions required to complete the initialization of an object set to this editor.
|
Cursor |
getCursor(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Returns a cursor that clarifies the mode and context the painter is operating in.
|
ILcdGXYPainter |
getDelegateAnchorPainter()
Returns the delegate anchor painter that was specified in the constructor.
|
ILcdGXYLabelPainter |
getDelegateLabelPainter()
Returns the delegate label painter that was specified in the constructor.
|
ILcdGXYEditor |
getDelegateOffsetEditor()
Returns the delegate editor that was specified in the constructor.
|
ILcdGXYPainter |
getDelegateOffsetIconPainter()
Returns the delegate icon painter that was specified in the constructor.
|
String |
getDisplayName()
This default implementation returns the display name set with
setDisplayName , or toString() if this was set to null . |
protected ILcdPoint |
getFocusPoint()
Returns the focus point of the set object if it is an
ILcdShape . |
ILcdGXYEditor |
getGXYEditor(Object aObject)
Finds an
ILcdGXYEditor that can be used to edit the object passed. |
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. |
ILcdGXYPainter |
getGXYPainter(Object aObject)
Finds an
ILcdGXYPainter that can be used to paint or locate 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.
|
ILcdIcon |
getSnapIcon()
Returns the
ILcdIcon to paint snap target points of the object set to this
painter. |
int |
getSubLabelCount(int aLabelIndex)
Returns the number of sublabels for the set object and the given label index.
|
boolean |
isDisplayLabels()
Returns whether this painter will paint the labels of the delegate label painter.
|
boolean |
isDisplayOffsetIcons()
Returns whether this painter paints the offset icons.
|
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 |
isTouched(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Checks if the representation of the object in the given mode is touched at the location as defined in the
supplied context.
|
boolean |
isWithPin()
Returns whether or not this painter draws a line (the "pin") from the offset icon 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.
|
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 |
paint(Graphics aGraphics,
int aMode,
ILcdGXYContext aGXYContext)
Displays the representation of the object in the given mode on the Graphics passed, taking into account the
supplied context.
|
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 |
setDisplayLabels(boolean aDisplayLabels)
Configures whether the regular labels should be painted.
|
void |
setDisplayOffsetIcons(boolean aDisplayOffsetIcons)
Configures whether this painter should paint the offset icons.
|
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 |
setSnapIcon(ILcdIcon aSnapIcon)
Sets the
ILcdIcon to paint snap target points of the object set to this
painter. |
void |
setWithPin(boolean aWithPin)
Specifies whether or not a line (the "pin") should be drawn from the offset icon to the anchor
point of the domain object.
|
Object |
snapTarget(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns an object that can be used as snapping target when graphically editing an object.
|
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. |
boolean |
supportSnap(Graphics aGraphics,
ILcdGXYContext aGXYContext)
Returns whether the painter can provide a snap target based on the representation of the object in the given
context.
|
addPropertyChangeListener, firePropertyChangeEvent, getLabelIndex, getLabelLocation, getLocationIndex, getObject, getSubLabelIndex, removePropertyChangeListener, setDisplayName, setLabelIndex, setLabelLocation, setLocationIndex, setObject, setSubLabelIndex
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLabelLocation, setLabelLocation, setObject
getLabelIndex, getSubLabelIndex, setLabelIndex, setSubLabelIndex
getLocationIndex, getObject, setLocationIndex
getLabelIndex, getLabelLocation, getObject, getSubLabelIndex, setLabelIndex, setLabelLocation, setObject, setSubLabelIndex
getObject, setObject
getObject, setObject
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 TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter, ILcdGXYPainter aDelegateOffsetIconPainter, ILcdGXYEditor aDelegateOffsetEditor, ILcdGXYLabelPainter aDelegateLabelPainter)
Creates an offset icon painter that delegates its operations to the specified painters and
editor. If aDelegateLabelPainterThis
is not an instance of
ILcdGXYLabelPainter2
, this offset icon painter will be configured to use
sublabels. The overloading constructor can be used if you want to set this option
explicitly.
public TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter, ILcdGXYPainter aDelegateOffsetIconPainter, ILcdGXYEditor aDelegateOffsetEditor, ILcdGXYLabelPainter aDelegateLabelPainter, boolean aMapAllToSublabels)
Creates an offset icon painter that delegates its operations to the specified painters and editor.
The aMapAllToSublabels
flag determines how the label- and sublabel indices are
mapped from the delegate label painter to this label painter.
This is especially useful for decluttering behavior, which can differ for labels and sublabels.
Please refer to
paintLabel
for a table visualizing this mapping.
aDelegateAnchorPainter
- The ILcdGXYPainter
that will be used to paint
the anchor. This parameter must not be null
aDelegateOffsetIconPainter
- The ILcdGXYPainter
that will be used to paint
the offset representation. This will typically be some sort
of icon painter. This parameter must not be
null
.aDelegateOffsetEditor
- The ILcdGXYEditor
that will be used to edit the
domain object on user interaction. This editor must not be
null
if this painter will be used as an editor.aDelegateLabelPainter
- The ILcdGXYLabelPainter
that will be used to
paint the regular labels. This parameter may be
null
if no regular labels need to be painted.aMapAllToSublabels
- If true
, the getLabelCount
method
will always return 1
. All labels of
aDelegateLabelPainter
and their sublabels are
drawn as sublabels of this one label, together with the label
representing the offset icon. If false
, only the
label indices will be shifted to compensate for the offset
icon, but the sublabel indices will remain the same.public ILcdGXYPainter getDelegateAnchorPainter()
null
.TLcdGXYOffsetIconPainter
public ILcdGXYPainter getDelegateOffsetIconPainter()
null
.TLcdGXYOffsetIconPainter
public ILcdGXYEditor getDelegateOffsetEditor()
null
.TLcdGXYOffsetIconPainter
public ILcdGXYLabelPainter getDelegateLabelPainter()
null
.TLcdGXYOffsetIconPainter
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 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 ILcdIcon getSnapIcon()
Returns the ILcdIcon
to paint snap target points of the object set to this
painter. This icon is only used when the mouse is near the offset icon. Otherwise the snapping
functionality is delegated to the anchor painter.
ILcdIcon
to paint snap the snap target when the context indicates a
location near the offset icon.setSnapIcon(com.luciad.gui.ILcdIcon)
public void setSnapIcon(ILcdIcon aSnapIcon)
Sets the ILcdIcon
to paint snap target points of the object set to this
painter. This icon is only used when the mouse is near the offset icon. Otherwise the snapping
functionality is delegated to the anchor painter.
aSnapIcon
- The ILcdIcon
to paint snap the snap target when the context
indicates a location near the offset icon.getSnapIcon()
public String getDisplayName()
ALcdGXYLabelPainter
setDisplayName
, or toString()
if this was set to null
.getDisplayName
in interface ILcdGXYEditor
getDisplayName
in interface ILcdGXYLabelEditor
getDisplayName
in interface ILcdGXYLabelPainter2
getDisplayName
in interface ILcdGXYPainter
getDisplayName
in class ALcdGXYLabelPainter
ILcdGXYLabelPainter2
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.
If this label painter is configured to paint all labels as sublabels (cfr the
constructor
) this will always return 1
. Otherwise this method will return the
number of labels as specified by the delegate label painter, plus 1
for the offset
icon.
Please refer to paintLabel
for documention on how the label- and sublabel indices set on this label painter
are mapped to the label- and sublabel indices of the delegate label painter.
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.
If this label painter is configured to paint all labels as sublabels (cfr the constructor
)
this will return the sum of all the sublabels of all the labels as specified by the delegate
label painter, plus one for the offset icon.
Otherwise it returns 1
when aLabelIndex
is 0
, for the
offset icon, or the subLabelCount
of the label with index
aLabelIndex - 1
as specified by the delegate label painter.
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 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 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.
If the label index and sublabel index are both 0
, this method tests whether the
offset icon is touched, otherwise the delegate label painter is used to determine whether the
specified label is touched.
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.
If the label index and sublabel index are both 0
, this method sets aPointSFCT
to the anchor point of the offset icon; otherwise the delegate label painter is used to
determine the anchor point.
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 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.
If the label index and sublabel index are both 0
, this method sets
aRectangleSFCT
to the bounds of the offset icon; otherwise the delegate label
painter is used to determine the bounds.
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 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
When the label- and sublabel index are both 0
, the offset icon is painted. This
icon is painted by the delegate offset icon painter. The graphics and the context passed to
this ILcdGXYPainter
are modified to take the offset into account, given by the
set TLcdLabelLocation
.
If any other combination of label- and sublabel index is set, this combination is mapped to
the corresponding label- and sublabel index of the delegate label painter, as explained in the
table below. The graphics and the context given to the delegate label painters are
modified to take the offset into account, as well as the label location. The label location
given to the delegate label painter is modified so that it cancels the offset of the icon. This
allows the label painter to keep painting a line to the anchor point of the domain object.
In this case the offset is retrieved from the ILcdGXYEditableLabelsLayer
in the
given context: it is specified by the label location of the label with label- and sublabel
index 0
.
The table below visualizes the mapping from label- and sublabel indices of the delegate label painter to the label- and sublabel indices of this label painter. In this table the example is given of a delegate label painter that has two labels: one with two sublabels, and the second with three sublabels.
Delegate label painter | Mapping with aMapAllToSublabels == false | Mapping with aMapAllToSublabels == true | |||
---|---|---|---|---|---|
Label index | Sublabel index | Label index | Sublabel index | Label index | Sublabel index |
Offset icon | 0 | 0 | 0 | 0 | |
0 | 0 | 1 | 0 | 1 | |
1 | 1 | 2 | |||
1 | 0 | 2 | 0 | 3 | |
1 | 1 | 4 | |||
2 | 2 | 5 |
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
public boolean supportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
ALcdGXYLabelPainter
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.
This default implementation returns false
. Override this method if you want to
support snapping.
supportLabelSnap
in interface ILcdGXYLabelPainter2
supportLabelSnap
in class ALcdGXYLabelPainter
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
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 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 boolean editLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
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.
In case aMode == ILcdGXYLabelEditor.TRANSLATED
:
When the set label- and sublabel index indicate the offset icon, this method will translate
the domain object (ie. not the label position) using the delegate editor
specified in the constructor. The set label location will not be changed, unless its label
edit mode indicates absolute placement
.
If the set label- and sublabel index indicate another label, the set label location will
only be changed if its label edit mode indicates absolute placement.
In case aMode == ILcdGXYLabelEditor.RESHAPED
:
The set label location will be adjusted according to the given context. This means that
for the offset icon the offset will be changed, and for the regular labels their position
will be changed.
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.paintLabel
public int getLabelCreationClickCount()
ILcdGXYLabelEditor
Object
.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 void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
ILcdGXYPainter
The anchor point is an important point of the representation, typically the point which would be used
when the object would be represented as a single point. The anchor point is mostly used to attach extra information
to the representation of an object, for example, using labels. A typical implementation of this method for painters
which can handle ILcdShape
objects is the location of the focus point of the shape.
anchorPointSFCT
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is painted in (see class documentation)aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.aPointSFCT
- the point that has to be moved to the location of the anchor point of the representation of
the object. This point must not be taken into account when the method has thrown a TLcdNoBoundsException.TLcdNoBoundsException
- if no anchor point can be determined for the representation of the object.
This can be when the object does not have a representation in the given context, for example when it is located in
a part of the world which is not visible in the projection as set in the views world reference.paint
public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.
The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model
space for ILcdBounded
objects.
This painter delegates this call to the delegate anchor painter specified in the constructor
.
boundsSFCT
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation). For example, an object may be
represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation
must take this different representation into account.aGXYContext
- the context for which the representation of the object is painted. It contains amongst others
the transformations from model to world and world to view.aBoundsSFCT
- the bounds that must be adapted to encompass the representation of the object in the given
mode and context. These bounds must not be taken into account when the method has thrown an exception.TLcdNoBoundsException
- if no bounds can be determined for the representation of the object.
This can happen when the object does not have a representation in the given context, for example when it is located
in a part of the world which is not visible in the current view.isTouched
public Cursor getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
ILcdGXYPainter
TRANSLATING
, the cursor could be the MOVE cursor.
When no specific cursor is required implementations must return null.getCursor
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the rendering mode to return the cursor for.aGXYContext
- the context in which the rendering occurs.Cursor
to indicate the type of operating
aMode
and aGXYContext
. Returns
null
if no particular Cursor
is required.public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
The location that must be taken into account to check whether the representation is touched can be retrieved from
the context passed with the methods
ILcdGXYContext.getX()
and ILcdGXYContext.getY()
.
If the check is part of an ongoing operation of
user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also
be taken into account using the methods
ILcdGXYContext.getDeltaX()
and ILcdGXYContext.getDeltaY()
.
The context contains the transformations required to convert this location into the equivalent location in
model space. Implementations of this interface usually follow either of the following patterns:
As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.
The boundsSFCT
is often used to speed up the performance of this method as a location outside these bounds can never
touch the representation of the object.
Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.
This painter delegates this call to the delegate anchor painter specified in the constructor
.
isTouched
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented inaGXYContext
- contains the location of the interaction and the transformations to convert this location into
model coordinatesboundsSFCT
public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:
The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.
When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for
interpreting interaction on the representation of an object and modifying the representation of the object
accordingly. The painter is not responsible for modifying the object itself, this is done by
a corresponding ILcdGXYEditor
.
Implementations of ILcdGXYPainter
and ILcdGXYEditor
interfaces must be consistent for
an object: the painter must display the result of the user interaction on the object, while the editor is
responsible for modifying the object as a result of the user interaction.
A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter
and ILcdGXYEditor
interfaces in a single class.
When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as
snap target by the method snapTarget
must be painted in order to provide the user with a visual indication of the snap target.
The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.
This painter delegates this call to the delegate anchor painter specified in the constructor
.
paint
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- the mode the object is represented in (see class documentation).aGXYContext
- the ILcdGXYContext
the drawing depends on.protected ILcdPoint getFocusPoint()
ILcdShape
. Override this
method if you want this painter to be able to work with domain objects that are no
ILcdShape
.ILcdShape
, null
otherwise.public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
This method must only be called when supportSnap
returns true for the given context.
If the set object is an ILcdShape
and the offset icon is touched (taking the
given context into account), this method returns the focus point
of the set shape as the snap target. Otherwise it lets the delegate anchor painter
handle this call.
snapTarget
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.supportSnap
public Object labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
ALcdGXYLabelPainter
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
).
This default implementation always returns null
. Override this method if you want
to support snapping.
labelSnapTarget
in interface ILcdGXYLabelPainter2
labelSnapTarget
in class ALcdGXYLabelPainter
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
.public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
This painter supports snapping if the getFocusPoint
method returns a
non-null
value, or if the delegate anchor painter supports snapping.
supportSnap
in interface ILcdGXYPainter
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context in which this object is represented and in which the editing of an object occurs.public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
ILcdGXYEditor
edit
method with this
context passed should edit the object so that (part of) the object snaps to the object passed
as snap target in the context.
The context contains information on the user interaction at hand: the current location of the
user interaction, given by its
X
and
Y
coordinates, and
the
distance in X direction
and
distance in Y direction
over which the user interaction is taking place.
For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged.
The context also contains the candidate
snap target
and the
layer the snap target is contained in
.
acceptSnapTarget
in interface ILcdGXYEditor
aGraphics
- the Graphics on which the representation of the object is paintedaGXYContext
- the context containing the information on the user interaction and the snap target.ILcdGXYContext.getSnapTarget()
public boolean edit(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
The mode passed indicates how the interaction should be interpreted. It can be one of the following:
TRANSLATED
RESHAPED
START_CREATION
CREATING
END_CREATION
The first two modes designate that the object should be modified, the last three modes are passed
when initializing an object. From an implementation point of view there is no difference between TRANSLATED and
RESHAPED. These constants only differ in semantics. For ILcdShape
objects TRANSLATED can be seen
as the mode that will be passed when the shape as a whole is moved. RESHAPED is used more often for moving part of
a shape.
The context contains information on the user interaction at hand. The methods
getX
and
getY
contain the location(s) of the user interaction. The methods
getDeltaX
and
getDeltaY
contain the distance(s) over which the user interaction is taking place. For example, getX
and
getY
may contain the current mouse location while getDeltaX
and getDeltaY
contain the distance over which the mouse has been dragged. The editing behavior can take into
account multiple locations, to respond to, for example, multi-touch input.
When a snap target is accepted, the implementation of this method should take that fact into account when editing or initializing an object.
This call is delegated to the delegate anchor editor specified in the
constructor
.
The specified mode is modified so the ILcdGXYEditor.RESHAPED
constant is
replaced by the ILcdGXYEditor.TRANSLATED
constant.
edit
in interface ILcdGXYEditor
aGraphics
- the Graphics on which the representation of the object is paintedaMode
- indicates how the user interaction should be interpreted. Is one of the following:
TRANSLATED
,
RESHAPED
,
START_CREATION
,
CREATING
,
END_CREATION
.
aGXYContext
- contains information on the user interaction and
the transformations to transform from view space to the object model space.ILcdGXYContext
,
acceptSnapTarget
public int getCreationClickCount()
ILcdGXYEditor
getCreationClickCount
in interface ILcdGXYEditor
public ILcdGXYPainter getGXYPainter(Object aObject)
ILcdGXYPainterProvider
ILcdGXYPainter
that can be used to paint or locate the object passed.
The painter provider is responsible for setting the object to the painter before returning the painter. An implementation should therefore have the following structure:
public ILcdGXYPainter getGXYPainter(Object aObject) {
ILcdGXYPainter painter = ... // find the painter for the object
if (painter != null) {
painter.setObject(aObject);
}
return painter;
}
getGXYPainter
in interface ILcdGXYPainterProvider
aObject
- the object to find a painter forpublic ILcdGXYEditor getGXYEditor(Object aObject)
ILcdGXYEditorProvider
ILcdGXYEditor
that can be used to edit the object passed.
The editor provider is responsible for setting the object to the editor before returning the editor. An implementation should therefore have the following structure:
public ILcdGXYEditor getGXYEditor(Object aObject) {
ILcdGXYEditor editor = ... // find the editor for the object
editor.setObject( aObject );
return editor;
}
getGXYEditor
in interface ILcdGXYEditorProvider
aObject
- the object to find an editor forpublic 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 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 void setDisplayLabels(boolean aDisplayLabels)
Configures whether the regular labels should be painted. If this property is
false
, the labels of the delegate label painter are not painted. This is useful
when adjusting the layer to respect its labeled property: since the offset icon is painted as a
label, the layer should always be labeled. You can extend layer implementation to always paint
labels, but let this label painter then respect the labeled property of this layer.
aDisplayLabels
- false
if you do not want the labels of the delegate label
painter to be drawn, true
otherwise.public boolean isDisplayLabels()
Returns whether this painter will paint the labels of the delegate label painter.
true
if the labels are painted, false otherwise.setDisplayLabels(boolean)
public boolean isDisplayOffsetIcons()
setDisplayLabels
for how this property can be useful.true
if this painter paints the offset icons, false
otherwisepublic void setDisplayOffsetIcons(boolean aDisplayOffsetIcons)
Configures whether this painter should paint the offset icons.
aDisplayOffsetIcons
- true
if this painter should paint the offset icons,
false
otherwise.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 ILcdCloneable
clone
in interface ILcdGXYEditorProvider
clone
in interface ILcdGXYLabelEditor
clone
in interface ILcdGXYLabelEditorProvider
clone
in interface ILcdGXYLabelPainter
clone
in interface ILcdGXYLabelPainter2
clone
in interface ILcdGXYLabelPainterProvider
clone
in interface ILcdGXYPainterProvider
clone
in class ALcdGXYLabelPainter
ALcdGXYLabelPainter
of which the label location
is a deep clone.Object.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.