Class ALspOutlineResizeHandle


public abstract class ALspOutlineResizeHandle extends ALsp3StepEditHandle
Base implementation of a handle that allows resizing or scaling of domain objects by dragging their outline.

This handle has two translate modes: either by dragging the mouse, or by moving it in between two clicks. See setTranslateOnDrag. When true, the handle is activated/deactivated using mouse press and release events and changed using mouse dragged events. Otherwise, the handle is activated/deactivated using mouse clicks and changed by moving the mouse when active.

When using touch events, this handle is activated on DOWN events, processes MOVED events, and is deactivated on UP events.

When using touch events, this handle is activated on DOWN events, processes MOVED events, and is deactivated on UP events.

This class can be implemented by implementing the following methods:

  • calculateClosestReferencePoint : Calculates the reference point of the given object that lies closest to the given point. The reference point can for example be the center of a circle, a point on the point list representing the axis of a buffer, etc.
  • getPropertyName : Determines the property name used in the returned PROPERTY_CHANGE operation.
Since:
2012.0
  • Constructor Details

    • ALspOutlineResizeHandle

      protected ALspOutlineResizeHandle(Object aGeometry)
      Constructs an outline resize handle for the given editor.
      Parameters:
      aGeometry - The geometry (shape) that will be edited by this handle. This argument is used to visualize the outline handle.
  • Method Details

    • isTranslateOnDrag

      public boolean isTranslateOnDrag()
      Returns if this handle is translated when dragging the mouse, or when moving it.
      Returns:
      if this handle is translated when dragging the mouse, or when moving it.
      See Also:
    • setTranslateOnDrag

      public void setTranslateOnDrag(boolean aIsTranslateOnDrag)
      Sets if this handle is translated when dragging the mouse, or when moving it. If true, the handle is activated using a MOUSE_PRESSED event, translated using a MOUSE_DRAGGED event, and deactivated using a MOUSE_RELEASED event.

      If false, this handle is activate using a MOUSE_RELEASED event, translated using a MOUSE_MOVED event, and deactivated using a MOUSE_RELEASED event.

      When using touch events, the only difference is that when this setting is set to false, this handle doesn't need a DOWN event to be activated.

      This setting is typically set to true during editing, and to false during creation.

      By default, isTranslateOnDrag returns true

      Parameters:
      aIsTranslateOnDrag - if this handle is translated when dragging the mouse, or when moving it.
    • getPropertyName

      protected abstract String getPropertyName()
      Returns the property name to be used by the generated property change descriptors created by this handle.
      Returns:
      the property name the property change descriptor generated by this handle
    • isOutlineTouched

      protected boolean isOutlineTouched(int aX, int aY, TLspEditContext aEditContext)
      Checks if the outline of the given object is touched, based on the given view coordinates.

      The default implementation queries the layer of the handle using a touch query, using the paint representation of the handle.

      Parameters:
      aX - mouse x
      aY - mouse y
      aEditContext - the edit context
      Returns:
      true if touched, false otherwise
    • calculateClosestReferencePoint

      protected abstract ILcdPoint calculateClosestReferencePoint(ILcdPoint aModelPoint, Object aObject, TLspContext aContext)
      Retrieves the reference point of the given object that lies closest to the given point. The reference point can for example be the center of a circle, a point on the point list representing the axis of a buffer, etc.

      If no model point can be computed, this method should return null. In that case, no operation will be created.

      Parameters:
      aModelPoint - the model point for which the closest point on the reference axis should be calculated.
      aObject - the domain object
      aContext - the context
      Returns:
      the point on the reference axis of the given object that lies closest to the given point, or null if no such point can be calculated.
    • requestsFocus

      public boolean requestsFocus(AWTEvent aEvent, TLspEditContext aEditContext)
      Indicates whether this handle requests focus for the given event. The edit controller can respond to this by forwarding event objects to this handle by calling handleAWTEvent. However, this is not ensured, because another handle may have precedence over this handle and also request focus. Precedence is primarily determined by the handle priority.

      The default implementation returns true if the handle is active. Subclasses can override this method for custom behavior. An example would be to request focus when the mouse hovers over a visual handle component.

      By default, this method returns true when this handle is active, or when the outline is touched.

      Overrides:
      requestsFocus in class ALspEditHandle
      Parameters:
      aEvent - the AWTEvent that might result in a focus request
      aEditContext - the edit context, containing, amongst others, information about the layer for which this handle is operating, the view, the object for which this handle was created, the geometry that this handle was created for, the paint representation in which geometry exists, and the sensitivity with which the event should be handled
      Returns:
      true if this handle requests focus for the given event, false otherwise.
      See Also:
    • requestsFocus

      public boolean requestsFocus(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      requestsFocus in class ALspEditHandle
      Parameters:
      aEvent - the AWTEvent that might result in a focus request
      aEditContext - the edit context, containing, amongst others, information about the layer for which this handle is operating, the view, the object for which this handle was created, the geometry that this handle was created for, the paint representation in which geometry exists, and the sensitivity with which the event should be handled
      Returns:
      true if this handle requests focus for the given event, false otherwise.
      Since:
      2020.0
    • getStyleTargetProviders

      public List<ALspStyleTargetProvider> getStyleTargetProviders(TLspHandleGeometryType aType)
      Returns a style target provider that can generate geometry for the given visual editing component type, or an empty list if no geometry can be generated for the given type. TLspEditHandleStyler allows you to register different styles for each visual component type.

      By default, this method returns a style target provider that returns the object itself (or its base shape for an extruded shape) for the VisualHandleComponentType OUTLINE. Returns an empty list for all other requests.

      Specified by:
      getStyleTargetProviders in class ALspHandle
      Parameters:
      aType - the handle component type for which the visual representations are to be retrieved
      Returns:
      the provided object or its base object or null depending on the visual handle component type requested
    • onActivate

      protected TLspEditHandleResult onActivate(AWTEvent aEvent, TLspEditContext aEditContext)
      Called when this handle is activated (after canActivate has returned true.

      By default, this method returns a edit handle result without operations and interaction status IN_PROGRESS.

      Override this method to provide custom behavior. In that case, also make sure to call the super method.

      Specified by:
      onActivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that caused the handle to be activated
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      See Also:
    • onActivate

      protected TLspEditHandleResultFX onActivate(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      onActivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that caused the handle to be activated
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      Since:
      2020.0
    • onDeactivate

      protected TLspEditHandleResult onDeactivate(AWTEvent aEvent, TLspEditContext aEditContext)
      Performs some action with the event after the handle is deactivated.

      By default, this method returns a edit handle result with a PROPERTY_CHANGE operation and interaction status FINISHED. The property chang descriptor describes a property change with the name provided by getPropertyName, and the closest point on the reference axis.

      Override this method to provide custom behavior. In that case, also make sure to call the super method.

      Specified by:
      onDeactivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that caused the handle to be deactivated
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      See Also:
    • onDeactivate

      protected TLspEditHandleResultFX onDeactivate(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      onDeactivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that caused the handle to be deactivated
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      Since:
      2020.0
    • process

      protected TLspEditHandleResult process(AWTEvent aEvent, TLspEditContext aEditContext)
      Process the given event. This method is only called when the handle is active and processing is requested.

      By default, this method returns a edit handle result with a PROPERTY_CHANGE operation and interaction status IN_PROGRESS. The property chang descriptor describes a property change with the name provided by getPropertyName, and the closest point on the reference axis.

      Override this method to provide custom behavior. In that case, also make sure to call the super method.

      Specified by:
      process in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that was processed
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      See Also:
    • process

      protected TLspEditHandleResultFX process(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      process in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that was processed
      aEditContext - the edit context
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      Since:
      2020.0
    • canActivate

      protected boolean canActivate(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether the handle can be activated. If this method returns true, isActive will return true and onActivate is called next.

      By default, this method returns true when the input event is a mouse pressed/click event (depending on the translation mode), and when the outline is touched as indicated by isOutlineTouched.

      Specified by:
      canActivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should be activated as a result of the given event, false otherwise
      See Also:
    • canActivate

      protected boolean canActivate(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      canActivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should be activated as a result of the given event, false otherwise
      Since:
      2020.0
    • canDeactivate

      protected boolean canDeactivate(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether the handle can be deactivated. If this method returns true, isActive will return false and onDeactivate is called next.

      By default, this method returns true when the input event is a mouse release/click event (depending on the translation mode).

      Specified by:
      canDeactivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should be deactivated as a result of the given event, false otherwise
      See Also:
    • canDeactivate

      protected boolean canDeactivate(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      canDeactivate in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should be deactivated as a result of the given event, false otherwise
      Since:
      2020.0
    • canProcess

      protected boolean canProcess(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether the given event should be processed. If this method returns true, process is called next.

      By default, this method returns true if a mouse drag/move happened (depending on the translation mode).

      Specified by:
      canProcess in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should process this event, false otherwise.
      See Also:
    • canProcess

      protected boolean canProcess(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      canProcess in class ALsp3StepEditHandle
      Parameters:
      aEvent - the event that should be handled
      aEditContext - the edit context
      Returns:
      true if the handle should process this event, false otherwise.
      Since:
      2020.0
    • handleAWTEvent

      public TLspEditHandleResult handleAWTEvent(AWTEvent aEvent, TLspEditContext aEditContext)
      Description copied from class: ALsp3StepEditHandle
      Handle the given input event for the given edit context. The edit handle can choose the operation to perform based on the type and state of the input event.

      When the edit handle has processed the input event, this method will return a edit handle result containing a null event to indicate that the event has been consumed. Note that sometimes an event might be partially consumed (which is often the case with touch events), in which case this method will return an edit handle result with an altered version of the given input event.

      If incoming event should be ignored, this method should return a TLspEditHandleResult without any edit operations, and an unconsumed AWTEvent. An unconsumed AWTEvent means that it should contain the original, unmodified aEvent parameter passed to this method. This result indicates that the event was not consumed, and that some other object needs to consume the event instead.

      As a side effect, a handle is allowed to activate or deactivate itself as a result of processing an input event.

      This method performs the handling of AWT events into 3 steps.

      • Activation: First the handle checks if the handle can be activated. If so, onActivate is called.
      • Processing: If a handle is active, the handle checks if it can process an event. If so, process is called. This step is typically performed for multiple events.
      • Deactivation: If a handle is active the handle checks if it can be deactivated. If so, onDeactivate is called, and the handle becomes inactive (isActive returns false).
      Subclasses should implement the above methods to obtain the desired behavior.

      Note: This handle checks if it can be deactivated before it checks if it can process an event.

      Overrides:
      handleAWTEvent in class ALsp3StepEditHandle
      Parameters:
      aEvent - the input event
      aEditContext - the edit context, containing, amongst others, information about the layer for which this handle is operating, the view, the object for which this handle was created, the geometry that this handle was created for, the paint representation in which geometry exists, and the sensitivity with which the event should be handled
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.
      See Also:
    • handleFXEvent

      public TLspEditHandleResultFX handleFXEvent(Event aEvent, TLspEditContext aEditContext)
      Description copied from class: ALsp3StepEditHandle
      Overrides:
      handleFXEvent in class ALsp3StepEditHandle
      Parameters:
      aEvent - the input event
      aEditContext - the edit context, containing, amongst others, information about the layer for which this handle is operating, the view, the object for which this handle was created, the geometry that this handle was created for, the paint representation in which geometry exists, and the sensitivity with which the event should be handled
      Returns:
      an edit handle result containing a collection of operations to perform, and the (partially) consumed event object. The handle result itself should not be null.