Implement copy action

This commit is contained in:
2025-02-19 11:27:45 +01:00
parent b4eac668c8
commit aea90f5a93
8 changed files with 58 additions and 14 deletions

View File

@@ -24,14 +24,19 @@ public class SRectangle extends AbstractShape {
'}';
}
@Override
public Shape clone() {
var color = (ColorAttributes) this.getAttributes(ColorAttributes.ID);
return SRectangle.create(super.getBounds().x, super.getBounds().y, getBounds().width, getBounds().height, color.strokedColor);
}
public static SRectangle create(int x, int y, int width, int height) {
SRectangle rect = new SRectangle(new Rectangle(x, y, width, height));
rect.addAttributes(new SelectionAttributes());
return rect;
return create(x, y, width, height, Color.BLACK);
}
public static SRectangle create(int x, int y, int width, int height, Color color) {
final SRectangle rect = create(x, y, width, height);
SRectangle rect = new SRectangle(new Rectangle(x, y, width, height));
rect.addAttributes(new SelectionAttributes());
rect.addAttributes(new ColorAttributes(false, true, Color.BLACK, color));
return rect;
}