Class TransformMouseOwner

All Implemented Interfaces:
EventEmitterInterface, MouseListener, MouseMotionListener, MouseWheelListener, EventListener
Direct Known Subclasses:
RotateMouseOwner, ScaleMouseOwner, TranslateMouseOwner

public class TransformMouseOwner extends SnapMouseOwner
A specialized MouseOwner that manages user interaction with a set of 3D transformation handles.

Responsible for detecting when a user clicks on a Handle, selecting an axis for manipulation. Subclasses, such as TranslateMouseOwner or ScaleMouseOwner, extend this class for either no additional stuff or extra drawing using the handles.

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • handles

      public ArrayList<Handle> handles
      The list of 3D handles
    • selectedHandleType

      public HandleType selectedHandleType
      The type of the currently selected handle, or null if no handle is selected.
    • selectionBoundingBox

      public Pair<Integer,Integer> selectionBoundingBox
      The screen-space bounding box (as a radius) for detecting clicks on a handle.
    • distance

      public int distance
    • selectedHandle

      public Handle selectedHandle
      A direct reference to the currently selected handle object, or null.
  • Constructor Details

    • TransformMouseOwner

      public TransformMouseOwner(MOwner mw)
      Constructs a new TransformMouseOwner.
      Parameters:
      mw - The parent MOwner that manages all mouse owners.
  • Method Details

    • isWithinBounds

      private boolean isWithinBounds(MouseEvent e, ScreenPoint p)
      Checks if a mouse event's coordinates are within the circular bounding box of a handle's screen point.
      Parameters:
      e - The mouse event to check.
      p - The screen point of the handle.
      Returns:
      true if the mouse click is on the handle, false otherwise.
    • mousePressedAdapter

      public void mousePressedAdapter(Handle handle)
      An adapter method called when a handle is successfully pressed. Subclasses can override this to perform specific actions upon handle selection.
      Parameters:
      handle - The handle that was pressed.
    • mousePressed

      public void mousePressed(MouseEvent e)
      Handles the mouse pressed event to detect handle selection. It iterates through all managed handles and checks if the click was within the bounds of any of them. If a handle is clicked, it is marked as selected.
      Specified by:
      mousePressed in interface MouseListener
      Overrides:
      mousePressed in class MouseAdapter
      Parameters:
      e - The mouse event.
    • mouseReleased

      public void mouseReleased(MouseEvent e)
      Handles the mouse released event. Subclasses often use this to finalize a transformation.
      Specified by:
      mouseReleased in interface MouseListener
      Overrides:
      mouseReleased in class MouseOwner
      Parameters:
      e - The mouse event.
    • square

      public void square(Graphics2D g, int offset)
      Draws a debug rectangle around the mouse cursor's snapping region.
      Parameters:
      g - The Graphics2D context to draw on.
    • setHandles

      public void setHandles(ArrayList<Handle> handles, ArrayList<GPoint> references)
      Sets the list of handles and the object references to be managed by this owner.
      Parameters:
      handles - The list of Handle objects.
      references - The list of GPoints being transformed (often unused in the base class).
    • mouseClicked

      public void mouseClicked(MouseEvent e)
      Description copied from class: SnapMouseOwner
      Handles mouse click events. If a right-click occurs on a highlighted snap target, it broadcasts a EventType.SNAP_TO_OBJ event with the hoveringOver object.
      Specified by:
      mouseClicked in interface MouseListener
      Overrides:
      mouseClicked in class SnapMouseOwner
      Parameters:
      e - The MouseEvent generated by the click.