Package edu.cnu.mdi.graphics.rubberband
Class RubberPolyline
java.lang.Object
edu.cnu.mdi.graphics.rubberband.ARubberband
edu.cnu.mdi.graphics.rubberband.AClickRubberband
edu.cnu.mdi.graphics.rubberband.APolyClickRubberband
edu.cnu.mdi.graphics.rubberband.RubberPolyline
- All Implemented Interfaces:
MouseListener,MouseMotionListener,EventListener
-
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.Get 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).protected intMinimum required points before accepting end.Methods inherited from class edu.cnu.mdi.graphics.rubberband.APolyClickRubberband
addPointOnDoubleClick, mousePressedMethods 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
-
RubberPolyline
-
-
Method Details
-
minPointsToAccept
protected int minPointsToAccept()Description copied from class:APolyClickRubberbandMinimum required points before accepting end.- Overrides:
minPointsToAcceptin classAPolyClickRubberband
-
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.
-