Add SCircle

This commit is contained in:
2019-03-19 21:54:57 +01:00
parent 5be59b37f0
commit 98b05e435e
5 changed files with 82 additions and 9 deletions

View File

@@ -1,11 +1,12 @@
package ovh.gasser.newshapes.ui;
import ovh.gasser.newshapes.ShapeVisitor;
import ovh.gasser.newshapes.shapes.Shape;
import ovh.gasser.newshapes.attributes.ColorAttributes;
import ovh.gasser.newshapes.attributes.SelectionAttributes;
import ovh.gasser.newshapes.shapes.SCircle;
import ovh.gasser.newshapes.shapes.SCollection;
import ovh.gasser.newshapes.shapes.SRectangle;
import ovh.gasser.newshapes.shapes.Shape;
import java.awt.*;
@@ -46,6 +47,23 @@ public class ShapeDraftman implements ShapeVisitor {
drawHandlerIfSelected(collection);
}
@Override
public void visitCircle(SCircle circle) {
ColorAttributes colAttrs = (ColorAttributes) circle.getAttributes(ColorAttributes.ID);
final Rectangle bounds = circle.getBounds();
if (colAttrs == null) {
colAttrs = DEFAULT_COLOR_ATTRIBUTES;
}
if (colAttrs.filled) {
this.g2d.setColor(colAttrs.filledColor);
this.g2d.fillOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius());
}
if (colAttrs.stroked) this.g2d.setColor(colAttrs.strokedColor);
this.g2d.drawOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius());
drawHandlerIfSelected(circle);
}
private void drawHandlerIfSelected(Shape s) {
SelectionAttributes selAttrs = (SelectionAttributes) s.getAttributes(SelectionAttributes.ID);
if ((selAttrs != null) && (selAttrs.selected)){