Multiple Selection and Grouping in JavaFX

Multiple Selection
Add to the blob demo so that the user can select multiple blobs, either with Control-click or with rubber-band selection.
Interaction requirements and required code changes:
The selection is now persistent (i.e., the selected blobs stay selected after the user releases the mouse)
Clicking on the background now clears the selection rather than creating a new blob
o
Change the demo’s Controller so that pressing on the background clears the selection rather than creating a blob
Control-clicking: holding the Control key and pressing with the mouse now adds or removes a blob from the selection
o
Add to the Controller to handle the pressing and releasing of the Control key
o
Add a boolean variable controlDown to the InteractionModel
o
Add to the View to show whether the Control key is pressed or not
o
Change the selection variable in the InteractionModel to represent a list of blobs instead of a single blob
o
Add method addSubtractSelection() to the InteractionModel that adds a blob to the selection list (if not already in the
list) or removes the blob from the selection list (if already in the list)
Rubber-band selection: if the user presses on the background and moves, a yellow rectangle will be drawn from the initial press
to the current mouse location. When the user releases the mouse, any blobs completely contained in the yellow rectangle will
be selected.
o
Create a class Rubberband to store the coordinates of the rectangle, and add an instance of Rubberband to your
InteractionModel
o
Add to the controller to handle the new interactions (draw the state diagram first)
o
Add another version of method addSubtractSelection() that can take a list of blobs found inside the rubberband, and
add them to / subtract them from the selection
o
Add a method to the model to return a list of blobs inside a given rectangle
Control + rubberband: holding Control and doing rubberband selection behaves similarly to Control-clicking (anything in the
rubberband on mouse release is added to / subtracted from the current selection list).
If the user presses on a blob that is selected (without the Control key), and then moves the mouse, all selected blobs will be
dragged.
If the user presses on a blob that is not selected (without the Control key), any existing selection is removed and the just-clicked
blob is selected.
If the user presses on the background and drags (without the Control key), any existing selection is removed and the
rubberband selection proceeds as above.
If the user presses and releases on the background (without the Control key), all selections are removed.
See the video (381-A4-multiselect.mp4) for illustrations of these actions.
Grouping and Ungrouping
Once you have a selection that includes a list of blobs rather than a single blob, add the ability to group and ungroup the selection.
Interaction requirements and required code changes:
When the user has selected multiple blobs, they can press the G key to group the items
o
Add to your Controller to handle the pressing of the G key
o
Add method createGroup() in your model to create a new group from the current selection list
Convert your model to work with Groupable items rather than Blobs
o
Create an interface Groupable that will have methods needed for both Blobs and Groups

Leave a Reply

Your email address will not be published. Required fields are marked *