diff options
author | Sven Gothel <[email protected]> | 2023-04-10 06:11:11 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-10 06:11:11 +0200 |
commit | c71cb787f99d2fe367aaa7eaa03c8d2ba9042ac1 (patch) | |
tree | 2187436a3711668392f514ac6c0b100ffb0581df /src/graphui/classes/jogamp | |
parent | b421ffb2eceba36037add192e786ef75a152aa99 (diff) |
GraphUI TreeTool: For all forAll*(): Allow acting upon Container Shape, i.e. 1st visit Shape, only therafter (if false) traverse into Container
This is required to allow actions on a Container itself.
Diffstat (limited to 'src/graphui/classes/jogamp')
-rw-r--r-- | src/graphui/classes/jogamp/graph/ui/TreeTool.java | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java index ff893ab56..f4fe2813d 100644 --- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java +++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java @@ -51,7 +51,13 @@ public class TreeTool { public static boolean forOne(final List<Shape> shapes, final PMVMatrix pmv, final Shape shape, final Runnable action) { for(int i=shapes.size()-1; i>=0; i--) { final Shape s = shapes.get(i); - if( s instanceof Container ) { + if( s.equals(shape) ) { + pmv.glPushMatrix(); + s.setTransform(pmv); + action.run(); + pmv.glPopMatrix(); + return true; + } else if( s instanceof Container ) { final Container c = (Container)s; if( !c.contains(shape) ) { // fast-path: skip container continue; @@ -62,14 +68,6 @@ public class TreeTool { pmv.glPopMatrix(); if( !res ) { throw new InternalError("Not found "+shape+" in "+c+", but contained"); } return true; - } else { - if( s.equals(shape) ) { - pmv.glPushMatrix(); - s.setTransform(pmv); - action.run(); - pmv.glPopMatrix(); - return true; - } } } return false; @@ -83,12 +81,10 @@ public class TreeTool { public static boolean forAll(final List<Shape> shapes, final Visitor1 v) { for(int i=shapes.size()-1; i>=0; i--) { final Shape s = shapes.get(i); - boolean res; - if( s instanceof Container ) { + boolean res = v.visit(s); + if( !res && s instanceof Container ) { final Container c = (Container)s; res = c.forAll(v); - } else { - res = v.visit(s); } if( res ) { return true; @@ -108,12 +104,10 @@ public class TreeTool { final Shape s = shapes.get(i); pmv.glPushMatrix(); s.setTransform(pmv); - boolean res; - if( s instanceof Container ) { + boolean res = v.visit(s, pmv); + if( !res && s instanceof Container ) { final Container c = (Container)s; res = c.forAll(pmv, v); - } else { - res = v.visit(s, pmv); } pmv.glPopMatrix(); if( res ) { @@ -141,12 +135,10 @@ public class TreeTool { final Shape s = (Shape)shapesS[i]; pmv.glPushMatrix(); s.setTransform(pmv); - boolean res; - if( s instanceof Container ) { + boolean res = v.visit(s, pmv); + if( !res && s instanceof Container ) { final Container c = (Container)s; - res = c.forAll(pmv, v); - } else { - res = v.visit(s, pmv); + res = c.forSortedAll(sortComp, pmv, v); } pmv.glPopMatrix(); if( res ) { |