From 972682a9247d3b4e8deb07b4ac1867d090f5ffff Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sat, 30 Sep 2023 01:32:28 +0200 Subject: GraphUI: Group: Add attribute to allow not to relayout if child Shapes are dirty. Only issue validate on childs if theyre shape is dirty --- src/graphui/classes/com/jogamp/graph/ui/Group.java | 38 ++++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'src/graphui') diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index 17820702b..fc29b5eb2 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -239,14 +239,20 @@ public class Group extends Shape implements Container { } } + private boolean relayoutOnDirtyShapes = true; + public void setRelayoutOnDirtyShapes(final boolean v) { relayoutOnDirtyShapes = v; } + public boolean getRelayoutOnDirtyShapes() { return relayoutOnDirtyShapes; } + @Override protected boolean isShapeDirty() { - // Deep dirty state update: - // - Ensure all group member's dirty state is updated - // - Allowing all group member's validate to function - for(final Shape s : shapes) { - if( s.isShapeDirty() ) { - markShapeDirty(); + if( relayoutOnDirtyShapes ) { + // Deep dirty state update: + // - Ensure all group member's dirty state is updated + // - Allowing all group member's validate to function + for(final Shape s : shapes) { + if( s.isShapeDirty() ) { + markShapeDirty(); + } } } return super.isShapeDirty(); @@ -266,10 +272,12 @@ public class Group extends Shape implements Container { firstGS = (GraphShape)s; } layouter.preValidate(s); - if( null != gl ) { - s.validate(gl); - } else { - s.validate(glp); + if( s.isShapeDirty() ) { + if( null != gl ) { + s.validate(gl); + } else { + s.validate(glp); + } } } layouter.layout(this, box, pmv); @@ -279,10 +287,12 @@ public class Group extends Shape implements Container { if( needsRMs && null == firstGS && s instanceof GraphShape ) { firstGS = (GraphShape)s; } - if( null != gl ) { - s.validate(gl); - } else { - s.validate(glp); + if( s.isShapeDirty() ) { + if( null != gl ) { + s.validate(gl); + } else { + s.validate(glp); + } } pmv.pushMv(); s.setTransformMv(pmv); -- cgit v1.2.3