/** * Adds two elements horizontally. * @param left the left element * @param right the right element * @param divider how much space the first element gets in respect * to the second element. Must be between 0 and 1. * @return a key of the combination of the two elements */ public Key horizontal( D left, D right, double divider ){ return horizontal( put( array( left ) ), put( array( right ) ), divider ); }
if( tree.isDockable( key )){ PerspectiveDockable[] dockables = tree.getDockables( key ); PerspectiveDockable dockable = null; dockable = combine( dockables, tree.getSelected( key ) ); return new Leaf( dockable, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() ); if( tree.isNode( key )){ Entry childA = convert( tree.getLeft( key )); Entry childB = convert( tree.getRight( key )); Orientation orientation; if( tree.isHorizontal( key )){ orientation = Orientation.HORIZONTAL; return new Node( orientation, tree.getDivider( key ), childA, childB, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
@Override public void evolve( SplitDockTree<Dockable>.Key key, boolean checkValidity, Map<Leaf, Dockable> linksToSet ){ SplitDockTree<Dockable> tree = key.getTree(); setPlaceholders( tree.getPlaceholders( key ) ); setPlaceholderMap( tree.getPlaceholderMap( key ) ); if( tree.isHorizontal( key )){ orientation = SplitDockStation.Orientation.HORIZONTAL; setLeft( create( tree.getLeft( key ), checkValidity, linksToSet )); setRight( create( tree.getRight( key ), checkValidity, linksToSet )); setDivider( tree.getDivider( key )); } else{ orientation = SplitDockStation.Orientation.VERTICAL; setLeft( create( tree.getTop( key ), checkValidity, linksToSet )); setRight( create( tree.getBottom( key ), checkValidity, linksToSet )); setDivider( tree.getDivider( key )); } }
SplitDockTree<Dockable> tree = key.getTree(); if( tree.isDockable( key )){ Dockable[] dockables = tree.getDockables( key ); if( dockables == null || dockables.length == 0 ){ Path[] placeholders = tree.getPlaceholders( key ); Placeholder leaf = createPlaceholder( key.getNodeId() ); leaf.setPlaceholders( placeholders ); leaf.setPlaceholderMap( tree.getPlaceholderMap( key )); return leaf; CombinerSource source = new NodeCombinerSource( dockables[0], dockables[1], key.getTree().getPlaceholderMap( key ) ); CombinerTarget target = combiner.prepare( source, Enforcement.HARD ); Dockable selected = key.getTree().getSelected( key ); if( selected != null ) station.setFrontDockable( selected ); Dockable selected = key.getTree().getSelected( key ); if( selected != null ) station.setFrontDockable( selected );
/** * Writes the contents of this node into <code>tree</code>. * @param tree the tree to write into * @return the key of the node */ public SplitDockTree<D>.Key put( SplitDockTree<D> tree ){ if( dockables != null || childA == null || childB == null ){ return tree.put( dockables, selected, placeholders, placeholderMap, -1 ); } else if( horizontal ){ return tree.horizontal( childA.put( tree ), childB.put( tree ), divider, placeholders, placeholderMap, -1 ); } else{ return tree.vertical( childA.put( tree ), childB.put( tree ), divider, placeholders, placeholderMap, -1 ); } }
for( Dockable dockable : tree.getDockables() ) { DockUtilities.ensureTreeValidity(this, dockable); SplitDockTree<Dockable>.Key rootKey = tree.getRoot(); if( rootKey != null ) { Map<Leaf, Dockable> linksToSet = new HashMap<Leaf, Dockable>();
/** * Adds two elements horizontally. * @param left the left element * @param right the right element * @param divider how much space the first element gets in respect * to the second element. Must be between 0 and 1. * @param nodeId a unique identifier for this node, may be -1 * @return a key of the combination of the two elements */ public Key horizontal( Key left, Key right, double divider, long nodeId ){ return horizontal( left, right, divider, null, null, nodeId ); }
@Override public void evolve( SplitDockTree<Dockable>.Key key, boolean checkValidity, Map<Leaf, Dockable> linksToSet ){ setPlaceholders( key.getTree().getPlaceholders( key ) ); setPlaceholderMap( key.getTree().getPlaceholderMap( key ) ); }
/** * Transforms a node of a {@link SplitDockStationLayout} into a key * of a {@link SplitDockTree}. * @param node the element to transform * @param tree the tree into which to add new keys * @param children the set of known children * @return the key or <code>null</code> */ private <D> SplitDockTree<D>.Key handleNode( SplitDockStationLayout.Node node, SplitDockTree<D> tree,Map<Integer, D> children ){ SplitDockTree<D>.Key a = handleEntry( node.getChildA(), tree, children ); SplitDockTree<D>.Key b = handleEntry( node.getChildB(), tree, children ); if( a == null ) return b; if( b == null ) return a; switch( node.getOrientation() ){ case HORIZONTAL: return tree.horizontal( a, b, node.getDivider(), node.getPlaceholders(), node.getPlaceholderMap(), node.getNodeId() ); case VERTICAL: return tree.vertical( a, b, node.getDivider(), node.getPlaceholders(), node.getPlaceholderMap(), node.getNodeId() ); } return null; }
/** * Creates an array around <code>dockable</code>. * @param dockable the element that should be put into an array * @return the array of length 1 */ public D[] array( D dockable ){ D[] array = array( 1 ); array[0] = dockable; return array; }
@Override public void evolve( SplitDockTree<Dockable>.Key key, boolean checkValidity, Map<Leaf, Dockable> linksToSet ){ setPlaceholders( key.getTree().getPlaceholders( key ) ); }
if( tree.isDockable( key )){ PerspectiveDockable[] dockables = tree.getDockables( key ); PerspectiveDockable dockable = null; dockable = combine( dockables, tree.getSelected( key ) ); return new Leaf( dockable, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() ); if( tree.isNode( key )){ Entry childA = convert( tree.getLeft( key )); Entry childB = convert( tree.getRight( key )); Orientation orientation; if( tree.isHorizontal( key )){ orientation = Orientation.HORIZONTAL; return new Node( orientation, tree.getDivider( key ), childA, childB, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
/** * Adds two elements vertically. * @param top the top element * @param bottom the bottom element * @param divider how much space the first element gets in respect * to the second element. Must be between 0 and 1. * @return a key of the combination of the two elements */ public Key vertical( D top, D bottom, double divider ){ return vertical( put( array( top ) ), put( array( bottom ) ), divider ); }
/** * Creates a key for the leaf <code>dockable</code>. * @param dockable the element for which a key is requested * @param nodeId the unique identifier for this node, can be -1 * @return the new key */ public Key put( D dockable, long nodeId ){ D[] array = array( 1 ); array[0] = dockable; return put( array, null, nodeId ); }
/** * Writes the contents of this node into <code>tree</code>. * @param tree the tree to write into * @return the key of the node */ public SplitDockTree<D>.Key put( SplitDockTree<D> tree ){ if( dockables != null || childA == null || childB == null ){ return tree.put( dockables, selected, placeholders, placeholderMap, -1 ); } else if( horizontal ){ return tree.horizontal( childA.put( tree ), childB.put( tree ), divider, placeholders, placeholderMap, -1 ); } else{ return tree.vertical( childA.put( tree ), childB.put( tree ), divider, placeholders, placeholderMap, -1 ); } }
for( Dockable dockable : tree.getDockables() ) { DockUtilities.ensureTreeValidity(this, dockable); SplitDockTree<Dockable>.Key rootKey = tree.getRoot(); if( rootKey != null ) { Map<Leaf, Dockable> linksToSet = new HashMap<Leaf, Dockable>();
/** * Adds two elements horizontally. * @param left the left element * @param right the right element * @return a key of the combination of the two elements */ public Key horizontal( Key left, Key right ){ return horizontal( left, right, 0.5 ); }