com.dlsc.flexgantt.swing.layer.system

## Class DefaultEditModeController

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.system.DefaultEditModeController

- All Implemented Interfaces:
    IEditModeController
  Direct Known Subclasses:
    ActivityObjectEditModeController, CapacityObjectEditModeController

      public class DefaultEditModeController
      extends Object
      implements IEditModeController

  The default edit mode controller specifies the editing behaviour used for timeline objects of type `DefaultTimelineObject`. The editor lets the user change the start and end times when the mouse cursor hovers over the left or right edige of the timeline object. The user can drag and drop the timeline object when the cursor is placed in its center region.

  The controller makes heavy use of the `IDragAndDropPolicy` and the `IEditTimelineObjectPolicy`. These policies define, which kind of editing behaviour is supported by the timeline object.

  Since:
    1.0
  Version:
    $Revision: 1.8 $
  Author:
    Dirk Lemmermann
  See Also:
    `IDragAndDropPolicy.getDragActions(com.dlsc.flexgantt.model.gantt.TimelineObjectPath, IGanttChartModel)`, `IEditTimelineObjectPolicy.isStartTimeChangeable(com.dlsc.flexgantt.model.gantt.TimelineObjectPath, IGanttChartModel)`, `IEditTimelineObjectPolicy.isDurationChangeable(com.dlsc.flexgantt.model.gantt.TimelineObjectPath, IGanttChartModel)`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.dlsc.flexgantt.swing.layer.system.IEditModeController

      `IEditModeController.EditMode`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultEditModeController()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `IEditModeController.EditMode` | `getEditMode(DragLayer layer, ObjectBounds bounds, MouseEvent e)` Returns an edit mode based on the given bounds and mouse event.
    `protected boolean` | `isChangeEndTimeLocation(ObjectBounds bounds, MouseEvent evt, IEditTimelineObjectPolicy editPolicy)` Returns TRUE if the given location is valid for changing the end time of the timeline object.
    `protected boolean` | `isChangeStartTimeLocation(ObjectBounds bounds, MouseEvent evt, IEditTimelineObjectPolicy editPolicy)` Returns TRUE if the given location is valid for changing the start time of the timeline object.
    `protected boolean` | `isDragLocation(ObjectBounds bounds, MouseEvent evt, IEditTimelineObjectPolicy editPolicy)` Returns TRUE if the given location is a valid location within the object's bounds for initiating a drag operation.
    `protected boolean` | `isUsingDragOverrideModifiers(MouseEvent evt)` Determines whether the modifiers of the mouse event override the standard editing behaviour so that the controller will return `EditMode.CHANGE_TIME_SPAN` even when the cursor is on the locations that usually trigger an `EditMode.CHANGE_START_TIME` or an `EditMode.CHANGE_END_TIME`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DefaultEditModeController

          public DefaultEditModeController()

  - ### Method Detail

    - #### getEditMode

          public IEditModeController.EditMode getEditMode(DragLayer layer,
                                                          ObjectBounds bounds,
                                                          MouseEvent e)

      Description copied from interface: `IEditModeController`
      Returns an edit mode based on the given bounds and mouse event. The method can evaluate the location and the modifiers of the event in order to determine what kind of editing operation will be supported.
      Specified by:
        `getEditMode` in interface `IEditModeController`
      Parameters:
        `layer` - the drag layer requesting the edit mode
        `bounds` - the object bounds over which the mouse cursor currently hovers
        `e` - the mouse event that triggered the request
      Returns:
        the edit mode that is appropriate for the given location and key modifiers

    - #### isDragLocation

          protected boolean isDragLocation(ObjectBounds bounds,
                                           MouseEvent evt,
                                           IEditTimelineObjectPolicy editPolicy)

      Returns TRUE if the given location is a valid location within the object's bounds for initiating a drag operation. The default implementation of this method will return TRUE if the location of the given mouse event is contained within the object bounds and the location is not the location for changing the start or the end time of the timeline object.
      Parameters:
        `bounds` - the object bounds to check
        `evt` - the mouse event causing the location check
        `editPolicy` - the timeline object editing policy
      Returns:
        TRUE if the specified location is valid for dragging the timeline object
      Since:
        1.0

    - #### isChangeEndTimeLocation

          protected boolean isChangeEndTimeLocation(ObjectBounds bounds,
                                                    MouseEvent evt,
                                                    IEditTimelineObjectPolicy editPolicy)

      Returns TRUE if the given location is valid for changing the end time of the timeline object.
      Parameters:
        `bounds` - the object bounds to check
        `evt` - the mouse event causing the location check
        `editPolicy` - the timeline object editing policy
      Returns:
        TRUE if the specified location is valid for changing the end time of the timeline object
      Since:
        1.0

    - #### isChangeStartTimeLocation

          protected boolean isChangeStartTimeLocation(ObjectBounds bounds,
                                                      MouseEvent evt,
                                                      IEditTimelineObjectPolicy editPolicy)

      Returns TRUE if the given location is valid for changing the start time of the timeline object.
      Parameters:
        `bounds` - the object bounds to check
        `evt` - the mouse event causing the location check
        `editPolicy` - the timeline object editing policy
      Returns:
        TRUE if the specified location is valid for changing the start time of the timeline object
      Since:
        1.0

    - #### isUsingDragOverrideModifiers

          protected boolean isUsingDragOverrideModifiers(MouseEvent evt)

      Determines whether the modifiers of the mouse event override the standard editing behaviour so that the controller will return `EditMode.CHANGE_TIME_SPAN` even when the cursor is on the locations that usually trigger an `EditMode.CHANGE_START_TIME` or an `EditMode.CHANGE_END_TIME`. An override can be useful when the timeline object is too small for all edit modes. The default implementation of this method returns TRUE when the user is pressing the ALT key.
      Parameters:
        `evt` - the mouse event to check for override modifiers
      Returns:
        TRUE if the mouse event overrides the standard editing behaviour
      Since:
        1.0

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.