summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Container.java14
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java16
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java11
3 files changed, 33 insertions, 8 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Container.java b/src/graphui/classes/com/jogamp/graph/ui/Container.java
index 3cc8e2ce4..845d41c0c 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Container.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Container.java
@@ -48,8 +48,18 @@ public interface Container {
void addShape(Shape s);
- /** Removes given shape, , w/o {@link Shape#destroy(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) destroying} them. */
- void removeShape(Shape s);
+ /**
+ * Removes given shape, w/o {@link Shape#destroy(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) destroying} them.
+ * @return the removed shape or null if not contained
+ */
+ Shape removeShape(Shape s);
+
+ /**
+ * Removes shape at given index, w/o {@link Shape#destroy(com.jogamp.opengl.GL2ES2, com.jogamp.graph.curve.opengl.RegionRenderer) destroying} them.
+ * @return the removed shape
+ * @throws IndexOutOfBoundsException if index is out of bounds, i.e. (index < 0 || index >= size())
+ */
+ Shape removeShape(final int idx);
void addShapes(Collection<? extends Shape> shapes);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index e831676ed..e748969cf 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -104,15 +104,25 @@ public class Group extends Shape implements Container {
@Override
public void addShape(final Shape s) {
shapes.add(s);
+ markShapeDirty();
}
/** Removes given shape, keeps it alive. */
@Override
- public void removeShape(final Shape s) {
- shapes.remove(s);
+ public Shape removeShape(final Shape s) {
+ final Shape r = shapes.remove(s) ? s : null;
+ markShapeDirty();
+ return r;
}
- /** Removes all given shapes and destroys them. */
+ @Override
+ public Shape removeShape(final int idx) {
+ final Shape r = shapes.remove(idx);
+ markShapeDirty();
+ return r;
+ }
+
+ /** Removes given shape and destroy it. */
public void removeShape(final GL2ES2 gl, final RegionRenderer renderer, final Shape s) {
s.setDebugBox(0f);
shapes.remove(s);
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index a0980246c..c5fb5cd01 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -221,11 +221,16 @@ public final class Scene implements Container, GLEventListener {
shapes.add(s);
}
@Override
- public void removeShape(final Shape s) {
+ public Shape removeShape(final Shape s) {
s.setDebugBox(0f);
- shapes.remove(s);
+ return shapes.remove(s) ? s : null;
}
- /** Removes all given shapes and destroys them. */
+ @Override
+ public Shape removeShape(final int idx) {
+ return shapes.remove(idx);
+ }
+
+ /** Removes given shape and destroy it. */
public void removeShape(final GL2ES2 gl, final Shape s) {
s.setDebugBox(0f);
shapes.remove(s);