diff options
author | Sven Göthel <[email protected]> | 2024-01-20 05:04:15 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-01-20 05:04:15 +0100 |
commit | cd47baa406818f99c6d7e7711b7c1d16357456f6 (patch) | |
tree | 3e879cd8ab65cbfdef38b7482129912f8194401b /src/graphui/classes/com/jogamp/graph/ui | |
parent | c1531c3d99b19032040018b9414263b0d3000147 (diff) |
GraphUI Graph/Scene: Reuse TreeTool for contains(), getShapeByID() and getShapeByName(), also adding full traversion (instead of a flat lookup)
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph/ui')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Group.java | 27 | ||||
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/Scene.java | 16 |
2 files changed, 6 insertions, 37 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index d1156120a..fc6f91980 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -564,19 +564,8 @@ public class Group extends Shape implements Container { @Override public boolean contains(final Shape s) { - if( shapes.contains(s) ) { - return true; - } - for(final Shape shape : shapes) { - if( shape instanceof Container ) { - if( ((Container)shape).contains(s) ) { - return true; - } - } - } - return false; + return TreeTool.contains(shapes, s); } - @Override public Shape getShapeByIdx(final int id) { if( 0 > id ) { @@ -586,21 +575,11 @@ public class Group extends Shape implements Container { } @Override public Shape getShapeByID(final int id) { - for(final Shape b : shapes) { - if(b.getID() == id ) { - return b; - } - } - return null; + return TreeTool.getShapeByID(shapes, id); } @Override public Shape getShapeByName(final String name) { - for(final Shape b : shapes) { - if( b.getName().equals(name) ) { - return b; - } - } - return null; + return TreeTool.getShapeByName(shapes, name); } @Override diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index 03cc29097..fa11f2675 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -332,7 +332,7 @@ public final class Scene implements Container, GLEventListener { @Override public boolean contains(final Shape s) { - return false; + return TreeTool.contains(shapes, s); } @Override public Shape getShapeByIdx(final int id) { @@ -343,21 +343,11 @@ public final class Scene implements Container, GLEventListener { } @Override public Shape getShapeByID(final int id) { - for(final Shape b : shapes) { - if(b.getID() == id ) { - return b; - } - } - return null; + return TreeTool.getShapeByID(shapes, id); } @Override public Shape getShapeByName(final String name) { - for(final Shape b : shapes) { - if( b.getName().equals(name) ) { - return b; - } - } - return null; + return TreeTool.getShapeByName(shapes, name); } /** Returns {@link RegionRenderer#getSampleCount()}. */ |