handle multiple selection with shift
This commit is contained in:
@@ -2,23 +2,30 @@ package ovh.gasser.newshapes;
|
||||
|
||||
import ovh.gasser.newshapes.attributes.SelectionAttributes;
|
||||
import ovh.gasser.newshapes.shapes.Shape;
|
||||
import ovh.gasser.newshapes.util.Streamable;
|
||||
|
||||
public class Selection {
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
private final SelectionAttributes attributes;
|
||||
public final Shape shape;
|
||||
public class Selection implements Streamable<Shape> {
|
||||
private final List<Shape> selectedShapes = new ArrayList<>();
|
||||
|
||||
public Selection(final Shape shape, boolean selected) {
|
||||
this(shape);
|
||||
attributes.selected = selected;
|
||||
@Override
|
||||
public Iterator<Shape> iterator() {
|
||||
return selectedShapes.iterator();
|
||||
}
|
||||
|
||||
private Selection(final Shape shape) {
|
||||
attributes = (SelectionAttributes) shape.getAttributes(SelectionAttributes.ID);
|
||||
this.shape = shape;
|
||||
public void clear() {
|
||||
for (Shape shape : selectedShapes) {
|
||||
shape.addAttributes(new SelectionAttributes(false));
|
||||
}
|
||||
|
||||
selectedShapes.clear();
|
||||
}
|
||||
|
||||
public void unselect() {
|
||||
attributes.selected = false;
|
||||
public void add(Shape s) {
|
||||
selectedShapes.add(s);
|
||||
s.addAttributes(new SelectionAttributes(true));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user