From df335c8ff29460ef750c0f5e1d4098e75a07282b Mon Sep 17 00:00:00 2001 From: "J. Neugebauer" Date: Wed, 6 Jul 2022 21:13:18 +0200 Subject: [PATCH] =?UTF-8?q?Weitere=20Methoden=20zum=20hinzuf=C3=BCgen=20un?= =?UTF-8?q?d=20entfernen=20von=20Shapes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/schule/ngb/zm/shapes/ShapesLayer.java | 29 +++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/schule/ngb/zm/shapes/ShapesLayer.java b/src/schule/ngb/zm/shapes/ShapesLayer.java index 6fdfed9..8626d12 100644 --- a/src/schule/ngb/zm/shapes/ShapesLayer.java +++ b/src/schule/ngb/zm/shapes/ShapesLayer.java @@ -3,6 +3,7 @@ package schule.ngb.zm.shapes; import schule.ngb.zm.Layer; import java.awt.Graphics2D; +import java.util.Collection; import java.util.LinkedList; public class ShapesLayer extends Layer { @@ -48,17 +49,35 @@ public class ShapesLayer extends Layer { return result; } - public void add( Shape... shape ) { + public void add( Shape... shapes ) { synchronized( shapes ) { - for( Shape f : shape ) { - shapes.add(f); + for( Shape s : shapes ) { + this.shapes.add(s); } } } - public void remove( Shape shape ) { + public void add( Collection shapes ) { synchronized( shapes ) { - shapes.remove(shape); + for( Shape s : shapes ) { + this.shapes.add(s); + } + } + } + + public void remove( Shape... shapes ) { + synchronized( shapes ) { + for( Shape s: shapes ) { + this.shapes.remove(s); + } + } + } + + public void remove( Collection shapes ) { + synchronized( shapes ) { + for( Shape s: shapes ) { + this.shapes.remove(s); + } } }