aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp/graph
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-20 05:06:00 +0100
committerSven Göthel <[email protected]>2024-01-20 05:06:00 +0100
commit5e2160edfb53d8896e4f8f0ed43e59a8e963d991 (patch)
tree177bd841c135cdabb0d6d304ee5b35ca25bd3036 /src/graphui/classes/com/jogamp/graph
parentcd47baa406818f99c6d7e7711b7c1d16357456f6 (diff)
GraphUI Group/BoxLayout/GridLayout: Handle empty Group, i.e. detect zero-size and avoid scale=Infinity and zero-sized resulting AABBox
Diffstat (limited to 'src/graphui/classes/com/jogamp/graph')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java6
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java6
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java12
3 files changed, 19 insertions, 5 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index fc6f91980..0cba294cc 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -452,9 +452,9 @@ public class Group extends Shape implements Container {
/**
* {@inheritDoc}
* <p>
- * If relayouting on dirty shape mode is enabler, see {@link #setRelayoutOnDirtyShapes(boolean)},
+ * If re-layouting on dirty shape mode is enabled (default), see {@link #setRelayoutOnDirtyShapes(boolean)},
* this method traverses through all shapes updating all dirty states of all its groups
- * provoking a relayout if required.
+ * provoking a re-layout if required.
* </p>
*/
@Override
@@ -491,8 +491,8 @@ public class Group extends Shape implements Container {
layouter.preValidate(s);
s.validate(gl, glp);
}
+ layouter.layout(this, box, pmv);
}
- layouter.layout(this, box, pmv);
} else if( 0 == shapes.size() ) {
box.resize(0, 0, 0);
} else {
diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
index eb2d752be..bed4b33eb 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/layout/BoxLayout.java
@@ -194,6 +194,9 @@ public class BoxLayout implements Group.Layout {
// IF isScaled: Uniform scale w/ lowest axis scale and center position on lower-scale axis
final float shapeWidthU = sbox.getWidth();
final float shapeHeightU = sbox.getHeight();
+ if( FloatUtil.isZero(shapeHeightU) || FloatUtil.isZero(shapeHeightU) ) {
+ continue;
+ }
final float sxy;
float dxh = 0, dyh = 0;
if( isScaled ) {
@@ -276,6 +279,9 @@ public class BoxLayout implements Group.Layout {
System.err.println("bl("+i+").x: "+box);
}
}
+ if( Float.isInfinite(box.getWidth()) || Float.isInfinite(box.getHeight()) ) {
+ box.resize(0, 0, 0);
+ }
if( TRACE_LAYOUT ) {
System.err.println("bl(X).x: "+box);
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java
index 949ec6fec..43358529a 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java
@@ -210,11 +210,14 @@ public class GridLayout implements Group.Layout {
pmv.pushMv();
s.setTransformMv(pmv);
final AABBox sbox = s.getBounds().transform(pmv.getMv(), new AABBox());
- sboxes[i] = sbox;
pmv.popMv();
final float shapeWidthU = sbox.getWidth();
final float shapeHeightU = sbox.getHeight();
+ if( FloatUtil.isZero(shapeHeightU) || FloatUtil.isZero(shapeHeightU) ) {
+ continue;
+ }
+ sboxes[i] = sbox;
final float sxy;
if( isScaled ) {
// scaling to cell size
@@ -276,7 +279,9 @@ public class GridLayout implements Group.Layout {
for(int i=0; i < shapes.size(); ++i) {
final Shape s = shapes.get(i);
final AABBox sbox = sboxes[i];
-
+ if( null == sbox ) {
+ continue;
+ }
if( TRACE_LAYOUT ) {
System.err.println("gl("+i+")["+col_i+"]["+row_i+"].0: sbox "+sbox+", s "+s);
}
@@ -378,6 +383,9 @@ public class GridLayout implements Group.Layout {
}
}
}
+ if( Float.isInfinite(box.getWidth()) || Float.isInfinite(box.getHeight()) ) {
+ box.resize(0, 0, 0);
+ }
if( TRACE_LAYOUT ) {
System.err.println("gl.xx: "+box);
}