Package kiyut.sketsa.canvas.tool

## Class DefaultResizeTool

- java.lang.Object
- - kiyut.sketsa.canvas.tool.AbstractTool
  - - kiyut.sketsa.canvas.tool.DefaultResizeTool

- All Implemented Interfaces:
    `KeyListener`, `MouseListener`, `MouseMotionListener`, `EventListener`, `MouseInputListener`, `ResizeTool`, `Tool`

      public class DefaultResizeTool
      extends AbstractTool
      implements ResizeTool

  Implementation of Resize Tool
  Author:
    Kiyut

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultResizeTool()` | Creates a new instance of ResizeTool

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected AffineTransform` | `createTransform()` | create resize transform
    `protected int` | `determineDirection​(int x, int y)` | Determine direction.
    `void` | `endTool()` | Invoked when the tool is ended
    `void` | `mouseDragged​(MouseEvent evt)` |
    `void` | `mousePressed​(MouseEvent evt)` |
    `void` | `mouseReleased​(MouseEvent evt)` |
    `void` | `paint​(Graphics2D g2d)` | Invoked by canvas to draw tool.
    `void` | `setVectorCanvas​(VectorCanvas canvas)` | set the canvas for the tool
    `void` | `startTool()` | Invoked when the tool is started
    `protected void` | `swap​(double[] array, int index1, int index2)` |
    `protected void` | `updateDOM()` | update the model by scaling.
    `protected void` | `updateOutline()` | update outline

    - ### Methods inherited from class kiyut.sketsa.canvas.tool.AbstractTool

      `addMessageListener, fireMessageReceived, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mouseMoved, removeMessageListener`

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

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

    - ### Methods inherited from interface java.awt.event.KeyListener

      `keyPressed, keyReleased, keyTyped`

    - ### Methods inherited from interface java.awt.event.MouseListener

      `mouseClicked, mouseEntered, mouseExited`

    - ### Methods inherited from interface java.awt.event.MouseMotionListener

      `mouseMoved`

    - ### Methods inherited from interface kiyut.sketsa.canvas.tool.Tool

      `addMessageListener, removeMessageListener`

- - ### Constructor Detail

    - #### DefaultResizeTool

          public DefaultResizeTool()

      Creates a new instance of ResizeTool

  - ### Method Detail

    - #### paint

          public void paint​(Graphics2D g2d)

      Description copied from interface: `Tool`
      Invoked by canvas to draw tool.
      Specified by:
        `paint` in interface `Tool`
      Overrides:
        `paint` in class `AbstractTool`
      Parameters:
        `g2d` - the Graphics2D context in which to paint

    - #### setVectorCanvas

          public void setVectorCanvas​(VectorCanvas canvas)

      Description copied from interface: `Tool`
      set the canvas for the tool
      Specified by:
        `setVectorCanvas` in interface `Tool`
      Overrides:
        `setVectorCanvas` in class `AbstractTool`
      Parameters:
        `canvas` - VectorCanvas

    - #### startTool

          public void startTool()

      Description copied from interface: `Tool`
      Invoked when the tool is started
      Specified by:
        `startTool` in interface `Tool`
      Overrides:
        `startTool` in class `AbstractTool`

    - #### endTool

          public void endTool()

      Description copied from interface: `Tool`
      Invoked when the tool is ended
      Specified by:
        `endTool` in interface `Tool`
      Overrides:
        `endTool` in class `AbstractTool`

    - #### determineDirection

          protected int determineDirection​(int x,
                                           int y)

      Determine direction. The direction is in phone keypad format.
      Parameters:
        `x` - the X
        `y` - the Y
      Returns:
        direction or -1
      See Also:
        `CanvasSelection.getBorder()`

    - #### createTransform

          protected AffineTransform createTransform()

      create resize transform
      Returns:
        AffineTransform

    - #### swap

          protected void swap​(double[] array,
                              int index1,
                              int index2)

    - #### updateDOM

          protected void updateDOM()

      update the model by scaling.
      1. get the selections bound in canvas transform
      2. create resizeAT based on the selections bounds (use selection bound x and y as translation point)
      3. get the globalTransform and canvasTransform
      4. transform using global and canvasTransform
      5. transform using resizeAT
      6. transform back using global and canvasTransform inverse Transform

    - #### updateOutline

          protected void updateOutline()

      update outline

    - #### mouseDragged

          public void mouseDragged​(MouseEvent evt)

      Specified by:
        `mouseDragged` in interface `MouseMotionListener`
      Overrides:
        `mouseDragged` in class `AbstractTool`

    - #### mousePressed

          public void mousePressed​(MouseEvent evt)

      Specified by:
        `mousePressed` in interface `MouseListener`
      Overrides:
        `mousePressed` in class `AbstractTool`

    - #### mouseReleased

          public void mouseReleased​(MouseEvent evt)

      Specified by:
        `mouseReleased` in interface `MouseListener`
      Overrides:
        `mouseReleased` in class `AbstractTool`