Implement copy action
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Spliterator;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class SCollection extends AbstractShape implements Streamable<Shape> {
|
||||
private final static Logger logger = LoggerFactory.getLogger(SCollection.class);
|
||||
@@ -43,6 +44,14 @@ public class SCollection extends AbstractShape implements Streamable<Shape> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Shape clone() {
|
||||
var clonedChildren = children.stream().map(Shape::clone).toArray(Shape[]::new);
|
||||
var collection = new SCollection(clonedChildren);
|
||||
collection.addAttributes(new SelectionAttributes());
|
||||
return collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoc(Point newLoc) {
|
||||
final Point loc = getBounds().getLocation();
|
||||
@@ -59,6 +68,10 @@ public class SCollection extends AbstractShape implements Streamable<Shape> {
|
||||
return children.spliterator();
|
||||
}
|
||||
|
||||
public void add(Shape s) {
|
||||
children.add(s);
|
||||
}
|
||||
|
||||
public void remove(Shape s) {
|
||||
if (!children.remove(s)) {
|
||||
logger.error("Unable to delete shape: {}", s);
|
||||
|
||||
Reference in New Issue
Block a user