Class RubberRectPreserveAspect

All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener

public class RubberRectPreserveAspect extends ADragRubberband
Rubberband rectangle that preserves aspect ratio (square in screen space). Matches the old Rubberband Policy.RECTANGLE_PRESERVE_ASPECT behavior.
  • Constructor Details

    • RubberRectPreserveAspect

      public RubberRectPreserveAspect(Component component, IRubberbanded rubberbanded)
  • Method Details

    • modifyCurrentPoint

      protected void modifyCurrentPoint(Point cp)
      Description copied from class: ARubberband
      Hook to modify the current point before using it. Default: clamp to component bounds (old Rubberband behavior).
      Overrides:
      modifyCurrentPoint in class ARubberband
    • draw

      protected void draw(Graphics2D g)
      Description copied from class: ARubberband
      Draw the rubberband shape based on the current state. Called during dragging or when the toolbar requests a preview update. Subclasses must implement this to define the visual appearance of the rubberband.
      Specified by:
      draw in class ARubberband
      Parameters:
      g -
    • getRubberbandBounds

      public Rectangle getRubberbandBounds()
      Description copied from class: ARubberband
      Get the bounding rectangle of the rubberband shape based on the current state. Used for area-based validity checks and as a default for vertex calculations. Subclasses should override this if their shape is not well-represented by a bounding rectangle (e.g. lines, polygons).
      Specified by:
      getRubberbandBounds in class ARubberband
      Returns:
      the bounding rectangle of the rubberband shape, or null if not applicable.