diff --git a/src/schule/ngb/zm/shapes/ShapesLayer.java b/src/schule/ngb/zm/shapes/ShapesLayer.java index a45cd78..6fdfed9 100644 --- a/src/schule/ngb/zm/shapes/ShapesLayer.java +++ b/src/schule/ngb/zm/shapes/ShapesLayer.java @@ -2,7 +2,7 @@ package schule.ngb.zm.shapes; import schule.ngb.zm.Layer; -import java.awt.*; +import java.awt.Graphics2D; import java.util.LinkedList; public class ShapesLayer extends Layer { @@ -21,14 +21,53 @@ public class ShapesLayer extends Layer { shapes = new LinkedList(); } - public void add( Shape... pFormen ) { + public Shape getShape( int index ) { + return shapes.get(index); + } + + public ST getShape( Class shapeClass ) { + for( Shape s : shapes ) { + if( shapeClass.isInstance(s) ) { + return (ST) s; + } + } + return null; + } + + public java.util.List getShapes() { + return shapes; + } + + public java.util.List getShapes( Class shapeClass ) { + java.util.List result = new LinkedList<>(); + for( Shape s : shapes ) { + if( shapeClass.isInstance(s) ) { + result.add((ST) s); + } + } + return result; + } + + public void add( Shape... shape ) { synchronized( shapes ) { - for( Shape f : pFormen ) { + for( Shape f : shape ) { shapes.add(f); } } } + public void remove( Shape shape ) { + synchronized( shapes ) { + shapes.remove(shape); + } + } + + public void removeAll() { + synchronized( shapes ) { + shapes.clear(); + } + } + public void showAll() { synchronized( shapes ) { for( Shape pShape : shapes ) { @@ -45,10 +84,6 @@ public class ShapesLayer extends Layer { } } - public java.util.List getShapes() { - return shapes; - } - @Override public void draw( Graphics2D pGraphics ) { if( clearBeforeDraw ) {