Add STriangle

This commit is contained in:
2026-03-19 19:38:40 +01:00
parent b8ecf9859b
commit f424735a7b
9 changed files with 193 additions and 22 deletions

View File

@@ -0,0 +1,31 @@
package ovh.gasser.newshapes.shapes;
import ovh.gasser.newshapes.ShapeVisitor;
import ovh.gasser.newshapes.attributes.ColorAttributes;
import ovh.gasser.newshapes.attributes.SelectionAttributes;
import java.awt.*;
public class STriangle extends AbstractShape {
private STriangle(int x, int y, int size){
super(new Rectangle(x, y, size, size));
}
@Override
public void accept(ShapeVisitor visitor) {
visitor.visitTriangle(this);
}
@Override
public Shape clone() {
var color = (ColorAttributes) getAttributes(ColorAttributes.ID);
return STriangle.create(super.getBounds().x, super.getBounds().y, super.getBounds().height, color.strokedColor, color.filledColor);
}
public static STriangle create(int x, int y, int size, Color filledColor, Color strokedColor) {
var tri = new STriangle(x, y, size);
tri.addAttributes(new SelectionAttributes());
tri.addAttributes(new ColorAttributes(true, true, filledColor, strokedColor));
return tri;
}
}