public final class TranslateEditHandle extends Object implements AutoCloseable, IEditHandle
ITranslateEditAction
.
This handle can operate in 2 modes: 1) Feature
mode: the handle is highlighted and can be interacted with when the feature is touched.
Feature
being painted.
2) Shadow geometry mode: this mode is enabled when a shadow geometry provider
is configured that provides a non-null
shadow geometry. A shadow geometry is a draped
version of a geometry. In that case the handle is highlighted and can be interacted with when that shadow geometry is touched.
If the shadow geometry provider returns null
, Feature
mode is enabled.
This handle uses drag events
to call ITranslateEditAction#translate
.
Constructor and Description |
---|
TranslateEditHandle(CoordinateReference reference,
FeatureEditContext context)
Creates a new translate handle that allows you to drag around a feature or geometry horizontally.
|
Modifier and Type | Method and Description |
---|---|
void |
addEditStateObserver(IInvalidationCallback observer)
Adds an observer that is called when the
edit state of this handle has changed. |
EditActionBinder |
addOnDragAction(ITranslateEditAction action)
Adds an action that will be triggered when dragging.
|
void |
close() |
protected void |
finalize() |
EditHandleState |
getEditState() |
MouseCursor |
getMouseCursor() |
ComplexStrokeLineStyle |
getShadowComplexStrokeLineStyle()
Returns the complex stroke line style that is used for shadow lines.
|
FillStyle |
getShadowFillStyle() |
Geometry |
getShadowGeometry() |
Observable<Geometry> |
getShadowGeometryProvider() |
IIcon |
getShadowIcon() |
LineStyle |
getShadowLineStyle()
Returns the line style that is used for shadow lines.
|
int |
getZOrder() |
EventResult |
onEvent(IInputEvent inputEvent,
FeatureEditContext context)
Handles the given event, and returns if the event was consumed or not.
|
void |
paint(FeatureCanvas canvas,
FeatureEditContext context)
Paints this handle on the given canvas.
|
void |
removeEditStateObserver(IInvalidationCallback observer)
Removes the given observer.
|
void |
setInvalidationCallback(IInvalidationCallback invalidationCallback)
Sets the callback for the handle to call when its visual representation or cursor has changed.
|
void |
setShadowComplexStrokeLineStyle(ComplexStrokeLineStyle style)
Sets the complex stroke line style that is used for shadow lines.
|
void |
setShadowFillStyle(FillStyle style)
Fill style that is used when a
shadow version of a geometry is painted. |
void |
setShadowGeometryProvider(Observable<Geometry> shadowGeometryProvider)
Sets the shadow geometry provider of this handle.
|
void |
setShadowIcon(IIcon icon) |
void |
setShadowLineStyle(LineStyle style)
Sets the line style that is used for shadow lines.
|
void |
setZOrder(int zOrder)
Sets the Z-order that is used for this handle's paint calls to the
FeatureCanvas . |
public TranslateEditHandle(@NotNull CoordinateReference reference, @NotNull FeatureEditContext context)
reference
- the coordinate reference in which the translation will occur, cannot be null
context
- the context, cannot be null
public void close()
close
in interface AutoCloseable
@NotNull public EventResult onEvent(@NotNull IInputEvent inputEvent, @NotNull FeatureEditContext context) throws NullPointerException
While handling events, IEditHandles
can mark themselves as highlighted or as Active. Related to event handling, the main effect of this is that highlighted or active handles get a higher priority compared to other handles: they get the chance to consume events first. See EditHandleState
onEvent
in interface IEditHandle
inputEvent
- the event to handle, cannot be null
context
- the context, cannot be null
NullPointerException
- when null
is passed.public void paint(@NotNull FeatureCanvas canvas, @NotNull FeatureEditContext context)
This method is called when
IEditHandles
fires an EditHandlesEvent
containing this handle, when the handle is newly added or removed for example.
invalidation callback
.
This method only gets called on the UI thread, so there is no need for additional synchronization.
paint
in interface IEditHandle
canvas
- the canvas on which this handle gets painted.context
- the context, cannot be null
@NotNull public EditHandleState getEditState()
getEditState
in interface IEditHandle
@Nullable public MouseCursor getMouseCursor()
getMouseCursor
in interface IEditHandle
null
can be returned.public void setInvalidationCallback(@Nullable IInvalidationCallback invalidationCallback)
Calling this callback triggers a new call to this handle's paint
method.
setInvalidationCallback
in interface IEditHandle
invalidationCallback
- the callback for the handle to call when its visual representation has changedpublic void addEditStateObserver(@NotNull IInvalidationCallback observer) throws IllegalArgumentException
edit state
of this handle has changed.
Adding the same observer twice is forbidden, and will cause an exception to be thrown.
addEditStateObserver
in interface IEditHandle
observer
- an observerIllegalArgumentException
- when the observer was already added.public void removeEditStateObserver(@NotNull IInvalidationCallback observer) throws IllegalArgumentException
If the given observer was never added, an exception is thrown.
removeEditStateObserver
in interface IEditHandle
observer
- an observerIllegalArgumentException
- when the observer is not known.@Nullable public Geometry getShadowGeometry()
null
.setShadowGeometryProvider
@Nullable public Observable<Geometry> getShadowGeometryProvider()
null
.public void setShadowGeometryProvider(@Nullable Observable<Geometry> shadowGeometryProvider)
When this provider (or the geometry it returned) is null
, Feature
mode is enabled for this handle. See TranslateEditHandle
for more information.
shadowGeometryProvider
- the shadow geometry provider that is used by this handle. Can be null
to disable the shadow geometry mode.@Nullable public IIcon getShadowIcon()
shadow version
of a geometry is paintedpublic void setShadowIcon(@Nullable IIcon icon)
icon
- the icon that is used when a shadow version
of a geometry is painted@Nullable public LineStyle getShadowLineStyle()
This method is linked to the getShadowComplexStrokeLineStyle
method:
null
, no shadow line is painted
null
, that shadow line style is used
null
value: they are mutually exclusive
public void setShadowLineStyle(@Nullable LineStyle style)
Only one shadow line style can be set, if this function is called with a non null
value when a ComplexStrokeLineStyle
has already been set, it will be overwritten.
style
- the line style that is used for shadow lines.@Nullable public ComplexStrokeLineStyle getShadowComplexStrokeLineStyle()
This method is linked to the getShadowLineStyle
method:
null
, no shadow line is painted
null
, that shadow line style is used
null
value: they are mutually exclusive
public void setShadowComplexStrokeLineStyle(@Nullable ComplexStrokeLineStyle style)
Only one shadow line style can be set, if this function is called with a non null
value when a ComplexStrokeLineStyle
has already been set, it will be overwritten.
style
- the complex stroke line style that is used for shadow lines.@Nullable public FillStyle getShadowFillStyle()
shadow version
of a geometry is paintedpublic void setShadowFillStyle(@Nullable FillStyle style)
shadow version
of a geometry is painted.
Setting this to null
means the shadow version of the geometry won't have a fill style.
style
- fill style that is used when a shadow version of a geometry is painted.public int getZOrder()
FeatureCanvas
.setZOrder
,
FeatureCanvas
,
FeatureCanvas.IconDrawCommand#zOrder
public void setZOrder(int zOrder)
FeatureCanvas
.
This Z-order determines which handles are painted on top, when multiple handles overlap. Edit handles with a higher Z-order are painted on top of handles with a lower Z-order. Note: Highlighted
edit handles are always painted above regular handles, and active
handles are always painted above highlighted handles. The default value is 0.
zOrder
- the Z-order that is used for this handle's paint calls to the FeatureCanvas
. Must be between [-1000,1000].FeatureCanvas
,
FeatureCanvas.IconDrawCommand#zOrder
@NotNull public EditActionBinder addOnDragAction(@NotNull ITranslateEditAction action)
For every drag event, the following method call will be triggered:
ITranslateEditAction#translate
at the end of the drag sequence, or on every drag update when EditActionBinder#performOnIntermediateEvents
is set to true
action
- the action to be performed on drag, cannot be null
.