Add STriangle
This commit is contained in:
31
src/main/java/ovh/gasser/newshapes/shapes/STriangle.java
Normal file
31
src/main/java/ovh/gasser/newshapes/shapes/STriangle.java
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user