Package edu.cnu.mdi.graphics.rubberband
Class RubberRadArc
java.lang.Object
edu.cnu.mdi.graphics.rubberband.ARubberband
edu.cnu.mdi.graphics.rubberband.AClickRubberband
edu.cnu.mdi.graphics.rubberband.RubberRadArc
- All Implemented Interfaces:
IRubberbandAngleProvider,MouseListener,MouseMotionListener,EventListener
Click-based, three-click radial-arc (pie-wedge) gesture.
Interaction
- First click: the arc's center.
- Second click: the endpoint of the first leg, which fixes the radius
(see
scaleToFirstRadius(java.awt.Point)). - Third click (or drag preview before it): the endpoint of the second leg, whose distance from center is rescaled to match the first leg's radius, and whose angle relative to the first leg determines the swept arc.
Sweep tracking
The signed sweep angle between the two legs, in degrees, is recomputed on
every mouse move via updateSweepForCurrentPoint(java.awt.Point). Because
Math.atan2(double, double) only returns a value in (-180, 180], dragging
the second leg all the way around the center would otherwise cause the
reported sweep to jump discontinuously at the ±180° boundary. This class
instead unwraps the sweep across that boundary, so sweepDeg can
exceed ±180° for a drag that goes more than halfway around, and callers
(via getRubberbandAngleDeg()) see a continuous value rather than a
wrapped one. This unwrapped angle cannot be reconstructed from the
gesture's vertices alone, hence IRubberbandAngleProvider.
-
Nested Class Summary
Nested classes/interfaces inherited from class edu.cnu.mdi.graphics.rubberband.ARubberband
ARubberband.Policy -
Field Summary
Fields inherited from class edu.cnu.mdi.graphics.rubberband.ARubberband
active, backgroundImage, component, currentPt, fillColor, highlightColor1, highlightColor2, image, policy, poly, rubberbanded, started, startPt, tempPoly -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected Point[]Get the vertices of the rubberband shape based on the current state.protected voiddraw(Graphics2D g) Draw the rubberband shape based on the current state.doubleGet the bounding rectangle of the rubberband shape based on the current state.booleanisGestureValid(int minSizePx) Validity rules depend on the policy; default is area-based (bounds must exceed min size).voidMethods inherited from class edu.cnu.mdi.graphics.rubberband.AClickRubberband
ensureStarted, isClickBased, mouseMovedMethods inherited from class edu.cnu.mdi.graphics.rubberband.ARubberband
addPoint, begin, cancel, endRubberbanding, getCurrent, getRubberbandVertices, getStart, isActive, modifyCurrentPoint, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseReleased, setActive, setCurrent, setFillColor, setHighlightColor1, setHighlightColor2, startRubberbanding
-
Constructor Details
-
RubberRadArc
-
-
Method Details
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin classARubberband
-
getRubberbandAngleDeg
public double getRubberbandAngleDeg()- Specified by:
getRubberbandAngleDegin interfaceIRubberbandAngleProvider- Returns:
- signed, unwrapped sweep angle in degrees (may exceed 180 in magnitude)
-
isGestureValid
public boolean isGestureValid(int minSizePx) Description copied from class:ARubberbandValidity rules depend on the policy; default is area-based (bounds must exceed min size). Click-based policies should override with their own rules.- Overrides:
isGestureValidin classARubberband- 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
Description copied from class:ARubberbandGet 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:
computeVerticesin classARubberband- Returns:
- an array of points representing the vertices of the rubberband shape, or null if not applicable.
-
draw
Description copied from class:ARubberbandDraw 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:
drawin classARubberband- Parameters:
g-
-
getRubberbandBounds
Description copied from class:ARubberbandGet 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:
getRubberbandBoundsin classARubberband- Returns:
- the bounding rectangle of the rubberband shape, or null if not applicable.
-