Class ALspCreateHandle

Direct Known Subclasses:
ALspDynamicCreateHandle, TLspStaticCreateHandle

public abstract class ALspCreateHandle extends ALspEditHandle
Base class for handles that are used to create and initialize new domain objects.

A create handle has a list of other handles that are used during the creation process. Only one handle is active at a time though. The create handle itself becomes active at construction time and cannot be reactivated when becoming inactive.

This class can be implemented by implementing the following methods.

  • hasNext : Checks if there are more edit handles to process.
  • next : Returns the next edit handle.
  • requestsDeactivation : Makes it possible to stop creation, even if there are still handles left.

If the list of handles is known at construction time, you can use TLspStaticCreateHandle. An example of an editor that uses a static create handle is TLspCircleEditor. For instance when creating a TLcdLonLatCircle, the number and type of handles is fixed and known a-priori.

If the list of handles is not known a-priori, you can derive your create handle from ALspDynamicCreateHandle. An example of an editor that uses a dynamic create handle is the TLsp2DPointListEditor, where a new handle is constructed whenever a new point is added to the point list under creation. Since the number of points in the list is unknown beforehand, a static create handle cannot be used.

Since:
2012.0
  • Constructor Details

    • ALspCreateHandle

      protected ALspCreateHandle(Object aGeometry)
      Creates a create handle for the given object.
      Parameters:
      aGeometry - a geometry for that is edited by this handle. Null is allowed, for instance if editing doesn't involve geometry directly.
  • Method Details

    • hasNext

      protected abstract boolean hasNext(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether there is a next handle to be used in the creation process.
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      true if another handle is available, false otherwise.
    • hasNext

      protected boolean hasNext(Event aEvent, TLspEditContext aEditContext)
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      true if another handle is available, false otherwise.
      Since:
      2020.0
    • next

      protected abstract ALspEditHandle next(AWTEvent aEvent, TLspEditContext aEditContext)
      Makes the next handle the active handle.
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      the next handle.
    • next

      protected ALspEditHandle next(Event aEvent, TLspEditContext aEditContext)
      JavaFX equivalent of next(AWTEvent, TLspEditContext).
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      the next handle.
      Since:
      2020.0
    • hasPrevious

      protected boolean hasPrevious(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether there is a previous handle used in the creation process, or a currently active handle.
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      true if a previous handle is available, false otherwise.
    • hasPrevious

      protected boolean hasPrevious(Event aEvent, TLspEditContext aEditContext)
      Parameters:
      aEvent - the event
      aEditContext - the edit context
      Returns:
      true if a previous handle is available, false otherwise.
      Since:
      2020.0
    • previous

      protected void previous(AWTEvent aEvent, TLspEditContext aEditContext)
      Makes the previous handle the current handle. The previous handle is provided with the given event in order to make it active again. If there is no previous handle, the active handle is made null. This allows the create handle to go back to its initial state.
      Parameters:
      aEvent - the given event
      aEditContext - the edit context
    • previous

      protected void previous(Event aEvent, TLspEditContext aEditContext)
      Parameters:
      aEvent - the given event
      aEditContext - the edit context
      Since:
      2020.0
    • requestsDeactivation

      protected abstract boolean requestsDeactivation(AWTEvent aEvent, TLspEditContext aEditContext)
      Checks whether the create handle should be deactivated. This is the case if the current handle is the last handle and it is not active.

      Subclasses can implement this method to perform additional checks on the input event and for example request deactivation when the right mouse button is clicked.

      The result of having this method return true is that the currently active handle (if any) is invoked one more time, and the resulting TLspEditHandleResult will contain a ELspInteractionStatus.FINISHED as an interaction status.

      Note that this create handle automatically deactivates if hasNext returns false, regardless of this method. This method should be considered an "early-out".

      Parameters:
      aEvent - the event
      aEditContext - the edit context for this request
      Returns:
      true if deactivation is requested, false otherwise.
    • requestsDeactivation

      protected boolean requestsDeactivation(Event aEvent, TLspEditContext aEditContext)
      Parameters:
      aEvent - the event
      aEditContext - the edit context for this request
      Returns:
      true if deactivation is requested, false otherwise.
      Since:
      2020.0
    • deactivate

      protected TLspEditHandleResult deactivate(AWTEvent aEvent, TLspEditContext aEditContext)
      Called right before the handle is deactivated
      Parameters:
      aEvent - The event
      aEditContext - the edit context
      Returns:
      A resulting operation of deactivation.
    • deactivate

      protected TLspEditHandleResultFX deactivate(Event aEvent, TLspEditContext aEditContext)
      Parameters:
      aEvent - The event
      aEditContext - the edit context
      Returns:
      A resulting operation of deactivation.
      Since:
      2020.0
    • isActive

      public boolean isActive()
      Description copied from class: ALspHandle
      Checks whether this handle is active. When a handle is active, it will be the first candidate to receive events. If a handle is inactive, it might still receive events (possibly making it active) if all other active handles didn't process an event.
      Specified by:
      isActive in class ALspHandle
      Returns:
      true if active, false otherwise
    • requestsFocus

      public boolean requestsFocus(AWTEvent aEvent, TLspEditContext aEditContext)
      Description copied from class: ALspEditHandle
      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.

      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)
      Description copied from class: ALspEditHandle
      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.
    • handleAWTEvent

      public TLspEditHandleResult handleAWTEvent(AWTEvent aEvent, TLspEditContext aEditContext)
      Processes the given event if this create handle is active. The create handle first tries to deactivate itself. If it is not deactivated it tries to delegate the event to the active handle (last returned by hasNext. If there is no active handle, hasNext is called to check if a next handle can be queried. Finally if no active handle is available, this handle deactivates and the creation ends.
      Specified by:
      handleAWTEvent in class ALspEditHandle
      Parameters:
      aEvent - the input event
      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:
    • handleFXEvent

      public TLspEditHandleResultFX handleFXEvent(Event aEvent, TLspEditContext aEditContext)
      Overrides:
      handleFXEvent in class ALspEditHandle
      Parameters:
      aEvent - the input event
      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
    • getPreviousHandles

      protected List<ALspEditHandle> getPreviousHandles()
    • removePreviousHandle

      protected void removePreviousHandle(ALspEditHandle aPreviousHandle)
    • getStyleTargetProviders

      public List<ALspStyleTargetProvider> getStyleTargetProviders(TLspHandleGeometryType aType)
      Returns all style target providers components of the currently active handle and previously used handles.
      Specified by:
      getStyleTargetProviders in class ALspHandle
      Parameters:
      aType - the handle component type for which the visual representations are to be retrieved
      Returns:
      the combined collection of visual handle components of the active handle, and possibly of all previously used handles
    • getActiveHandle

      protected ALspEditHandle getActiveHandle()
    • getCursor

      public Cursor getCursor()
      Description copied from class: ALspHandle
      Returns the cursor for this handle. In practice, this cursor is used when this handle is active, or when it has focus.
      Overrides:
      getCursor in class ALspHandle
      Returns:
      the cursor for this handle.