Class RubberPolygon

All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener

public class RubberPolygon extends APolyClickRubberband
  • Constructor Details

  • Method Details

    • minPointsToAccept

      protected int minPointsToAccept()
      Description copied from class: APolyClickRubberband
      Minimum required points before accepting end.
      Overrides:
      minPointsToAccept in class APolyClickRubberband
    • isGestureValid

      public boolean isGestureValid(int minSizePx)
      Description copied from class: ARubberband
      Validity rules depend on the policy; default is area-based (bounds must exceed min size). Click-based policies should override with their own rules.
      Overrides:
      isGestureValid in class ARubberband
      Parameters:
      minSizePx - minimum size in pixels for validity; interpretation depends on policy (e.g. max dimension for polygons).
      Returns:
      true if the current gesture state is valid for completion, false if it should be rejected (e.g. too small).
    • computeVertices

      protected Point[] computeVertices()
      Description copied from class: ARubberband
      Get the vertices of the rubberband shape based on the current state. Used for click-based policies and by toolbars to read results. Default implementation returns the corners of the bounding rectangle, which is suitable for rectangles and ovals but not for lines or polygons. Subclasses should override this if their shape has specific vertex requirements.
      Overrides:
      computeVertices in class ARubberband
      Returns:
      an array of points representing the vertices of the rubberband shape, or null if not applicable.
    • 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.