Class PointEditHandle
- All Implemented Interfaces:
IEditHandle
,AutoCloseable
Point
on the Map
and can be visualized using an icon.
It can be moved around, or react to mouse events.
The handle executes IPointEditAction
, based on mouse input events. IEditHandles
implementations configure concrete IPointEditAction
implementations on this handle to make sure they result in geometry or feature changes. For example, when this handle is dragged around on the Map
, an IEditHandles
implementation for polylines
can make sure that the second point of the polyline is moved.
This class supports the following gestures:
This handle is painted using an icon
at its current location.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
This interface allows to calculate a visual aid line based on the location of the handle. -
Constructor Summary
ConstructorDescriptionPointEditHandle
(Point initialLocation) Creates a newPointEditHandle
without associated actions.PointEditHandle
(Observable<@Nullable Point> locationProvider) Creates a newPointEditHandle
without associated actions. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addEditStateObserver
(IInvalidationCallback observer) Adds an observer that is called when theedit state
of this handle has changed.addOnClickAction
(IPointEditAction action, long clickCount) Adds an action that will be triggered when the handle is clicked or tapped (touch).addOnDragAction
(IPointEditAction action) Adds an action that will be triggered when the handle is dragged.addOnMouseMoveAction
(IPointEditAction action) Adds an action that will be executed on every mouse move.Adds an action that will be triggered when a long press is performed on a handle.void
close()
protected void
finalize()
Returns the icon to paint when the handle is in an active state.Returns the visual aid line style to use when this handle is in anactive
state.Returns the visual aid line style to use when this handle is in anactive
state.Returns the current state of this handle.Returns the icon to paint when the handle is in a highlighted state.Returns the visual aid complex stroke line style to use when this handle is in ahighlighted
state.Returns the visual aid line style to use when this handle is in ahighlighted
state.Returns the current location of this handle.Observable
<@Nullable Point> Returns the location provider of this handle.Observable
<@Nullable Point> Returns the location provider to use when the handle isactive
.Returns the current mouse cursor that should be displayed for this handle.Returns the move constraint of this point handle.Returns the icon to paint when the handle is in a regular state.Returns the visual aid complex stroke line style to use when this handle is in aninactive
state.Returns the visual aid line style to use when this handle is in aninactive
state.Returns the visual aid line provider that allows to paint a visual aid line together with this handle.int
Returns the Z-order that is used for this handle's paint calls to theFeatureCanvas
.boolean
Returns whether this handle should paint any icons itself.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
setActiveIcon
(IIcon icon) Sets the icon to paint when the handle is in an active state.void
Sets the visual aid line style to use when this handle is in anactive
state.void
setActiveVisualAidLineStyle
(LineStyle lineStyle) Sets the visual aid line style to use when this handle is in anactive
state.void
setHighlightedIcon
(IIcon icon) Sets the icon to paint when the handle is in a highlighted state.void
Sets the visual aid complex stroke line style to use when this handle is in ahighlighted
state.void
setHighlightedVisualAidLineStyle
(LineStyle lineStyle) Sets the visual aid line style to use when this handle is in ahighlighted
state.void
setInvalidationCallback
(IInvalidationCallback invalidationCallback) Sets the callback for the handle to call when its visual representation or cursor has changed.void
setLocationProviderWhenActive
(Observable<@Nullable Point> locationProviderWhenActive) Sets the location provider to use when the handle isactive
.void
setMoveConstraint
(EditMoveConstraint moveConstraint) Sets the move constraint of this point handle.void
setRegularIcon
(IIcon icon) Sets the icon to paint when the handle is in a regular state.void
Sets the visual aid complex stroke line style to use when this handle is in aninactive
state.void
setRegularVisualAidLineStyle
(LineStyle lineStyle) Sets the visual aid line style to use when this handle is in aninactive
state.void
setUseFeatureAsHandle
(boolean useFeatureAsHandle) Sets whether this handle should paint any icons itself.void
Sets the visual aid line provider that allows to paint a visual aid line together with this handle.void
setZOrder
(int zOrder) Sets the Z-order that is used for this handle's paint calls to theFeatureCanvas
.
-
Constructor Details
-
PointEditHandle
Creates a newPointEditHandle
without associated actions.- Parameters:
initialLocation
- the initial location of the handle, cannot benull
-
PointEditHandle
Creates a newPointEditHandle
without associated actions.- Parameters:
locationProvider
- the location provider of the handle. The handle assumes the location of this point upon construction, while alsoobserving
the point to adjust its own location whenever the observable point changes; 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
-
getLocation
Returns the current location of this handle.Note that this location is not necessarily equal to the
location provider
at all times. For example, they may differ when the handle is dragged around and no location changes are triggered in the location provider.- Returns:
- the current location of this handle
-
getLocationProvider
Returns the location provider of this handle.Note that the handle's
current location
is not necessarily equal to thislocation provider
at all times. For example, they may differ when the handle is dragged around and no location changes are triggered in this location provider. Additionally, the handle may have a different location provider when it is active. SeegetLocationProviderWhenActive
.- Returns:
- the location provider of this handle. Never
null
.
-
getLocationProviderWhenActive
Returns the location provider to use when the handle isactive
.Can be
null
if no distinct location provider is set for when the handle is active.- Returns:
- the location provider to use when the handle is
active
, ornull
.
-
setLocationProviderWhenActive
public void setLocationProviderWhenActive(@Nullable Observable<@Nullable Point> locationProviderWhenActive) Sets the location provider to use when the handle isactive
.If set, this overrides the
regular location provider
when the handle is active.Can be
null
.- Parameters:
locationProviderWhenActive
- the location provider to use when the handle isactive
.
-
getMoveConstraint
Returns the move constraint of this point handle.- Returns:
- the move constraint of this point handle.
-
setMoveConstraint
Sets the move constraint of this point handle.By default, this is
EditMoveConstraint#XY
.- Parameters:
moveConstraint
- the move constraint of this point handle.
-
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:
-
getRegularIcon
Returns the icon to paint when the handle is in a regular state.- Returns:
- the icon to paint when the handle is in a regular state.
- See Also:
-
setRegularIcon
Sets the icon to paint when the handle is in a regular state.This icon is only used when
setUseFeatureAsHandle
is set to false.- Parameters:
icon
- the icon to paint when the handle is in a regular (i.e. non-highlighted, non-active) state.
-
getHighlightedIcon
Returns the icon to paint when the handle is in a highlighted state.- Returns:
- the icon to paint when the handle is in a highlighted state.
- See Also:
-
setHighlightedIcon
Sets the icon to paint when the handle is in a highlighted state.This icon is only used when
setUseFeatureAsHandle
is set to false.- Parameters:
icon
- the icon to paint when the handle is in a highlighted state.
-
getActiveIcon
Returns the icon to paint when the handle is in an active state.- Returns:
- the icon to paint when the handle is in an active state.
- See Also:
-
setActiveIcon
Sets the icon to paint when the handle is in an active state.This icon is only used when
setUseFeatureAsHandle
is set to false.- Parameters:
icon
- the icon to paint when the handle is in an active state
-
isUseFeatureAsHandle
public boolean isUseFeatureAsHandle()Returns whether this handle should paint any icons itself.When set to true, this handle does not paint any icons itself.
- Returns:
- when this is set to true, this handle does not paint any icons for itself.
- See Also:
-
setUseFeatureAsHandle
public void setUseFeatureAsHandle(boolean useFeatureAsHandle) Sets whether this handle should paint any icons itself.When set to true, this handle does not paint any icons for itself. In this case, the handle considers the feature that is being edited for determining whether it is touched or not. Otherwise, when this is set to false, the handle paints itself as an icon and only considers that icon for deciding whether it is touched.
By default, this is false.
- Parameters:
useFeatureAsHandle
- when true, this handle does not paint any icons for itself.
-
setVisualAidLineProvider
Sets the visual aid line provider that allows to paint a visual aid line together with this handle.It is not possible to interact with this line. The line style can be configured using
setRegularVisualAidLineStyle
.If
null
, no visual aid line is painted. The default isnull
.- Parameters:
provider
- the visual aid line provider.
-
getVisualAidLineProvider
Returns the visual aid line provider that allows to paint a visual aid line together with this handle.- Returns:
- the visual aid line provider
- See Also:
-
getRegularVisualAidLineStyle
Returns the visual aid line style to use when this handle is in aninactive
state.This method is linked to the
getRegularVisualAidComplexStrokeLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid line style to use when this handle is in an
inactive
state. - See Also:
- if both of them return
-
getRegularVisualAidComplexStrokeLineStyle
Returns the visual aid complex stroke line style to use when this handle is in aninactive
state.This method is linked to the
getRegularVisualAidLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid complex stroke line style to use when this handle is in an
inactive
state. - Since:
- 2023.1
- See Also:
- if both of them return
-
setRegularVisualAidLineStyle
Sets the visual aid line style to use when this handle is in aninactive
state.This style is only used when a visual aid line is
set
.Only one regular 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.The default is a small, grey line.
- Parameters:
lineStyle
- the visual aid line style to use when this handle is in aninactive
state.
-
setRegularVisualAidComplexStrokeLineStyle
Sets the visual aid complex stroke line style to use when this handle is in aninactive
state.This style is only used when a visual aid line is
set
.Only one regular line style can be set, if this function is called with a non
null
value when aLineStyle
has already been set, it will be overwritten.The default is
null
, as alinestyle
is used as default regular visual aid style.- Parameters:
lineStyle
- the visual aid complex stroke line style to use when this handle is in aninactive
state.- Since:
- 2023.1
-
getHighlightedVisualAidLineStyle
Returns the visual aid line style to use when this handle is in ahighlighted
state.This method is linked to the
getHighlightedVisualAidComplexStrokeLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid line style to use when this handle is in a
highlighted
state. - See Also:
- if both of them return
-
getHighlightedVisualAidComplexStrokeLineStyle
Returns the visual aid complex stroke line style to use when this handle is in ahighlighted
state.This method is linked to the
getHighlightedVisualAidLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid complex stroke line style to use when this handle is in a
highlighted
state. - Since:
- 2023.1
- See Also:
- if both of them return
-
setHighlightedVisualAidLineStyle
Sets the visual aid line style to use when this handle is in ahighlighted
state.This style is only used when a visual aid line is
set
.Only one regular 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.The default is a small, grey line.
- Parameters:
lineStyle
- the visual aid line style to use when this handle is in ahighlighted
state.
-
setHighlightedVisualAidComplexStrokeLineStyle
public void setHighlightedVisualAidComplexStrokeLineStyle(@Nullable ComplexStrokeLineStyle lineStyle) Sets the visual aid complex stroke line style to use when this handle is in ahighlighted
state.This style is only used when a visual aid line is
set
.Only one highlighted line style can be set, if this function is called with a non
null
value when aLineStyle
has already been set, it will be overwritten.The default is
null
, as alinestyle
is used as default highlighted visual aid style.- Parameters:
lineStyle
- the visual aid complex stroke line style to use when this handle is in ahighlighted
state.- Since:
- 2023.1
-
getActiveVisualAidLineStyle
Returns the visual aid line style to use when this handle is in anactive
state.This method is linked to the
getActiveVisualAidComplexStrokeLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid line style to use when this handle is in an
active
state. - See Also:
- if both of them return
-
getActiveVisualAidComplexStrokeLineStyle
Returns the visual aid line style to use when this handle is in anactive
state.This method is linked to the
getActiveVisualAidLineStyle
method:- if both of them return
null
, no visual aid line is painted - if one of them is not
null
, that line style is used - it's not possible for both methods to return a non
null
value: they are mutually exclusive
- Returns:
- the visual aid complex stroke line style to use when this handle is in an
active
state. - Since:
- 2023.1
- See Also:
- if both of them return
-
setActiveVisualAidLineStyle
Sets the visual aid line style to use when this handle is in anactive
state.This style is only used when a visual aid line is
set
.Only one active 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.The default is a small, grey line.
- Parameters:
lineStyle
- the visual aid line style to use when this handle is in anactive
state.
-
setActiveVisualAidComplexStrokeLineStyle
Sets the visual aid line style to use when this handle is in anactive
state.This style is only used when a visual aid line is
set
.Only one active line style can be set, if this function is called with a non
null
value when aLineStyle
has already been set, it will be overwritten.The default is
null
, as alinestyle
is used as default active visual aid style.- Parameters:
lineStyle
- the visual aid complex stroke line style to use when this handle is in aEditHandleState#Active
state.- Since:
- 2023.1
-
addOnClickAction
@NotNull public EditActionBinder addOnClickAction(@NotNull IPointEditAction action, long clickCount) Adds an action that will be triggered when the handle is clicked or tapped (touch).- Parameters:
action
- the action to be performed on click, cannot benull
.clickCount
- the action will only be performed when an event is received with this click count- Returns:
- an object on which more options or requirements can be specified regarding the given on-click action, such as the mouse buttons that need to be pressed for the action to be executed.
-
addOnTouchLongPressAction
Adds an action that will be triggered when a long press is performed on a handle.- Parameters:
action
- the action to be performed, cannot benull
.- Returns:
- an object on which more options or requirements can be specified regarding the given on-drag action
-
addOnDragAction
Adds an action that will be triggered when the handle is dragged.The given action is executed at least when the drag gesture
starts
andends
, and ifEditActionBinder#performOnIntermediateEvents
is set to true, it also gets executed on everyintermediate
drag event. The action is always called with anEventStatus
parameter corresponding to the drag event.- Parameters:
action
- the action to be performed on drag, cannot benull
.- Returns:
- an object on which more options or requirements can be specified regarding the given on-drag action, such as the mouse buttons that need to be pressed for the action to be executed.
-
addOnMouseMoveAction
Adds an action that will be executed on every mouse move.- Parameters:
action
- the action to be performed during the mouse move, cannot benull
.- Returns:
- an object on which more options or requirements can be specified regarding the given action, such as the modifier keys that need to be pressed for the action to be executed.
-