ur_rna.StructureEditor.services.drawing

## Class DrawHandle

- java.lang.Object
- - ur_rna.StructureEditor.services.drawing.DrawHandle

- Direct Known Subclasses:
    BranchSlider, LoopResizer, SelectionRotater, SelectionRotater.CenterPoint

      public abstract class DrawHandle
      extends java.lang.Object

  Represents a handle that the user can click, drag or interact with on the screen to cause an effect in the scene.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.awt.geom.Point2D.Double` | `_tmpPt`
    `protected java.awt.geom.AffineTransform` | `_tmpTr`
    `protected java.util.Collection<Nuc>` | `allNucs`
    `protected int` | `boxSize`
    `protected java.awt.Rectangle` | `cachedBounds`
    `protected SceneController` | `controller`
    `protected java.awt.Cursor` | `customCursor`
    `private static int` | `DEFAULT_MARGIN`
    `protected static java.awt.Color` | `defaultBgColor`
    `private static int` | `defaultBoxSize`
    `protected static java.awt.Color` | `defaultLineColor`
    `protected static java.awt.BasicStroke` | `defaultOutline`
    `private boolean` | `enabled`
    `protected java.awt.Image` | `icon`
    `private boolean` | `isPerformingDrag`
    `protected java.awt.Point` | `location`
    `static float` | `SNAP_DISTANCE`
    `protected java.awt.Point` | `startLocation`
    `protected Nuc` | `targetNuc`
    `protected View2D` | `view`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `DrawHandle(SceneController controller)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.awt.geom.Point2D` | `calcBoxPos(java.awt.geom.Point2D location, java.awt.geom.Point2D direction, double margin, DrawSettings settings, java.awt.geom.AffineTransform view)` Calculates the position of the DrawHandle's box based on a starting point and the suggested direction to move away from that point.
    `void` | `drag(java.awt.Point start, java.awt.Point prev, java.awt.Point current, SceneController.DragOpts options)` Called when this handle has been dragged by the user.
    `void` | `dragComplete(boolean success)` Called when the user has completed dragging (e.g.
    `void` | `dragStarted(java.awt.Point startPos)`
    `java.awt.Shape` | `draw(java.awt.Graphics2D g, View2D view, DrawSettings settings, boolean isDragging)`
    `protected java.awt.Shape` | `drawBox(java.awt.Graphics2D g, View2D view, DrawSettings settings)`
    `java.awt.Rectangle` | `getBounds()`
    `int` | `getBoxSize()` Get the size of the default DrawHandle box that the user can click.
    `protected abstract SceneUpdateInfo` | `getCompletionEvent()`
    `protected java.awt.geom.AffineTransform` | `getModelSpaceDeltaTransform(java.awt.Point start, java.awt.Point end)`
    `private static int` | `getSelectionHashCode(java.lang.Iterable<Nuc> selection)`
    `boolean` | `isEnabled()`
    `boolean` | `isUpdating()` Returns true when this DragHandle is performing updates in response to being dragged.
    `abstract boolean` | `isValid()`
    `void` | `layoutUpdated()` Called when any nucleotides in the scene changed position.
    `protected void` | `moveLocation(java.awt.Point start, java.awt.Point end)`
    `protected abstract void` | `nucPositionsChanged()` Called when any nucleotides in the scene changed position, EXCEPT when THIS DrawHandle is in the middle of a performDrag operation (because any nucleotide changes then are likely due to its own drag operation).
    `protected abstract void` | `performDrag(java.awt.Point start, java.awt.Point prev, java.awt.Point current, SceneController.DragOpts options)` Called when this handle has been dragged by the user.
    `protected abstract void` | `prepareDraw(boolean isDragging)`
    `protected abstract void` | `selectionChanged()`
    `void` | `setBoxSize(int size)` Set the size of the default DrawHandle box that the user can click.
    `void` | `setEnabled(boolean enabled)`
    `void` | `setIcon(java.awt.image.BufferedImage icon)`
    `void` | `setSelection(Nuc focus, java.util.Collection<Nuc> selection)`
    `void` | `settingsChanged()`

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

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

- - ### Field Detail

    - #### _tmpPt

          protected final java.awt.geom.Point2D.Double _tmpPt

    - #### _tmpTr

          protected final java.awt.geom.AffineTransform _tmpTr

    - #### allNucs

          protected java.util.Collection<Nuc> allNucs

    - #### boxSize

          protected int boxSize

    - #### cachedBounds

          protected java.awt.Rectangle cachedBounds

    - #### controller

          protected SceneController controller

    - #### customCursor

          protected java.awt.Cursor customCursor

    - #### DEFAULT_MARGIN

          private static int DEFAULT_MARGIN

    - #### defaultBgColor

          protected static final java.awt.Color defaultBgColor

    - #### defaultBoxSize

          private static int defaultBoxSize

    - #### defaultLineColor

          protected static final java.awt.Color defaultLineColor

    - #### defaultOutline

          protected static final java.awt.BasicStroke defaultOutline

    - #### enabled

          private boolean enabled

    - #### icon

          protected java.awt.Image icon

    - #### isPerformingDrag

          private boolean isPerformingDrag

    - #### location

          protected java.awt.Point location

    - #### SNAP_DISTANCE

          public static final float SNAP_DISTANCE

      See Also:
        Constant Field Values

    - #### startLocation

          protected java.awt.Point startLocation

    - #### targetNuc

          protected Nuc targetNuc

    - #### view

          protected View2D view

  - ### Constructor Detail

    - #### DrawHandle

          protected DrawHandle(SceneController controller)

  - ### Method Detail

    - #### calcBoxPos

          protected java.awt.geom.Point2D calcBoxPos(java.awt.geom.Point2D location,
                                                     java.awt.geom.Point2D direction,
                                                     double margin,
                                                     DrawSettings settings,
                                                     java.awt.geom.AffineTransform view)

      Calculates the position of the DrawHandle's box based on a starting point and the suggested direction to move away from that point. The returned Point is in device space, but parameters are in model space, so the view transform is are required to convert them.
      Parameters:
        `location` - a Point2D specifying the starting point (e.g. a nucleotide location) in model space.
        `direction` - a Point2D that represents a vector that indicates the direction to move away from the location. This should be given in model space. It will be normalized (to a unit vector) and then multiplied by an appropriate margin.
        `margin` - A margin given in model-space that will be converted to device space and augmented by an additional device-space margin.

    - #### drag

          public final void drag(java.awt.Point start,
                                 java.awt.Point prev,
                                 java.awt.Point current,
                                 SceneController.DragOpts options)

      Called when this handle has been dragged by the user.

    - #### dragComplete

          public void dragComplete(boolean success)

      Called when the user has completed dragging (e.g. on mouse-button-release.) It is appropriate to add an undo event.
      Parameters:
        `success` - Whether the action was successful (and therefore should be stored in the UNDO history).

    - #### dragStarted

          public void dragStarted(java.awt.Point startPos)

    - #### draw

          public final java.awt.Shape draw(java.awt.Graphics2D g,
                                           View2D view,
                                           DrawSettings settings,
                                           boolean isDragging)

    - #### drawBox

          protected java.awt.Shape drawBox(java.awt.Graphics2D g,
                                           View2D view,
                                           DrawSettings settings)

    - #### getBounds

          public java.awt.Rectangle getBounds()

    - #### getBoxSize

          public int getBoxSize()

      Get the size of the default DrawHandle box that the user can click.

    - #### getCompletionEvent

          protected abstract SceneUpdateInfo getCompletionEvent()

    - #### getModelSpaceDeltaTransform

          protected java.awt.geom.AffineTransform getModelSpaceDeltaTransform(java.awt.Point start,
                                                                              java.awt.Point end)

    - #### getSelectionHashCode

          private static int getSelectionHashCode(java.lang.Iterable<Nuc> selection)

    - #### isEnabled

          public boolean isEnabled()

    - #### isUpdating

          public boolean isUpdating()

      Returns true when this DragHandle is performing updates in response to being dragged. Specifically, it is true during a call to `drag(Point, Point, Point, SceneController.DragOpts)`

    - #### isValid

          public abstract boolean isValid()

    - #### layoutUpdated

          public final void layoutUpdated()

      Called when any nucleotides in the scene changed position.

    - #### moveLocation

          protected void moveLocation(java.awt.Point start,
                                      java.awt.Point end)

    - #### nucPositionsChanged

          protected abstract void nucPositionsChanged()

      Called when any nucleotides in the scene changed position, EXCEPT when THIS DrawHandle is in the middle of a performDrag operation (because any nucleotide changes then are likely due to its own drag operation).

    - #### performDrag

          protected abstract void performDrag(java.awt.Point start,
                                              java.awt.Point prev,
                                              java.awt.Point current,
                                              SceneController.DragOpts options)

      Called when this handle has been dragged by the user.

    - #### prepareDraw

          protected abstract void prepareDraw(boolean isDragging)

    - #### selectionChanged

          protected abstract void selectionChanged()

    - #### setBoxSize

          public void setBoxSize(int size)

      Set the size of the default DrawHandle box that the user can click.

    - #### setEnabled

          public void setEnabled(boolean enabled)

    - #### setIcon

          public void setIcon(java.awt.image.BufferedImage icon)

    - #### setSelection

          public void setSelection(Nuc focus,
                                   java.util.Collection<Nuc> selection)

    - #### settingsChanged

          public void settingsChanged()