/** * Returns a newly created map that centers around the child with index <code>childIndex</code>. * @param childIndex the index of the child * @return the new map */ public DefaultLocationEstimationMap subMap( int childIndex ){ return new DefaultLocationEstimationMap( root.children.get( childIndex ) ); }
public void setLocation( int childIndex, DockableProperty location ){ if( location != null ){ getChild( childIndex ).setLocation( location ); } }
public DockLayoutInfo getChild( int childIndex ){ if( childIndex < 0 || childIndex >= getChildCount() ){ return null; } return root.children.get( childIndex ).composition.getLayout(); }
/** * 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(); }
public void setLocation( int childIndex, int subChildIndex, DockableProperty location ){ if( location != null ){ getSubChild( childIndex, subChildIndex ).setLocation( location ); } }
/** * 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 ); } }