It is possible to add submanagers to a manager in two
different ways:
This first approach requires multiple recalculations
of the bounds of the parent manager while filling the submanager.
Adding an object to the submanager might not only change the bounds
of the submanager but also the bounds of all its ancestor managers.
-
Add the submanager to its parent manager.
-
The second approach avoids changing the bounds of all
its ancestor managers and is always faster. Generally, it is faster
to add a subobject to a manager after all the customizations of the
subobject are completed.
-
-
Add it to its parent manager.
However, it is not always possible to control the order
in which objects are added to managers. In this case, insertion adjusting
sessions help:
manager.setInsertionAdjusting(true);
try {
... add nested managers and nodes recursively in any order ..
} finally {
manager.setInsertionAdjusting(false);
}
This ensures that the performance is optimal even when
submanagers and their contents are added in the wrong order. It ensures
that the bounding boxes of the manager and its all submanagers are
only recalculated when setting the insertion adjusting flag to false
. Events related to the change of the bounds of
the managers are also delayed until this time.
The insertion adjusting flag needs only to be set at
the top level manager, and it will be automatically propagated to
all existing and newly created submanagers. The insertion adjusting
flag affects only the performance when objects are added. It has no
effect when objects are removed.