Interface ILcdGXYEditableLabelsLayer
- All Superinterfaces:
ILcdGXYLayer
,ILcdLayer
,ILcdPropertyChangeSource
,ILcdSelection<Object>
,Serializable
- All Known Implementing Classes:
TLcdGXYAsynchronousEditableLabelsLayerTreeNodeWrapper
,TLcdGXYAsynchronousEditableLabelsLayerWrapper
,TLcdGXYLayer
,TLcdGXYLayerTreeNode
,TLcdKML22GXYLayer
,TLcdPOLLayer
,TLcdS52GXYCatalogueLayer
,TLcdS52GXYLayer
,TLcdVPFLayer
,TLcdWMSProxyGXYLayer
,TLcyAreaOfInterestLayer
,TLcyPIMGXYLayer
,TLcySnappableGXYLayer
,com.luciad.internal.lucy.map.TLcyStyledSnappableGXYLayer
,TLfnGXYVectorLayer
This extension of ILcdGXYLayer
adds extra methods to allow querying and changing
what labels get painted and where the labels are placed.
This allows to perform the following tasks:
- select objects by clicking on their labels using a
select controller
- drag around labels using an
edit controller
- declutter labels and/or influence their locations using a
view label placer
ILcdGXYEditableLabelsLayer
instances have an associated ALcdLabelLocations
. This ALcdLabelLocations
instance contains the information about
which labels have been drawn and where these drawn labels are located. The position of the labels
can be adjusted by modifying the information in this ALcdLabelLocations
instance.
Implementations of this class should make sure to update the information in the
ALcdLabelLocations
instance when they paint labels.
See getLabelLocations
for more information.
To fully support all information specified in TLcdLabelLocation
, this layer
implementation requires the use of an ILcdGXYLabelPainter2
.
This label painter interface allows setting a TLcdLabelLocation
on it, so that
it can visualize all label editing changes.
To allow iterating over the objects and labels that are to be painted,
this interface defines two methods to interact with the painted
geometry representations
and label representations
.
This interface also introduces the notion of a label editor
.
Similar to the regular ILcdGXYEditor
, it provides the ability to graphically edit
the locations and shape of the labels.
- Since:
- 7.0
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Paint mode to indicate that only labels that are already placed by an external label placer should be painted. -
Method Summary
Modifier and TypeMethodDescriptionint
applyOnInteract
(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view.int
applyOnInteractLabels
(ILcdFunction aLabelFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all labels that are contained (partially or completely) in the bounds of the view.getGXYLabelEditor
(Object aObject) Retrieves the label editor for the given object.default ILcdGXYLabelingAlgorithm
Returns the label algorithm to use for the given label ID.Returns theALcdLabelLocations
instance which contains all the information about the labels of this layer.boolean
This flag determines if the labels are editable, i.e. if they can be moved by the user.boolean
This property determines whether the layer is equipped to let the user edit the labels.void
paint
(Graphics aGraphics, int aMode, ILcdGXYView aGXYView) Paints the combined representation of the layer's objects for a view, taking into account the mode.void
setLabelsEditable
(boolean aLabelsEditable) This flag determines if the labels are editable, i.e. if they can be moved by the user.Methods inherited from interface com.luciad.view.gxy.ILcdGXYLayer
applyOnInteract, getBounds, getGXYEditor, getGXYLabelPainter, getGXYPainter, getGXYPen, getLabelMapScaleRange, getLabelScaleRange, getMapScaleRange, getModelXYWorldTransfoClass, getScaleRange, isLabeled, isLabeledSupported, setLabeled, stopPainting
Methods inherited from interface com.luciad.view.ILcdLayer
clearSelection, fireCollectedSelectionChanges, getIcon, getLabel, getModel, isEditable, isEditableSupported, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setIcon, setLabel, setSelectable, setVisible
Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource
addPropertyChangeListener, removePropertyChangeListener
Methods inherited from interface com.luciad.util.ILcdSelection
addSelectionListener, getSelectedObjects, getSelectionCount, isSelected, removeSelectionListener, selectedObjects
-
Field Details
-
PLACED_LABELS
static final int PLACED_LABELSPaint mode to indicate that only labels that are already placed by an external label placer should be painted. The already placed labels can be set and retrieved from theALcdLabelLocations
retrieved usinggetLabelLocations()
. They can be painted by first iterating over all painted label locations (ALcdLabelLocations.applyOnPaintedLabelLocations(com.luciad.view.ILcdView, com.luciad.view.ALcdLabelLocations.LabelLocationFunction)
) and then using these label locations to setup the label painter retrieved fromILcdGXYLayer.getGXYLabelPainter(Object)
.- See Also:
-
-
Method Details
-
getGXYLabelEditor
Retrieves the label editor for the given object. This label editor can be used to move the label foraObject
to a different location.- Parameters:
aObject
- The object for which to retrieve the label editor. This object should not benull
and should be contained in the model of this layer.- Returns:
- The editor for
aObject
. This editor should already haveaObject
set on it. TheTLcdLabelLocation
however still needs tobe set
.
-
getGXYLabelingAlgorithm
Returns the label algorithm to use for the given label ID.- Parameters:
aLabel
- the identifier defining the label and its associated domain object- Returns:
- the label algorithm, or
null
to rely on the label painter - Since:
- 2020.0
-
isLabelsEditable
boolean isLabelsEditable()This flag determines if the labels are editable, i.e. if they can be moved by the user. Note that the labels can however still be moved by, for instance, labeling algorithms.- Returns:
true
if the labels can be moved and reshaped by the user,false
otherwise.
-
setLabelsEditable
void setLabelsEditable(boolean aLabelsEditable) This flag determines if the labels are editable, i.e. if they can be moved by the user. Note that the labels can however still be moved by, for instance, labeling algorithms.- Parameters:
aLabelsEditable
-true
if you want the user to be able to move and reshape the labels,false
otherwise.
-
isLabelsEditableSupported
boolean isLabelsEditableSupported()This property determines whether the layer is equipped to let the user edit the labels. More specifically this property determines whether the layer can provide anILcdGXYLabelEditor
for its objects.- Returns:
true
if the layer is equipped with label editors,false
otherwise.
-
getLabelLocations
ALcdLabelLocations getLabelLocations()Returns the
ALcdLabelLocations
instance which contains all the information about the labels of this layer. You can use this instance to retrieve which labelshave been drawn
and where these labelsare located
.This instance can also be used to
alter
the location of the labels. As this method always returns the same instance, changes made to the returnedALcdLabelLocations
instance immediately effect all other clients of this layer.If the location of a label is changed, the layer should be invalidated using the
invalidateGXYLayer
method of theILcdGXYView
.- Returns:
- The
ALcdLabelLocations
instance. It never isnull
.
-
paint
Paints the combined representation of the layer's objects for a view, taking into account the mode.The mode indicates what objects of the model should be taken into account and what representation should be provided. The objects to be taken into account shall be one of:
- ALL: all the objects in the layer's model, or
- SELECTION: all the objects in the layer's selection.
Note that the combined representation may contain less than the representation of all objects that were taken into account, as some objects may be disregarded for various reasons (filters, scale, ... ). When the views scale is outside the scale range (BODIES or HANDLES mode) or the label scale range (LABELS mode) nothing shall be painted.
The representations provided shall be one or more of:
- BODIES: the combination of geometric representations of the objects,
- HANDLES: the handles for the objects. These are the parts of the objects representation on which user interaction can be applied. For example, for a circle this can be the center point, allowing to move the circle.
- LABELS: the combination of the textual representations of the objects.
The mode supplied shall be a bitwise or combination of a constant of the first group and one or more of the second group. When painting in BODIES or HANDLES mode, painting of an object shall be delegated to the
painter
for that object, when the LABELS mode is passed, painting shall be delegated to thelabelpainter
for that object.The view is passed to provide contextual information: some of the objects may have a different representation depending on the view, or depending on a property of the view, for example, the scale of the view.
The combined representation of the objects has to be painted on the Graphics supplied, as these may be different from the Graphics provided by the view (due to double buffering, for example).
When
stopPainting
is called, the current painting operation should be aborted.If this layer is asked to paint its labels, it must inform its
ALcdLabelLocations
instance as to which labels have been painted and which haven't been.The paint mode may contain
PLACED_LABELS
. This is a paint mode to indicate that only labels that are already placed should be painted. The already placed labels can be retrieved from theALcdLabelLocations
retrieved usinggetLabelLocations()
.- Specified by:
paint
in interfaceILcdGXYLayer
- Parameters:
aGraphics
- the Graphics to paint on.aMode
- indicates what should be painted and how it should be painted.aGXYView
- the view to paint for.- See Also:
-
applyOnInteract
int applyOnInteract(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all objects that are contained (partially or completely) in the bounds of the view. This method behaves similar to the paint method, and as such is allowed to omit small or invisible objects for performance reasons. For example, it can disregard objects that are outside the scale range.The function shall be applied successively to all objects in the bounds as long as the function returns
true
for an object. This allows developers to indicate a stop condition. Note that the order in which the objects are passed to the function is not specified.The mode indicates what objects of the model should be taken into account. The objects to be taken into account shall be one of:
- ALL: all the objects in the layer's model, or
- SELECTION: all the objects in the layer's selection.
The representations provided shall be a combination of one or more of:
- BODIES: the combination of geometric representations of the objects,
- HANDLES: the handles for the objects,
- LABELS: the combination of the textual representations of the objects.
The mode supplied shall be a bitwise 'or' combination of a constant of the first group and a combination of constants of the second group.
- Parameters:
aFunction
- the function to apply. When the function returnsfalse
, no more objects should be passed to the function.aGraphics
- the graphicsaPaintMode
- the paint mode.aGXYView
- the view in whose bounds the objects representations should be in order to be passed to the function. Note that for efficiency reasons (e.g. to avoid expensive bounds calculations) objects may be passed that are not inside the view bounds.- Returns:
- the number of objects the function was applied on.
-
applyOnInteractLabels
int applyOnInteractLabels(ILcdFunction aLabelFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView) Applies the function to (at the least) all labels that are contained (partially or completely) in the bounds of the view. This method behaves similar to the paint method, and as such is allowed to omit labels for small or invisible objects for performance reasons. For example, it can disregard labels for objects outside the scale range, or labels outside the label scale range.The function shall be applied successively to all labels in the bounds as long as the function returns
true
for a label. This allows developers to indicate a stop condition. Note that the order in which the labels are passed to the function is not specified.The mode indicates what labels should be taken into account. The labels to be taken into account shall be one of:
- ALL: all the labels in the layer's model, or
- SELECTION: all the labels in the layer's selection.
The representations provided shall be a combination of one or more of:
- BODIES: the combination of label representations of the objects,
- HANDLES: the handles for the labeled objects,
- LABELS: the combination of the textual labels representations of the objects.
The mode supplied shall be a bitwise 'or' combination of a constant of the first group and a combination of constants of the second group.
- Parameters:
aLabelFunction
- the function to apply. When the function returnsfalse
, no more labels should be passed to the function. The Object passed to this function is always aTLcdLabelIdentifier
.aGraphics
- the graphicsaPaintMode
- the paint mode.aGXYView
- the view in whose bounds the objects representations should be in order passed to the function. Note that for efficiency reasons (e.g. to avoid expensive bounds calculations) objects may be passed that are not inside the view bounds.- Returns:
- the number of objects the function was applied on.
-