public interface ILcdGXYEditableLabelsLayer extends ILcdGXYLayer
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 controller
edit controller
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.
Modifier and Type | Field and Description |
---|---|
static int |
PLACED_LABELS
Paint mode to indicate that only labels that are already placed by an external label placer
should be painted.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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.
|
ILcdGXYLabelEditor |
getGXYLabelEditor(Object aObject)
Retrieves the label editor for the given object.
|
default ILcdGXYLabelingAlgorithm |
getGXYLabelingAlgorithm(TLcdLabelIdentifier aLabel)
Returns the label algorithm to use for the given label ID.
|
ALcdLabelLocations |
getLabelLocations()
Returns the
ALcdLabelLocations instance which contains all the information
about the labels of this layer. |
boolean |
isLabelsEditable()
This flag determines if the labels are editable, i.e. if they can be moved by the user.
|
boolean |
isLabelsEditableSupported()
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.
|
applyOnInteract, getBounds, getGXYEditor, getGXYLabelPainter, getGXYPainter, getGXYPen, getLabelMapScaleRange, getLabelScaleRange, getMapScaleRange, getModelXYWorldTransfoClass, getScaleRange, isLabeled, isLabeledSupported, setLabeled, stopPainting
clearSelection, fireCollectedSelectionChanges, getIcon, getLabel, getModel, isEditable, isEditableSupported, isSelectable, isSelectableSupported, isVisible, selectObject, setEditable, setIcon, setLabel, setSelectable, setVisible
addSelectionListener, getSelectedObjects, getSelectionCount, isSelected, removeSelectionListener, selectedObjects
addPropertyChangeListener, removePropertyChangeListener
static final int PLACED_LABELS
ALcdLabelLocations
retrieved using getLabelLocations()
.
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 from ILcdGXYLayer.getGXYLabelPainter(Object)
.ILcdGXYLabelEditor getGXYLabelEditor(Object aObject)
aObject
to a different location.aObject
- The object for which to retrieve the label editor. This object should not be
null
and should be contained in the model of this layer.aObject
. This editor should already have
aObject
set on it. The TLcdLabelLocation
however still needs
to be
set
.default ILcdGXYLabelingAlgorithm getGXYLabelingAlgorithm(TLcdLabelIdentifier aLabel)
aLabel
- the identifier defining the label and its associated domain objectnull
to rely on the label painterboolean isLabelsEditable()
true
if the labels can be moved and reshaped by the user,
false
otherwise.void setLabelsEditable(boolean aLabelsEditable)
aLabelsEditable
- true
if you want the user to be able to move and reshape
the labels, false
otherwise.boolean isLabelsEditableSupported()
ILcdGXYLabelEditor
for its objects.true
if the layer is equipped with label editors, false
otherwise.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 labels have been drawn
and where these labels are 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
returned ALcdLabelLocations
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
the ILcdGXYView
.
ALcdLabelLocations
instance. It never is null
.void paint(Graphics aGraphics, int aMode, ILcdGXYView aGXYView)
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:
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:
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 the labelpainter
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 the ALcdLabelLocations
retrieved using
getLabelLocations()
.
paint
in interface ILcdGXYLayer
aGraphics
- the Graphics to paint on.aMode
- indicates what should be painted and how it should be painted.aGXYView
- the view to paint for.ILcdGXYLayer.getGXYPainter(Object)
,
ILcdGXYLayer.getGXYLabelPainter(Object)
,
ILcdGXYLayer.getScaleRange()
,
ILcdGXYLayer.getLabelScaleRange()
,
ILcdGXYLayer.stopPainting()
int applyOnInteract(ILcdFunction aFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView)
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:
The representations provided shall be a combination of one or more of:
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.
aFunction
- the function to apply. When the function returns false
, 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.int applyOnInteractLabels(ILcdFunction aLabelFunction, Graphics aGraphics, int aPaintMode, ILcdGXYView aGXYView)
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:
The representations provided shall be a combination of one or more of:
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.
aLabelFunction
- the function to apply. When the function returns false
, no
more labels should be passed to the function. The Object passed to this
function is always a TLcdLabelIdentifier
.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.