package shape;

import javafx.geometry.Point2D;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;

public class CenterDecorator extends Decorator{
    private final double radius;
    public CenterDecorator(Shape decoratedShape, double radius) {
        super(decoratedShape);
        this.radius = radius;
    }
        protected void drawDecoration(GraphicsContext context) {

        if (decoratedshape.pointsCount() >= 2) {
            Point2D point0 = decoratedshape.point(0);
            Point2D point1 = decoratedshape.point(1);

            double centerX = point0.getX() + point1.getX() / 2;
            double centerY = point0.getY() + point1.getY() / 2;

            context.setFill(Color.RED);
            context.strokeOval(centerX - radius, centerY - radius, radius * 2, radius * 2);
        }
    }
}