From 5bdc5f947353d59930609daad5e223764a1e12e4 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 22 Mar 2023 11:06:23 +0100 Subject: GraphUI Scene: Add removeShape*(GL2ES2..) variant w/ their destruction for convenience --- .../classes/com/jogamp/graph/ui/gl/Scene.java | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/graphui/classes/com/jogamp/graph/ui') diff --git a/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java index 5e7151076..038d1d877 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/gl/Scene.java @@ -196,18 +196,32 @@ public final class Scene implements GLEventListener { public ArrayList getShapes() { return shapes; } - public void addShape(final Shape b) { - shapes.add(b); + public void addShape(final Shape s) { + shapes.add(s); } - public void removeShape(final Shape b) { - shapes.remove(b); + /** Removes given shape, keeps it alive. */ + public void removeShape(final Shape s) { + shapes.remove(s); + } + /** Removes all given shapes and destroys them. */ + public void removeShape(final GL2ES2 gl, final Shape s) { + shapes.remove(s); + s.destroy(gl, renderer); } public void addShapes(final Collection shapes) { this.shapes.addAll(shapes); } + /** Removes all given shapes, keeps them alive. */ public void removeShapes(final Collection shapes) { this.shapes.removeAll(shapes); } + /** Removes all given shapes and destroys them. */ + public void removeShapes(final GL2ES2 gl, final Collection shapes) { + this.shapes.removeAll(shapes); + for(final Shape s : shapes) { + s.destroy(gl, renderer); + } + } public Shape getShapeByIdx(final int id) { if( 0 > id ) { return null; -- cgit v1.2.3