Class TranslateEditHandle
- All Implemented Interfaces:
IEditHandle
,AutoCloseable
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.
- the handle does not paint anything. It depends on the original
Feature
being painted. - you can drag the feature
- the EditHandleState and cursor are changed accordingly
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.
- the handle paints a shadow geometry
- you can drag the shadow instead of the feature
- the EditHandleState and cursor are changed accordingly
If the shadow geometry provider returns null
, Feature
mode is enabled.
This handle uses drag events
to call ITranslateEditAction#translate
.
-
Constructor Summary
ConstructorDescriptionTranslateEditHandle
(CoordinateReference reference, FeatureEditContext context) Creates a new translate handle that allows you to drag around a feature or geometry horizontally. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEditStateObserver
(IInvalidationCallback observer) Adds an observer that is called when theedit state
of this handle has changed.addOnDragAction
(ITranslateEditAction action) Adds an action that will be triggered when dragging.void
close()
protected void
finalize()
Returns the current state of this handle.Returns the current mouse cursor that should be displayed for this handle.Returns the complex stroke line style that is used for shadow lines.Returns the fill style that is used when ashadow version
of a geometry is painted.Returns the current shadow geometry of this handle, ornull
.Observable
<@Nullable Geometry> Returns the shadow geometry provider of this handle.Returns the icon that is used when ashadow version
of a geometry is painted.Returns the line style that is used for shadow lines.int
Returns the Z-order that is used for this handle's paint calls to theFeatureCanvas
.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
Sets the complex stroke line style that is used for shadow lines.void
setShadowFillStyle
(FillStyle style) Sets the fill style that is used when ashadow version
of a geometry is painted.void
setShadowGeometryProvider
(Observable<@Nullable Geometry> shadowGeometryProvider) Sets the shadow geometry provider of this handle.void
setShadowIcon
(IIcon icon) Sets the icon that is used when ashadow version
of a geometry is painted.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 theFeatureCanvas
.
-
Constructor Details
-
TranslateEditHandle
public TranslateEditHandle(@NotNull CoordinateReference reference, @NotNull FeatureEditContext context) Creates a new translate handle that allows you to drag around a feature or geometry horizontally.- Parameters:
reference
- the coordinate reference in which the translation will occur, cannot benull
context
- the context, cannot benull
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
close
in interfaceAutoCloseable
-
onEvent
@NotNull public EventResult onEvent(@NotNull IInputEvent inputEvent, @NotNull FeatureEditContext context) throws NullPointerException Handles the given event, and returns if the event was consumed or not.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- Specified by:
onEvent
in interfaceIEditHandle
- Parameters:
inputEvent
- the event to handle, cannot benull
context
- the context, cannot benull
- Returns:
- if the event was consumed or not
- Throws:
NullPointerException
- whennull
is passed.
-
paint
Paints this handle on the given canvas.This method is called when
- the handle's
IEditHandles
fires anEditHandlesEvent
containing this handle, when the handle is newly added or removed for example. - the handle triggers a new paint call itself by calling its
invalidation callback
.
This method only gets called on the UI thread, so there is no need for additional synchronization.
- Specified by:
paint
in interfaceIEditHandle
- Parameters:
canvas
- the canvas on which this handle gets painted.context
- the context, cannot benull
- the handle's
-
getEditState
Returns the current state of this handle.- Specified by:
getEditState
in interfaceIEditHandle
- Returns:
- the current state of this handle.
-
getMouseCursor
Returns the current mouse cursor that should be displayed for this handle.This method typically returns a value when this handle is highlighted or active. If not,
null
can be returned.- Specified by:
getMouseCursor
in interfaceIEditHandle
- Returns:
- the current mouse cursor that should be displayed for this handle.
-
setInvalidationCallback
Sets the callback for the handle to call when its visual representation or cursor has changed.Calling this callback triggers a new call to this handle's
paint
method.- Specified by:
setInvalidationCallback
in interfaceIEditHandle
- Parameters:
invalidationCallback
- the callback for the handle to call when its visual representation has changed
-
addEditStateObserver
public void addEditStateObserver(@NotNull IInvalidationCallback observer) throws IllegalArgumentException Adds an observer that is called when theedit state
of this handle has changed.Adding the same observer twice is forbidden, and will cause an exception to be thrown.
- Specified by:
addEditStateObserver
in interfaceIEditHandle
- Parameters:
observer
- an observer- Throws:
IllegalArgumentException
- when the observer was already added.- Since:
- 2023.1
-
removeEditStateObserver
public void removeEditStateObserver(@NotNull IInvalidationCallback observer) throws IllegalArgumentException Removes the given observer.If the given observer was never added, an exception is thrown.
- Specified by:
removeEditStateObserver
in interfaceIEditHandle
- Parameters:
observer
- an observer- Throws:
IllegalArgumentException
- when the observer is not known.- Since:
- 2023.1
-
getShadowGeometry
Returns the current shadow geometry of this handle, ornull
.- Returns:
- the current shadow geometry of this handle, or
null
. - See Also:
-
getShadowGeometryProvider
Returns the shadow geometry provider of this handle.Can be
null
.- Returns:
- the shadow geometry provider of this handle, or
null
.
-
setShadowGeometryProvider
public void setShadowGeometryProvider(@Nullable Observable<@Nullable Geometry> shadowGeometryProvider) Sets the shadow geometry provider of this handle.When this provider (or the geometry it returned) is
null
,Feature
mode is enabled for this handle. SeeTranslateEditHandle
for more information.- Parameters:
shadowGeometryProvider
- the shadow geometry provider that is used by this handle. Can benull
to disable the shadow geometry mode.
-
getShadowIcon
Returns the icon that is used when ashadow version
of a geometry is painted.- Returns:
- the icon that is used when a
shadow version
of a geometry is painted.
-
setShadowIcon
Sets the icon that is used when ashadow version
of a geometry is painted.- Parameters:
icon
- the icon that is used when ashadow version
of a geometry is painted.
-
getShadowLineStyle
Returns the line style that is used for shadow lines.This method is linked to the
getShadowComplexStrokeLineStyle
method:- if both of them return
null
, no shadow line is painted - if one of them is not
null
, that shadow line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the line style that is used for shadow lines.
- if both of them return
-
setShadowLineStyle
Sets the line style that is used for shadow lines.Only one shadow line style can be set, if this function is called with a non
null
value when aComplexStrokeLineStyle
has already been set, it will be overwritten.- Parameters:
style
- the line style that is used for shadow lines.
-
getShadowComplexStrokeLineStyle
Returns the complex stroke line style that is used for shadow lines.This method is linked to the
getShadowLineStyle
method:- if both of them return
null
, no shadow line is painted - if one of them is not
null
, that shadow line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the complex stroke line style that is used for shadow lines.
- Since:
- 2023.1
- if both of them return
-
setShadowComplexStrokeLineStyle
Sets the complex stroke line style that is used for shadow lines.Only one shadow line style can be set, if this function is called with a non
null
value when aComplexStrokeLineStyle
has already been set, it will be overwritten.- Parameters:
style
- the complex stroke line style that is used for shadow lines.- Since:
- 2023.1
-
getShadowFillStyle
Returns the fill style that is used when ashadow version
of a geometry is painted.- Returns:
- the fill style that is used when a
shadow version
of a geometry is painted.
-
setShadowFillStyle
Sets the fill style that is used when ashadow version
of a geometry is painted.Setting this to
null
means the shadow version of the geometry won't have a fill style.- Parameters:
style
- fill style that is used when a shadow version of a geometry is painted.
-
getZOrder
public int getZOrder()Returns the Z-order that is used for this handle's paint calls to theFeatureCanvas
.- Returns:
- the Z-order that is used for this handle's paint calls to the
FeatureCanvas
. - See Also:
-
setZOrder
public void setZOrder(int zOrder) Sets the Z-order that is used for this handle's paint calls to theFeatureCanvas
.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, andactive
handles are always painted above highlighted handles.Must be between [-1000,1000]. The default value is 0.
- Parameters:
zOrder
- the Z-order that is used for this handle's paint calls to theFeatureCanvas
.- See Also:
-
addOnDragAction
Adds an action that will be triggered when dragging.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 whenEditActionBinder#performOnIntermediateEvents
is set to true
- Parameters:
action
- the action to be performed on drag, cannot benull
.- Returns:
- an object on which you can specify more options or requirements regarding the given on-drag action, such as the mouse buttons that need to be pressed for the action to be executed.
-