From ec5d278a51eaaf4062010df41cf23f884e4b715b Mon Sep 17 00:00:00 2001
From: Sven Göthel
Date: Sun, 4 Feb 2024 20:49:20 +0100
Subject: GraphUI Cleanup: Use TreeTool directly (Reduce virtl-funcs); Fix
typos; Use PointerListener for onClicked(), add onHover();
Subsequent commits will fix complete cleanup where code was changed mostly regarding other issues.
---
src/graphui/classes/jogamp/graph/ui/TreeTool.java | 29 +++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
(limited to 'src/graphui/classes/jogamp')
diff --git a/src/graphui/classes/jogamp/graph/ui/TreeTool.java b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
index 1a12ff461..d80a6c103 100644
--- a/src/graphui/classes/jogamp/graph/ui/TreeTool.java
+++ b/src/graphui/classes/jogamp/graph/ui/TreeTool.java
@@ -160,11 +160,19 @@ public class TreeTool {
* Each {@link Container} level is sorted using {@code sortComp}
*
* @param cont container of the shapes
+ * @param ascnZOrder if {@code true}, traverse through {@link Container#getRenderedShapes()} in ascending z-axis order (bottom-up), otherwise descending (top-down)
* @param pmv
* @param v
* @return true to signal operation complete and to stop traversal, i.e. {@link Visitor2#visit(Shape, PMVMatrix4f)} returned true, otherwise false
*/
- public static boolean forAllRendered(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) {
+ public static boolean forAllRendered(final Container cont, final boolean ascnZOrder, final PMVMatrix4f pmv, final Visitor2 v) {
+ if( ascnZOrder ) {
+ return forAllRenderedAscn(cont, pmv, v);
+ } else {
+ return forAllRenderedDesc(cont, pmv, v);
+ }
+ }
+ private static boolean forAllRenderedAscn(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) {
final List shapes = cont.getRenderedShapes();
boolean res = false;
@@ -175,7 +183,24 @@ public class TreeTool {
res = v.visit(s, pmv);
if( !res && s instanceof Container ) {
final Container c = (Container)s;
- res = forAllRendered(c, pmv, v);
+ res = forAllRenderedAscn(c, pmv, v);
+ }
+ pmv.popMv();
+ }
+ return res;
+ }
+ private static boolean forAllRenderedDesc(final Container cont, final PMVMatrix4f pmv, final Visitor2 v) {
+ final List shapes = cont.getRenderedShapes();
+ boolean res = false;
+
+ for(int i=shapes.size()-1; !res && i>=0; --i) {
+ final Shape s = shapes.get(i);
+ pmv.pushMv();
+ s.applyMatToMv(pmv);
+ res = v.visit(s, pmv);
+ if( !res && s instanceof Container ) {
+ final Container c = (Container)s;
+ res = forAllRenderedDesc(c, pmv, v);
}
pmv.popMv();
}
--
cgit v1.2.3