From ad45eddbf5776794004cbc3277bd4e2b6c6205a3 Mon Sep 17 00:00:00 2001 From: Thibaud Date: Thu, 19 Mar 2026 19:05:12 +0100 Subject: [PATCH] fix confusion between circle radius and diameter classic shite --- src/main/java/ovh/gasser/newshapes/App.java | 2 +- src/main/java/ovh/gasser/newshapes/shapes/SCircle.java | 4 ++-- src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/ovh/gasser/newshapes/App.java b/src/main/java/ovh/gasser/newshapes/App.java index 8e3dc2c..4424097 100644 --- a/src/main/java/ovh/gasser/newshapes/App.java +++ b/src/main/java/ovh/gasser/newshapes/App.java @@ -57,7 +57,7 @@ public class App { SCollection.of( SRectangle.create(100, 200, 40, 60, Color.MAGENTA), SRectangle.create(150, 200, 40, 60, Color.MAGENTA), - SCircle.create(200, 200, 60) + SCircle.create(200, 250, 30) ) ); } diff --git a/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java b/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java index 51b05c0..568a4ca 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java @@ -8,10 +8,10 @@ import java.awt.*; public class SCircle extends AbstractShape { - private int radius; + private final int radius; private SCircle(int x, int y, int radius) { - super(new Rectangle(x, y, radius, radius)); + super(new Rectangle(x, y, radius * 2, radius * 2)); this.radius = radius; } diff --git a/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java b/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java index 983ba9b..7eb9af5 100644 --- a/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java +++ b/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java @@ -56,10 +56,10 @@ public class ShapeDraftman implements ShapeVisitor { } if (colAttrs.filled) { this.g2d.setColor(colAttrs.filledColor); - this.g2d.fillOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius()); + this.g2d.fillOval(bounds.x, bounds.y, 2 * circle.getRadius(), 2 * circle.getRadius()); } if (colAttrs.stroked) this.g2d.setColor(colAttrs.strokedColor); - this.g2d.drawOval(bounds.x, bounds.y, circle.getRadius(), circle.getRadius()); + this.g2d.drawOval(bounds.x, bounds.y, 2 * circle.getRadius(), 2 * circle.getRadius()); drawHandlerIfSelected(circle); }