diff --git a/src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java b/src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java index 72eecff..b8a4a7d 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/AbstractShape.java @@ -75,7 +75,7 @@ public abstract class AbstractShape implements Shape { @Override public Rectangle getBounds() { - return this.bounds; + return new Rectangle(this.bounds); } @Override diff --git a/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java b/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java index d1e2f84..98107de 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/SCircle.java @@ -49,7 +49,8 @@ public class SCircle extends AbstractShape { @Override public Shape clone() { var color = (ColorAttributes) getAttributes(ColorAttributes.ID); - return SCircle.create(super.getBounds().x, super.getBounds().y, this.radius, color.strokedColor); + Color strokeColor = color != null ? color.strokedColor : Color.BLACK; + return SCircle.create(super.getBounds().x, super.getBounds().y, this.radius, strokeColor); } public int getRadius() { diff --git a/src/main/java/ovh/gasser/newshapes/shapes/SCollection.java b/src/main/java/ovh/gasser/newshapes/shapes/SCollection.java index 73828ab..5a124ea 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/SCollection.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/SCollection.java @@ -39,7 +39,7 @@ public class SCollection extends AbstractShape implements Streamable { for (Shape s : children) bounds = bounds.union(s.getBounds()); return bounds; } catch (IndexOutOfBoundsException e){ - logger.error("getBounds(): {e}", e); + logger.error("getBounds(): {}", e); throw new RuntimeException(e); } } diff --git a/src/main/java/ovh/gasser/newshapes/shapes/SRectangle.java b/src/main/java/ovh/gasser/newshapes/shapes/SRectangle.java index 9f868d4..b718f10 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/SRectangle.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/SRectangle.java @@ -27,7 +27,8 @@ public class SRectangle extends AbstractShape { @Override public Shape clone() { var color = (ColorAttributes) this.getAttributes(ColorAttributes.ID); - return SRectangle.create(super.getBounds().x, super.getBounds().y, getBounds().width, getBounds().height, color.strokedColor); + Color strokeColor = color != null ? color.strokedColor : Color.BLACK; + return SRectangle.create(super.getBounds().x, super.getBounds().y, getBounds().width, getBounds().height, strokeColor); } public static SRectangle create(int x, int y, int width, int height) { diff --git a/src/main/java/ovh/gasser/newshapes/shapes/STriangle.java b/src/main/java/ovh/gasser/newshapes/shapes/STriangle.java index af19f28..e4c581a 100644 --- a/src/main/java/ovh/gasser/newshapes/shapes/STriangle.java +++ b/src/main/java/ovh/gasser/newshapes/shapes/STriangle.java @@ -67,7 +67,9 @@ public class STriangle extends AbstractShape { @Override public Shape clone() { var color = (ColorAttributes) getAttributes(ColorAttributes.ID); - return STriangle.create(super.getBounds().x, super.getBounds().y, super.getBounds().height, color.strokedColor, color.filledColor); + Color strokeColor = color != null ? color.strokedColor : Color.BLACK; + Color fillColor = color != null ? color.filledColor : Color.BLACK; + return STriangle.create(super.getBounds().x, super.getBounds().y, super.getBounds().height, fillColor, strokeColor); } public static STriangle create(int x, int y, int size, Color filledColor, Color strokedColor) { diff --git a/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java b/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java index cd1bc55..3d00f86 100644 --- a/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java +++ b/src/main/java/ovh/gasser/newshapes/ui/ShapeDraftman.java @@ -60,8 +60,10 @@ public class ShapeDraftman implements ShapeVisitor { this.g2d.setColor(colAttrs.filledColor); 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, 2 * circle.getRadius(), 2 * circle.getRadius()); + if (colAttrs.stroked) { + this.g2d.setColor(colAttrs.strokedColor); + this.g2d.drawOval(bounds.x, bounds.y, 2 * circle.getRadius(), 2 * circle.getRadius()); + } drawHandlerIfSelected(circle); }