package ovh.gasser.newshapes.shapes; import ovh.gasser.newshapes.attributes.ColorAttributes; import ovh.gasser.newshapes.attributes.SelectionAttributes; import ovh.gasser.newshapes.ShapeVisitor; import java.awt.*; public class SRectangle extends AbstractShape { private SRectangle(Rectangle rect) { super(rect); } @Override public void accept(ShapeVisitor visitor) { visitor.visitRectangle(this); } @Override public String toString() { return "SRectangle{" + super.toString() + '}'; } @Override public Shape clone() { var color = (ColorAttributes) this.getAttributes(ColorAttributes.ID); Color strokeColor = color != null ? color.strokedColor : Color.BLACK; return SRectangle.create(super.getBounds().x, super.getBounds().y, getBounds().width, getBounds().height, strokeColor); } public static SRectangle create(int x, int y, int width, int height) { return create(x, y, width, height, Color.BLACK); } public static SRectangle create(int x, int y, int width, int height, Color color) { 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; } }