Class ItemModification

java.lang.Object
edu.cnu.mdi.item.ItemModification

public class ItemModification extends Object
Mutable state for one interactive item operation.

The object captures the item's original geometry and initial mouse position, then tracks the current mouse position in both local and world coordinates while a drag, resize, or rotation is in progress.

  • Constructor Details

    • ItemModification

      public ItemModification(AItem item, IContainer container, Point startMousePoint, Point currentMousePoint, boolean shift, boolean control)
      Create an ItemModification. The type is the default: DRAG. It can be changed via setType.
      Parameters:
      item - the item being modified.
      container - the item's container.
      startMousePoint - the mouse point where the item was grabbed.
      currentMousePoint - the current mouse point.
      shift - was shift pressed when modification began
      control - was control pressed when modification began
      Throws:
      NullPointerException - if item or container is null
  • Method Details

    • getType

      Get the type of modification.
      Returns:
      the type of modification
    • setType

      public void setType(ItemModification.ModificationType type)
      Set the type of modification.
      Parameters:
      type - the type to set
    • getCurrentMousePoint

      public Point getCurrentMousePoint()
      Get the current location of the mouse.
      Returns:
      the currentMousePoint
    • setCurrentMousePoint

      public void setCurrentMousePoint(Point currentMousePoint)
      Set the current mouse location. This will be done by the PointerButton.
      Parameters:
      currentMousePoint - the currentMousePoint to set
    • getStartFocus

      public Point2D.Double getStartFocus()
      The focus is the world reference point for the item. It might be its location or its centroid. It has to be set by the item when
      Returns:
      the startFocus
    • setStartFocus

      public void setStartFocus(Point2D.Double startFocus)
      The focus is the world reference point for the item. It might be its location or its centroid. It has to be set by the item when the modification starts.
      Parameters:
      startFocus - the startFocus to set
    • getStartFocusPoint

      public Point getStartFocusPoint()
      The focus is the screen (pixel) version of reference point for the item. It might be its location or its centroid. It has to be set by the item when the modification starts.
      Returns:
      the startFocusPoint
    • setStartFocusPoint

      public void setStartFocusPoint(Point startFocusPoint)
      The focus is the screen (pixel) version reference point for the item. It might be its location or its centroid. It has to be set by the item when the modification starts.
      Parameters:
      startFocusPoint - the startFocusPoint to set
    • getSelectIndex

      public int getSelectIndex()
      The selectIndex can be used by the item to cache the index of the selectRect that started the modification. This is often needed for resizing and rotating.
      Returns:
      the selectIndex
    • setSelectIndex

      public void setSelectIndex(int selectIndex)
      The selectIndex can be used by the item to cache the index of the selectRect that started the modification. This is often needed for resizing and rotating.
      Parameters:
      selectIndex - the selectIndex to set
    • getItem

      public AItem getItem()
      Get the item being modified.
      Returns:
      the item being modified.
    • getContainer

      public IContainer getContainer()
      Get the container that holds the item on one of its layers.
      Returns:
      the container holding the item.
    • getStartMousePoint

      public Point getStartMousePoint()
      Get the point where the grab was initiated.
      Returns:
      the startMousePoint the point where the grab was initiated.
    • getStartPath

      public Path2D.Double getStartPath()
      Returns:
      the startPath
    • getStartLine

      public Line2D.Double getStartLine()
      Returns:
      the startLine
    • getStartWorldPoint

      public Point2D.Double getStartWorldPoint()
      Returns:
      the startWorldPoint
    • getCurrentWorldPoint

      public Point2D.Double getCurrentWorldPoint()
      Returns:
      the currentWorldPoint
    • isShift

      public boolean isShift()
      Returns:
      the shift flag
    • isControl

      public boolean isControl()
      Returns:
      the control falg
    • getStartAzimuth

      public double getStartAzimuth()
      Returns:
      the startAzimuth
    • getStartLocation

      public Point getStartLocation()
      Returns:
      the startLocation
    • setStartLocation

      public void setStartLocation(Point startLocation)
      Parameters:
      startLocation - the startLocation to set
    • getUserObject

      public Object getUserObject()
      Returns:
      the userObject
    • setUserObject

      public void setUserObject(Object userObject)
      Parameters:
      userObject - the userObject to set