Class LineEditHandle
- All Implemented Interfaces:
IEditHandle,AutoCloseable
Map and can be visualized using a line.
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 circles can make sure that the circle can expand/shrink.
This class supports the following gestures:
This handle is painted using the provided geometry.
- Since:
- 2025.0
-
Constructor Summary
ConstructorsConstructorDescriptionLineEditHandle(Geometry geometry) Creates a newLineEditHandlewithout associated actions.LineEditHandle(Observable<@Nullable Geometry> geometryProvider) Creates aLineEditHandlewithout associated actions. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEditStateObserver(IInvalidationCallback observer) Adds an observer that is called when theedit stateof 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.voidclose()booleanprotected voidfinalize()Returns the visual aid line style to use when this handle is in anactivestate.Returns the current state of this handle.Returns the current geometry of this handle.Observable<@Nullable Geometry> Returns the geometry provider of this handle.Returns the visual aid line style to use when this handle is in ahighlightedstate.Returns the current mouse cursor that should be displayed for this handle.Returns the visual aid line style to use when this handle is in aninactivestate.intReturns the Z-order that is used for this handle's paint calls to theFeatureCanvas.inthashCode()onEvent(IInputEvent inputEvent, FeatureEditContext context) Handles the given event, and returns if the event was consumed or not.voidpaint(FeatureCanvas canvas, FeatureEditContext context) Paints this handle on the given canvas.voidremoveEditStateObserver(IInvalidationCallback observer) Removes the given observer.voidsetActiveLineStyle(LineStyle lineStyle) Sets the line style to use when this handle is in anactivestate.voidsetHighlightedLineStyle(LineStyle lineStyle) Sets the line style to use when this handle is in ahighlightedstate.voidsetInvalidationCallback(IInvalidationCallback invalidationCallback) Sets the callback for the handle to call when its visual representation or cursor has changed.voidsetRegularLineStyle(LineStyle lineStyle) Sets the line style to use when this handle is in aninactivestate.voidsetZOrder(int zOrder) Sets the Z-order that is used for this handle's paint calls to theFeatureCanvas.
-
Constructor Details
-
LineEditHandle
Creates a newLineEditHandlewithout associated actions.- Parameters:
geometry- the initial geometry of the handle, cannot benull
-
LineEditHandle
Creates aLineEditHandlewithout associated actions.- Parameters:
geometryProvider- the geometry provider of the handle. The handle assumes the geometry of this point upon construction, while alsoobservingthe geometry to adjust its own shape whenever the observable geometry changes; cannot benull.
-
-
Method Details
-
finalize
protected void finalize() -
close
public void close()- Specified by:
closein 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,
IEditHandlescan 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:
onEventin interfaceIEditHandle- Parameters:
inputEvent- the event to handle, cannot benullcontext- the context, cannot benull- Returns:
- if the event was consumed or not
- Throws:
NullPointerException- whennullis passed.
-
paint
Paints this handle on the given canvas.This method is called when
- the handle's
IEditHandlesfires anEditHandlesEventcontaining 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:
paintin 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:
getEditStatein 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,
nullcan be returned.- Specified by:
getMouseCursorin 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
paintmethod.- Specified by:
setInvalidationCallbackin 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 stateof this handle has changed.Adding the same observer twice is forbidden, and will cause an exception to be thrown.
- Specified by:
addEditStateObserverin 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:
removeEditStateObserverin interfaceIEditHandle- Parameters:
observer- an observer- Throws:
IllegalArgumentException- when the observer is not known.- Since:
- 2023.1
-
getGeometry
Returns the current geometry of this handle.Note that this geometry is not necessarily equal to the
geometry providerat all times. For example, they may differ when the handle is dragged around and no geometry changes are triggered in the geometry provider.- Returns:
- the current geometry of this handle
-
getGeometryProvider
Returns the geometry provider of this handle.Note that the handle's
current geometryis not necessarily equal to thisgeometry providerat all times. For example, they may differ when the handle is dragged around and no geometry changes are triggered in this geometry provider.- Returns:
- the geometry provider of this handle. Never
null.
-
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:
Highlightededit handles are always painted above regular handles, andactivehandles 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:
-
getRegularLineStyle
Returns the visual aid line style to use when this handle is in aninactivestate.- Returns:
- The visual aid line style to use when this handle is in an
inactivestate.
-
setRegularLineStyle
Sets the line style to use when this handle is in aninactivestate.- Parameters:
lineStyle- The line style to use when this handle is in aninactivestate.
-
getHighlightedLineStyle
Returns the visual aid line style to use when this handle is in ahighlightedstate.- Returns:
- The visual aid line style to use when this handle is in a
highlightedstate.
-
setHighlightedLineStyle
Sets the line style to use when this handle is in ahighlightedstate.- Parameters:
lineStyle- The line style to use when this handle is in ahighlightedstate.
-
getActiveLineStyle
Returns the visual aid line style to use when this handle is in anactivestate.- Returns:
- The visual aid line style to use when this handle is in an
activestate.
-
setActiveLineStyle
Sets the line style to use when this handle is in anactivestate.- Parameters:
lineStyle- The line style to use when this handle is in anactivestate.
-
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, cannot benull.clickCount- the action will only be performed when an event is received with this click count.- Returns:
- an object to specify more options or requirements for 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 to specify more options or requirements for 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
startsandends, and ifEditActionBinder#performOnIntermediateEventsis set to true, it also gets executed on everyintermediatedrag event. The action is always called with anEventStatusparameter corresponding to the drag event.- Parameters:
action- the action to be performed on drag, cannot benull.- Returns:
- an object to specify more options or requirements for 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 to specify more options or requirements for the given action, such as the modifier keys that need to be pressed for the action to be executed.
-
hashCode
public int hashCode() -
equals
-