com.dlsc.flexgantt.swing.layer.system

## Class LassoLayer

- java.lang.Object
- - com.dlsc.flexgantt.swing.layer.AbstractLayer
  - - com.dlsc.flexgantt.swing.layer.system.AbstractSystemLayer
    - - com.dlsc.flexgantt.swing.layer.system.LassoLayer

- All Implemented Interfaces:
    MouseListener, MouseMotionListener, KeyEventDispatcher, EventListener

      public class LassoLayer
      extends AbstractSystemLayer
      implements MouseListener, MouseMotionListener, KeyEventDispatcher

  A layer that focuses on visualizing a lasso / selection rectangle.
  Since:
    1.0
  Version:
    $Revision: 1.16 $
  Author:
    Dirk Lemmermann

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `LassoLayer.LassoMode` A selection mode enumerator that can be used to instruct the lasso layer what to select when a lasso operation finishes.
    `static class` | `LassoLayer.SelectionBehaviour` An enumerator used to control the selection behaviour of the lasso.

  - ### Field Summary

    - ### Fields inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `alpha, changeSupport, ganttChart, layerContainer, PROPERTY_ALPHA, PROPERTY_VISIBLE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `LassoLayer(LayerContainer lc)` Constructs a new lasso layer.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addLassoLayerListener(ILassoLayerListener l)` Adds a lasso layer listener to the lasso layer.
    `protected Cursor` | `createLassoCursor(LassoLayer.LassoMode mode, boolean multi)` Creates a cursor that will be used for the given lasso mode.
    `boolean` | `dispatchKeyEvent(KeyEvent e)` Intercepts key events from the `KeyboardFocusManager` in order to temporarily change the edit mode.
    `protected void` | `fireLassoLayerEvent(LassoLayerEvent evt)` Sends the given event object to all lasso layer listeners that are currently observing the lasso layer.
    `LassoLayer.LassoMode` | `getLassoMode()` Returns the lasso mode used by the lasso layer (selecting timeline objects or selecting time spans).
    `LassoLayer.SelectionBehaviour` | `getSelectionBehaviour()` Returns the selection behavour used by the lasso.
    `Color` | `getSelectionColor()` Returns the color used for filling the selection color.
    `LassoLayer.LassoMode[]` | `getSupportedLassoModes()` Returns the supported lasso modes.
    `boolean` | `isSelecting()` Determines if a selection / lasso operation is currently taking place.
    `boolean` | `isSingleRowObjectCreation()` Determines whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
    `boolean` | `isSupportedLassoMode(LassoLayer.LassoMode mode)` Checks whether the given lasso mode is supported by the lasso layer.
    `void` | `mouseClicked(MouseEvent e)`
    `void` | `mouseDragged(MouseEvent e)`
    `void` | `mouseEntered(MouseEvent e)`
    `void` | `mouseExited(MouseEvent e)`
    `void` | `mouseMoved(MouseEvent e)`
    `void` | `mousePressed(MouseEvent e)`
    `void` | `mouseReleased(MouseEvent e)`
    `protected void` | `paintLasso(Graphics g, Rectangle lasso)` Draws the actual lasso.
    `protected void` | `paintLayer(Graphics g)`
    `void` | `removeLassoLayerListener(ILassoLayerListener l)` Removes a lasso layer listener from the lasso layer.
    `void` | `setLassoMode(LassoLayer.LassoMode mode)` Sets the lasso mode so that the layer can switch between selecting timeline objects and selecting time spans and creating timeline objects.
    `void` | `setSelectionBehaviour(LassoLayer.SelectionBehaviour behaviour)` Sets the selection behavour used by the lasso.
    `void` | `setSelectionColor(Color color)` Sets the color used for filling the selection rectangle.
    `void` | `setSingleRowObjectCreation(boolean single)` Specifies whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
    `void` | `setSupportedLassoModes(LassoLayer.LassoMode... modes)` Sets the supported lasso modes.
    `void` | `tearDown()` Removes the layer from the keyboard focus manager.

    - ### Methods inherited from class com.dlsc.flexgantt.swing.layer.AbstractLayer

      `addPropertyChangeListener, getAlpha, getDateline, getEventline, getGanttChart, getHeight, getLayerContainer, getLayerPolicyProvider, getModel, getName, getStartRow, getTimeAt, getTimeline, getTimeLocation, getTimeSpanUsed, getToolTipText, getTreeTable, getTreeTablePolicyProvider, getWidth, isVisible, removePropertyChangeListener, repaint, repaint, repaint, setAlpha, setVisible`

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

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

- - ### Constructor Detail

    - #### LassoLayer

          public LassoLayer(LayerContainer lc)

      Constructs a new lasso layer.
      Parameters:
        `lc` - the layer container to which the layer belongs
      Since:
        1.0

  - ### Method Detail

    - #### isSelecting

          public boolean isSelecting()

      Determines if a selection / lasso operation is currently taking place.
      Returns:
        TRUE if the user is currently selecting something
      Since:
        1.0

    - #### paintLayer

          protected void paintLayer(Graphics g)

      Overrides:
        `paintLayer` in class `AbstractLayer`

    - #### paintLasso

          protected void paintLasso(Graphics g,
                                    Rectangle lasso)

      Draws the actual lasso. The values passed to this method ensure that the point (x1, y1) is always the upper left corner of the lasso and (x2, y2) is always the lower right corner of the lasso.
      Parameters:
        `g` - the graphics context into which to draw
        `lasso` - the lasso bounds
      Since:
        1.0

    - #### mouseDragged

          public void mouseDragged(MouseEvent e)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`

    - #### mouseMoved

          public void mouseMoved(MouseEvent e)

      Specified by:
        `mouseMoved` in interface `MouseMotionListener`

    - #### mouseClicked

          public void mouseClicked(MouseEvent e)

      Specified by:
        `mouseClicked` in interface `MouseListener`

    - #### mousePressed

          public void mousePressed(MouseEvent e)

      Specified by:
        `mousePressed` in interface `MouseListener`

    - #### mouseReleased

          public void mouseReleased(MouseEvent e)

      Specified by:
        `mouseReleased` in interface `MouseListener`

    - #### mouseEntered

          public void mouseEntered(MouseEvent e)

      Specified by:
        `mouseEntered` in interface `MouseListener`

    - #### mouseExited

          public void mouseExited(MouseEvent e)

      Specified by:
        `mouseExited` in interface `MouseListener`

    - #### getSelectionColor

          public Color getSelectionColor()

      Returns the color used for filling the selection color.
      Returns:
        the color used for filling the selection color
      Since:
        1.0

    - #### setSelectionColor

          public void setSelectionColor(Color color)

      Sets the color used for filling the selection rectangle.
      Parameters:
        `color` - the color used for filling the selection color
      Since:
        1.0

    - #### getLassoMode

          public LassoLayer.LassoMode getLassoMode()

      Returns the lasso mode used by the lasso layer (selecting timeline objects or selecting time spans).
      Returns:
        the mode for the next lasso operation
      Since:
        1.0

    - #### setLassoMode

          public void setLassoMode(LassoLayer.LassoMode mode)

      Sets the lasso mode so that the layer can switch between selecting timeline objects and selecting time spans and creating timeline objects.
      Parameters:
        `mode` - the mode to use for the next lasso operation
      Since:
        1.0

    - #### isSingleRowObjectCreation

          public boolean isSingleRowObjectCreation()

      Determines whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
      Returns:
        TRUE if timeline objects can only be created one row at a time
      Since:
        1.0

    - #### setSingleRowObjectCreation

          public void setSingleRowObjectCreation(boolean single)

      Specifies whether the layer only supports the creation of timeline objects on a single row or several rows at the same time.
      Parameters:
        `single` - if TRUE timeline objects can only be created one row at a time
      Since:
        1.0

    - #### createLassoCursor

          protected Cursor createLassoCursor(LassoLayer.LassoMode mode,
                                             boolean multi)

      Creates a cursor that will be used for the given lasso mode. This method looks up its cursor from the `IconRegistry` with the following IDs:
      - `IconId.CURSOR_SELECT_TIMELINE_OBJECTS`
      - `IconId.CURSOR_SELECT_TIMELINE_OBJECTS_MULTI`
      - `IconId.CURSOR_SELECT_TIME_SPANS`
      - `IconId.CURSOR_SELECT_TIME_SPANS_MULTI`
      - `IconId.CURSOR_CREATE_RELATIONSHIPS`
      - `IconId.CURSOR_CREATE_TIMELINE_OBJECTS`
      Parameters:
        `mode` - the lasso mode for which to create a cursor
        `multi` - determines if the cursor is needed for a 'multi' operation (multi timeline object selection, multi time span selection)
      Returns:
        a cursor for the given lasso mode
      Since:
        1.0

    - #### dispatchKeyEvent

          public boolean dispatchKeyEvent(KeyEvent e)

      Intercepts key events from the `KeyboardFocusManager` in order to temporarily change the edit mode. Pressing the `SHIFT` key will turn on the multi selection mode. Pressing the `CTRL` key will change from timeline object selection to time span selection. Pressing the ALT key will switch to the timeline object creation mode. Key events will only be processed if the mouse cursor is currently on top of the layer container.
      Specified by:
        `dispatchKeyEvent` in interface `KeyEventDispatcher`
      Since:
        1.0

    - #### getSupportedLassoModes

          public LassoLayer.LassoMode[] getSupportedLassoModes()

      Returns the supported lasso modes. By default the lasso layer supports all lasso modes defined in `LassoLayer.LassoMode`.
      Returns:
        the supported lasso modes
      Since:
        1.0
      See Also:
        `setSupportedLassoModes(LassoMode[])`

    - #### setSupportedLassoModes

          public void setSupportedLassoModes(LassoLayer.LassoMode... modes)

      Sets the supported lasso modes. By default the lasso layer supports all lasso modes defined in `LassoLayer.LassoMode`.
      Parameters:
        `modes` - the supported lasso modes
      Since:
        1.0
      See Also:
        `getSupportedLassoModes()`

    - #### isSupportedLassoMode

          public boolean isSupportedLassoMode(LassoLayer.LassoMode mode)

      Checks whether the given lasso mode is supported by the lasso layer.
      Parameters:
        `mode` - the mode to check
      Returns:
        TRUE if the given lasso mode is supported by the layer
      Since:
        1.0
      See Also:
        `setSupportedLassoModes(com.dlsc.flexgantt.swing.layer.system.LassoLayer.LassoMode[])`, `getSupportedLassoModes()`

    - #### addLassoLayerListener

          public void addLassoLayerListener(ILassoLayerListener l)

      Adds a lasso layer listener to the lasso layer. The listener will be informed whenever the user performs a lasso operation.
      Parameters:
        `l` - the listener to attach to the layer
      Since:
        1.1

    - #### removeLassoLayerListener

          public void removeLassoLayerListener(ILassoLayerListener l)

      Removes a lasso layer listener from the lasso layer.
      Parameters:
        `l` - the listener that will be removed
      Since:
        1.1

    - #### fireLassoLayerEvent

          protected void fireLassoLayerEvent(LassoLayerEvent evt)

      Sends the given event object to all lasso layer listeners that are currently observing the lasso layer.
      Parameters:
        `evt` - the lasso layer event that will be sent to all listeners
      Since:
        1.1

    - #### getSelectionBehaviour

          public LassoLayer.SelectionBehaviour getSelectionBehaviour()

      Returns the selection behavour used by the lasso.
      Returns:
        the lasso selection behaviour
      Since:
        1.0

    - #### setSelectionBehaviour

          public void setSelectionBehaviour(LassoLayer.SelectionBehaviour behaviour)

      Sets the selection behavour used by the lasso.
      Parameters:
        `behaviour` - the lasso selection behaviour
      Since:
        1.0

    - #### tearDown

          public void tearDown()

      Removes the layer from the keyboard focus manager.
      Overrides:
        `tearDown` in class `AbstractLayer`
      Since:
        1.1

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