Package selector
Class SplineSelectionModel
java.lang.Object
selector.SelectionModel
selector.SplineSelectionModel
Models a selection tool that connects every other control point with a cubic Bezier spline that
bends towards the interleaving points. Note: while the spline formulation is technically cubic,
the intermediate points of each segment are constrained to be identical, reducing the degrees of
freedom. The overall selection is C0 continuous.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enum
The possible states that a spline selection model can be in.Nested classes/interfaces inherited from class selector.SelectionModel
SelectionModel.SelectionState
-
Field Summary
Fields inherited from class selector.SelectionModel
controlPoints, img, propSupport, segments
-
Constructor Summary
ConstructorsConstructorDescriptionSplineSelectionModel
(boolean notifyOnEdt) Create a model instance with no selection and no image.Create a model instance with the same image and event notification policy as `copy`. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add `p` as the next control point of our selection.void
Close the current selection path by connecting the last segment to the starting point and transitioning to a "finished" state.If we currently have an odd number of control points, return a straight line segment from our last control point to `p`.void
Move a control point with index `index` in our list of control points to `newPos`, updating the segments in our selection influenced by the point.void
reset()
Clear the current selection path and any starting point.protected void
startSelection
(Point start) When no selection has yet been started, set our first control point to `start` and transition to the appropriate state.state()
Return the status of this model's current selection.protected void
Remove the last control point from our selection.Methods inherited from class selector.SelectionModel
addPoint, addPropertyChangeListener, addPropertyChangeListener, cancelProcessing, closestPoint, controlPoints, getProcessingProgress, image, lastPoint, removePropertyChangeListener, removePropertyChangeListener, saveSelection, selection, setImage, undo
-
Constructor Details
-
SplineSelectionModel
public SplineSelectionModel(boolean notifyOnEdt) Create a model instance with no selection and no image. If `notifyOnEdt` is true, property change listeners will be notified on Swing's Event Dispatch thread, regardless of which thread the event was fired from. -
SplineSelectionModel
Create a model instance with the same image and event notification policy as `copy`. If `copy` is a `SplineSelectionModel`, preserve its selection. Otherwise, the selection is set to empty.
-
-
Method Details
-
state
Description copied from class:SelectionModel
Return the status of this model's current selection.- Specified by:
state
in classSelectionModel
-
reset
public void reset()Description copied from class:SelectionModel
Clear the current selection path and any starting point. Listeners will be notified if the "state" or "selection" properties are changed. Subclasses should override this method in order to transition to an empty state.- Overrides:
reset
in classSelectionModel
-
undoPoint
protected void undoPoint()Description copied from class:SelectionModel
Remove the last control point from our selection. Listeners will be notified if the "state" or "selection" properties are changed.- Specified by:
undoPoint
in classSelectionModel
-
startSelection
Description copied from class:SelectionModel
When no selection has yet been started, set our first control point to `start` and transition to the appropriate state. Listeners will be notified that the "state" property has changed. Throws an `IllegalStateException` if our state is not empty.The default implementation checks that the state is empty and adds the control point. Subclasses must override this method in order to perform the state transition and notify listeners.
- Overrides:
startSelection
in classSelectionModel
-
liveWire
If we currently have an odd number of control points, return a straight line segment from our last control point to `p`. Otherwise, return a Bezier curve from our penultimate control point to `p`, previewing the segment that would extend our selection if `p` were added as the next control point.- Specified by:
liveWire
in classSelectionModel
-
movePoint
Move a control point with index `index` in our list of control points to `newPos`, updating the segments in our selection influenced by the point. Notify listeners that the "selection" property has changed.- Specified by:
movePoint
in classSelectionModel
-
appendToSelection
Add `p` as the next control point of our selection. If this results in an odd number of control points, extend our selection with a cubic Bezier spline between our previous penultimate point and `p`, influenced by our previous last point.- Specified by:
appendToSelection
in classSelectionModel
-
finishSelection
public void finishSelection()Description copied from class:SelectionModel
Close the current selection path by connecting the last segment to the starting point and transitioning to a "finished" state. If no segments have been added yet, reset this selection instead. Listeners will be notified if the "state" or "selection" properties are changed. Throws an `IllegalStateException` if the selection is already finished or cannot be finished.- Specified by:
finishSelection
in classSelectionModel
-