From 5e2160edfb53d8896e4f8f0ed43e59a8e963d991 Mon Sep 17 00:00:00 2001 From: Sven Göthel Date: Sat, 20 Jan 2024 05:06:00 +0100 Subject: GraphUI Group/BoxLayout/GridLayout: Handle empty Group, i.e. detect zero-size and avoid scale=Infinity and zero-sized resulting AABBox --- .../classes/com/jogamp/graph/ui/layout/GridLayout.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/graphui/classes/com/jogamp/graph/ui/layout/GridLayout.java') 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); } -- cgit v1.2.3