private Entry convert( SplitDockPerspective.Entry entry, Map<PerspectiveDockable, Integer> children ){ if( entry == null ){ return null; } if( entry.asNode() != null ){ SplitDockPerspective.Node node = entry.asNode(); Entry childA = convert( node.getChildA(), children ); Entry childB = convert( node.getChildB(), children ); if( childA == null ){ return childB; } if( childB == null ){ return childA; } return new SplitDockStationLayout.Node( node.getOrientation(), node.getDivider(), childA, childB, toArray( node.getPlaceholders() ), node.getPlaceholderMap(), node.getNodeId() ); } else if( entry.asLeaf() != null ){ SplitDockPerspective.Leaf leaf = entry.asLeaf(); Integer id = children.get( leaf.getDockable() ); return new SplitDockStationLayout.Leaf( id == null ? -1 : id.intValue(), toArray( leaf.getPlaceholders() ), leaf.getPlaceholderMap(), leaf.getNodeId() ); } else{ return convert( ((Root)entry).getChild(), children ); } }
if( childA != null && isAnchestor( childA )){ throw new IllegalArgumentException( "cannot build a cycle" ); SplitDockPerspective perspective = getPerspective();
root.setChild( new SplitDockPerspective.Node( Orientation.HORIZONTAL, 0.5, leaf, root.getChild(), null, null, -1 ) );
root.setChild( new SplitDockPerspective.Node( Orientation.HORIZONTAL, 0.5, leaf, root.getChild(), null, null, -1 ) );
Node parentNode = (Node)parent; Entry other; if( parentNode.getChildA() == this ){ other = parentNode.getChildB(); parentNode.setChildA( null ); other = parentNode.getChildA(); parentNode.setChildB( null ); parent = parentNode.getParent(); if( parent == null ){ return; parentNode.setChildA( null ); parentNode.setChildB( null ); if( nextParent.getChildA() == parentNode ){ nextParent.setChildA( other ); nextParent.setChildB( other );
double size; if( parent.getChildA() == nodeChild ){ size = parent.getDivider(); if( parent.getOrientation() == Orientation.HORIZONTAL ){ location = Location.LEFT; size = 1.0 - parent.getDivider(); if( parent.getOrientation() == Orientation.HORIZONTAL ){ location = Location.RIGHT; path.insert( location, size, 0, parent.getNodeId() ); parent = parent.getParent().asNode();
return new Node( orientation, tree.getDivider( key ), childA, childB, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
return new Node( orientation, tree.getDivider( key ), childA, childB, toSet( tree.getPlaceholders( key ) ), tree.getPlaceholderMap( key ), key.getNodeId() );
double size; if( parent.getChildA() == nodeChild ){ size = parent.getDivider(); if( parent.getOrientation() == Orientation.HORIZONTAL ){ location = Location.LEFT; size = 1.0 - parent.getDivider(); if( parent.getOrientation() == Orientation.HORIZONTAL ){ location = Location.RIGHT; path.insert( location, size, 0, parent.getNodeId() ); parent = parent.getParent().asNode();
Node parentNode = (Node)parent; Entry other; if( parentNode.getChildA() == this ){ other = parentNode.getChildB(); parentNode.setChildA( null ); other = parentNode.getChildA(); parentNode.setChildB( null ); parent = parentNode.getParent(); if( parent == null ){ return; parentNode.setChildA( null ); parentNode.setChildB( null ); if( nextParent.getChildA() == parentNode ){ nextParent.setChildA( other ); nextParent.setChildB( other );
if( childA != null && isAnchestor( childA )){ throw new IllegalArgumentException( "cannot build a cycle" ); SplitDockPerspective perspective = getPerspective();
if( childB != null && isAnchestor( childB )){ throw new IllegalArgumentException( "cannot build a cycle" ); SplitDockPerspective perspective = getPerspective();
if( childB != null && isAnchestor( childB )){ throw new IllegalArgumentException( "cannot build a cycle" ); SplitDockPerspective perspective = getPerspective();
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
private void handle( Entry entry, double x, double y, double width, double height ){ if( entry != null ){ if( entry.asLeaf() != null ) { PerspectiveDockable dockable = entry.asLeaf().getDockable(); if( dockable != null ) { grid.addDockable( x, y, width, height, dockable ); } } else{ Node node = entry.asNode(); double divider = node.getDivider(); if( node.getOrientation() == Orientation.HORIZONTAL ){ handle( node.getChildA(), x, y, width*divider, height ); handle( node.getChildB(), x+width*divider, y, width*(1-divider), height ); } else{ handle( node.getChildA(), x, y, width, height*divider ); handle( node.getChildB(), x, y+height*divider, width, height*(1-divider) ); } } } }
private void handle( Entry entry, double x, double y, double width, double height ){ if( entry != null ){ if( entry.asLeaf() != null ) { PerspectiveDockable dockable = entry.asLeaf().getDockable(); if( dockable != null ) { grid.addDockable( x, y, width, height, dockable ); } } else{ Node node = entry.asNode(); double divider = node.getDivider(); if( node.getOrientation() == Orientation.HORIZONTAL ){ handle( node.getChildA(), x, y, width*divider, height ); handle( node.getChildB(), x+width*divider, y, width*(1-divider), height ); } else{ handle( node.getChildA(), x, y, width, height*divider ); handle( node.getChildB(), x, y+height*divider, width, height*(1-divider) ); } } } }
/** * Replaces <code>this</code> with <code>next</code>. * @param next the element which replaces this */ public void replace( Entry next ){ Entry parent = getParent(); if( parent == null ){ return; } if( parent instanceof Root ){ ((Root)parent).setChild( next ); } else{ Node parentNode = (Node)parent; if( parentNode.getChildA() == this ){ parentNode.setChildA( next ); } else{ parentNode.setChildB( next ); } } }
/** * Creates a new node. * @param orientation whether this node is horizontal or vertical * @param divider the location of the divider * @param childA the left or top child * @param childB the right or bottom child * @param placeholders placeholders associated with this node * @param placeholderMap placeholder information of a child {@link DockStation} * @param id the unique identifier of this node or -1 */ public Node( Orientation orientation, double divider, Entry childA, Entry childB, Set<Path> placeholders, PlaceholderMap placeholderMap, long id ){ super( placeholders, placeholderMap, id ); this.orientation = orientation; this.divider = divider; setChildA( childA ); setChildB( childB ); }
/** * Creates a new node. * @param orientation whether this node is horizontal or vertical * @param divider the location of the divider * @param childA the left or top child * @param childB the right or bottom child * @param placeholders placeholders associated with this node * @param placeholderMap placeholder information of a child {@link DockStation} * @param id the unique identifier of this node or -1 */ public Node( Orientation orientation, double divider, Entry childA, Entry childB, Set<Path> placeholders, PlaceholderMap placeholderMap, long id ){ super( placeholders, placeholderMap, id ); this.orientation = orientation; this.divider = divider; setChildA( childA ); setChildB( childB ); }
private void remove( Entry child ){ if( child != null ){ if( child.asLeaf() != null ){ PerspectiveDockable dockable = child.asLeaf().getDockable(); if( dockable != null ){ children.remove( dockable ); dockable.setParent( null ); } } else{ remove( child.asNode().getChildA() ); remove( child.asNode().getChildB() ); } } } });