Class RubberLine

All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener
Direct Known Subclasses:
RubberTwoClickLine

public class RubberLine extends ALineClickRubberband
  • Constructor Details

    • RubberLine

      public RubberLine(Component component, IRubberbanded rubberbanded)
    • RubberLine

      protected RubberLine(Component component, IRubberbanded rubberbanded, ARubberband.Policy policy)
      Constructor for subclasses (e.g. RubberTwoClickLine) that share this class's line-gesture behavior but must be registered under a distinct ARubberband.Policy so isClickBased()/policy-aware callers see the correct policy for the instance.
      Parameters:
      component - the component this rubberband operates on
      rubberbanded - the completion callback
      policy - the policy this instance reports
  • Method Details

    • 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.