Package selector
Class PointToPointSelectionModel
java.lang.Object
selector.SelectionModel
selector.PointToPointSelectionModel
Models a selection tool that connects each added point with a straight line.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static enumThe possible states that a point-to-point 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
ConstructorsConstructorDescriptionPointToPointSelectionModel(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`, and attempt to preserve `copy`'s selection if it can be represented without violating the invariants of this class. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd `p` as the next control point of our selection, extending our selection with a straight line segment from the end of the current selection path to `p`.voidClose the current selection path by connecting the last segment to the starting point and transitioning to a "finished" state.Return a straight line segment from our last point to `p`.voidMove the control point with index `index` to `newPos`.voidreset()Clear the current selection path and any starting point.protected voidstartSelection(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 voidRemove 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
-
PointToPointSelectionModel
public PointToPointSelectionModel(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. -
PointToPointSelectionModel
Create a model instance with the same image and event notification policy as `copy`, and attempt to preserve `copy`'s selection if it can be represented without violating the invariants of this class.
-
-
Method Details
-
state
Description copied from class:SelectionModelReturn the status of this model's current selection.- Specified by:
statein classSelectionModel
-
liveWire
Return a straight line segment from our last point to `p`.- Specified by:
liveWirein classSelectionModel
-
appendToSelection
Add `p` as the next control point of our selection, extending our selection with a straight line segment from the end of the current selection path to `p`.- Specified by:
appendToSelectionin classSelectionModel
-
movePoint
Move the control point with index `index` to `newPos`. The segment that previously terminated at the point should be replaced with a straight line connecting the previous point to `newPos`, and the segment that previously started from the point should be replaced with a straight line connecting `newPos` to the next point (where "next" and "previous" wrap around as necessary). Notify listeners that the "selection" property has changed.- Specified by:
movePointin classSelectionModel
-
finishSelection
public void finishSelection()Description copied from class:SelectionModelClose 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:
finishSelectionin classSelectionModel
-
reset
public void reset()Description copied from class:SelectionModelClear 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:
resetin classSelectionModel
-
startSelection
Description copied from class:SelectionModelWhen 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:
startSelectionin classSelectionModel
-
undoPoint
protected void undoPoint()Description copied from class:SelectionModelRemove the last control point from our selection. Listeners will be notified if the "state" or "selection" properties are changed.- Specified by:
undoPointin classSelectionModel
-