Skip to content
Snippets Groups Projects
Select Git revision
  • c9a08c92e7b22652b923003df78b953f55157e41
  • main default protected
2 results

ComplexTest.java

Blame
  • Forked from LABOUREL Arnaud / M1 INFO FSI TP Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    CenterDecorator.java 843 B
    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);
            }
        }
    }