Class TranslateEditHandle

java.lang.Object
com.luciad.edit.handles.TranslateEditHandle
All Implemented Interfaces:
IEditHandle, AutoCloseable

public final class TranslateEditHandle extends Object implements AutoCloseable, IEditHandle
This handle allows you to translate a feature by translating its geometry using 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 Details Link icon

    • TranslateEditHandle Link icon

      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 be null
      context - the context, cannot be null
  • Method Details Link icon

    • finalize Link icon

      protected void finalize()
      Overrides:
      finalize in class Object
    • close Link icon

      public void close()
      Specified by:
      close in interface AutoCloseable
    • onEvent Link icon

      @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 interface IEditHandle
      Parameters:
      inputEvent - the event to handle, cannot be null
      context - the context, cannot be null
      Returns:
      if the event was consumed or not
      Throws:
      NullPointerException - when null is passed.
    • paint Link icon

      public void paint(@NotNull FeatureCanvas canvas, @NotNull FeatureEditContext context)
      Paints this handle on the given canvas.

      This method is called when

      This method only gets called on the UI thread, so there is no need for additional synchronization.

      Specified by:
      paint in interface IEditHandle
      Parameters:
      canvas - the canvas on which this handle gets painted.
      context - the context, cannot be null
    • getEditState Link icon

      @NotNull public EditHandleState getEditState()
      Returns the current state of this handle.
      Specified by:
      getEditState in interface IEditHandle
      Returns:
      the current state of this handle.
    • getMouseCursor Link icon

      @Nullable public MouseCursor 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 interface IEditHandle
      Returns:
      the current mouse cursor that should be displayed for this handle.
    • setInvalidationCallback Link icon

      public void setInvalidationCallback(@Nullable IInvalidationCallback invalidationCallback)
      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 interface IEditHandle
      Parameters:
      invalidationCallback - the callback for the handle to call when its visual representation has changed
    • addEditStateObserver Link icon

      public void addEditStateObserver(@NotNull IInvalidationCallback observer) throws IllegalArgumentException
      Adds an observer that is called when the edit 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 interface IEditHandle
      Parameters:
      observer - an observer
      Throws:
      IllegalArgumentException - when the observer was already added.
      Since:
      2023.1
    • removeEditStateObserver Link icon

      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 interface IEditHandle
      Parameters:
      observer - an observer
      Throws:
      IllegalArgumentException - when the observer is not known.
      Since:
      2023.1
    • getShadowGeometry Link icon

      @Nullable public Geometry getShadowGeometry()
      Returns the current shadow geometry of this handle, or null.
      Returns:
      the current shadow geometry of this handle, or null.
      See Also:
    • getShadowGeometryProvider Link icon

      @Nullable public Observable<@Nullable Geometry> getShadowGeometryProvider()
      Returns the shadow geometry provider of this handle.

      Can be null.

      Returns:
      the shadow geometry provider of this handle, or null.
    • setShadowGeometryProvider Link icon

      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. See TranslateEditHandle for more information.

      Parameters:
      shadowGeometryProvider - the shadow geometry provider that is used by this handle. Can be null to disable the shadow geometry mode.
    • getShadowIcon Link icon

      @Nullable public IIcon getShadowIcon()
      Returns the icon that is used when a shadow version of a geometry is painted.
      Returns:
      the icon that is used when a shadow version of a geometry is painted.
    • setShadowIcon Link icon

      public void setShadowIcon(@Nullable IIcon icon)
      Sets the icon that is used when a shadow version of a geometry is painted.
      Parameters:
      icon - the icon that is used when a shadow version of a geometry is painted.
    • getShadowLineStyle Link icon

      @Nullable public LineStyle 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.
    • setShadowLineStyle Link icon

      public void setShadowLineStyle(@Nullable LineStyle style)
      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 a ComplexStrokeLineStyle has already been set, it will be overwritten.

      Parameters:
      style - the line style that is used for shadow lines.
    • getShadowComplexStrokeLineStyle Link icon

      @Nullable public ComplexStrokeLineStyle 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
    • setShadowComplexStrokeLineStyle Link icon

      public void setShadowComplexStrokeLineStyle(@Nullable ComplexStrokeLineStyle style)
      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 a ComplexStrokeLineStyle 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 Link icon

      @Nullable public FillStyle getShadowFillStyle()
      Returns the fill style that is used when a shadow version of a geometry is painted.
      Returns:
      the fill style that is used when a shadow version of a geometry is painted.
    • setShadowFillStyle Link icon

      public void setShadowFillStyle(@Nullable FillStyle style)
      Sets the fill style that is used when a shadow 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 Link icon

      public int getZOrder()
      Returns the Z-order that is used for this handle's paint calls to the FeatureCanvas.
      Returns:
      the Z-order that is used for this handle's paint calls to the FeatureCanvas.
      See Also:
    • setZOrder Link icon

      public void setZOrder(int zOrder)
      Sets the Z-order that is used for this handle's paint calls to the 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.

      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 the FeatureCanvas.
      See Also:
    • addOnDragAction Link icon

      @NotNull public EditActionBinder addOnDragAction(@NotNull ITranslateEditAction action)
      Adds an action that will be triggered when dragging.

      For every drag event, the following method call will be triggered:

      Parameters:
      action - the action to be performed on drag, cannot be null.
      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.