/** * Tries to guess the location of the elements stored in the tree * below <code>composition</code>. Invoking this method is the same as calling * <code>guessLocation( composition, composition.getLayout().getLocation() );</code>. * @param composition the composition whose location will be determined */ public void estimateLocations( DockLayoutComposition composition ){ estimateLocations( composition, composition.getLayout().getLocation() ); }
/** * Tries to guess the location of the elements stored in the tree below * <code>composition</code>, assuming that <code>composition</code> itself * is at location <code>location</code>. This method reads out the * {@link DockLayoutInfo} through {@link DockLayoutComposition#getLayout()} * and then calls {@link DockLayoutInfo#setLocation(DockableProperty)}, so * <code>composition</code> gets modified by this method. This method stops * its recursion if the location of a child of <code>composition</code> * was not found.<br> * This method returns immediately if one of: * <ul> * <li><code>composition</code> does not have children</li> * <li><code>composition</code> does not carry a {@link DockLayout}</li> * <li>There is no {@link DockFactory} registered for the factory-id found * in <code>composition</code></li> * </ul> <br> * Note: if the number of factories changed, then it might be a good idea * to call {@link #fillMissing(DockLayoutComposition)} before invoking this method. * @param composition the composition whose children should be analyzed * @param location the location of <code>composition</code>, can be <code>null</code> */ public void estimateLocations( DockLayoutComposition composition, DockableProperty location ){ DefaultLocationEstimationMap map = new DefaultLocationEstimationMap( composition ); estimateLocations( map ); if( location != null ){ appendFirstOnEstimate( composition, location ); } }
/** * Recursively tries to estimate the locations of all {@link DockLayoutInfo}s that can * be found in <code>map</code>.<br> * <b>Note:</b> this method does <i>not</i> call {@link DefaultLocationEstimationMap#finish()}. * @param map the root of the tree for which locations need to be estimated */ @SuppressWarnings("unchecked") protected void estimateLocations( DefaultLocationEstimationMap map ){ DockLayoutComposition composition = map.getRoot(); List<DockLayoutComposition> children = composition.getChildren(); if( children == null || children.size() == 0 ){ return; } DockLayout<Object> layout = (DockLayout<Object>)composition.getLayout().getDataLayout(); if( layout == null ){ return; } DockFactory<DockElement,?,Object> factory = (DockFactory<DockElement,?,Object>)getFactory( layout.getFactoryID() ); if( factory == null ){ return; } for( int i = 0, n = map.getChildCount(); i<n; i++ ){ estimateLocations( map.subMap( i ) ); } map.prepare(); factory.estimateLocations( layout.getData(), map ); map.finish(); }