Skip to content
Snippets Groups Projects
Commit 21ecc668 authored by BENHILA Douaa's avatar BENHILA Douaa
Browse files

add class CenterDecorator and add method draw decoration

parent bbd61760
No related branches found
No related tags found
No related merge requests found
Pipeline #34157 failed
package shape;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.geometry.Point2D;
import shape.Shape;
public class CenterDecorator extends Decorator{
private double radius;
public CenterDecorator(Shape decoratedShape, double radius){
super(decoratedShape);
this.radius=radius;
}
@Override
protected void drawDecoration(GraphicsContext graphicsContext) {
graphicsContext.setStroke(Color.RED); // Définir la couleur de la décoration
// Calculer le centre de la forme décorée
Point2D center = point(0);
// Dessiner un cercle autour du centre
graphicsContext.fillOval(center.getX() - radius, center.getY() - radius, radius * 2, radius * 2);
}
public void draw(GraphicsContext graphicsContext) {
super.draw(graphicsContext);
drawDecoration(graphicsContext);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment