@Override protected SplitNode getRootChild( SplitNode root ){ return ((Root)root).getChild(); }
public void updateBounds( Root root, double x, double y, double factorW, double factorH ) { root.updateBounds( x, y, 1, 1, factorW, factorH, true ); } }
public double getDividerAt( int x, int y ){ Root root = getRoot(); if( orientation == Orientation.HORIZONTAL ){ double mx = x / root.getWidthFactor(); return (mx - this.x) / width; } else{ double my = y / root.getHeightFactor(); return (my - this.y) / height; } }
/** * Tells whether the location x/y is in the override zone. * @param x the x-coordinate of the mouse * @param y the y-coordinate of the mouse * @return <code>true</code> if this station should have priority * over all other stations when the mouse is in x/y. */ public boolean isInOverrideZone( int x, int y ){ double factorW = getWidthFactor(); double factorH = getHeightFactor(); return isInOverrideZone( x, y, factorW, factorH ); }
/** * Gets the preferred operation when dragging the {@link Dockable} * <code>drop</code> to the location <code>x/y</code>. * @param x the x-coordinate of the mouse * @param y the y-coordinate of the mouse * @param drop the Dockable which will be dropped * @return where to trop the Dockable or <code>null</code> */ public PutInfo getPut( int x, int y, Dockable drop ){ double factorW = getWidthFactor(); double factorH = getHeightFactor(); return getPut( x, y, factorW, factorH, drop ); }
/** * Tells whether the current operation is a resize operation. The locked sizes will only be respected if * the operation is a resize operation. * @param root the item that is going to be updated * @return whether a resize operation is in progress */ protected boolean isResize( Root root ){ Rectangle current = root.getCurrentBounds(); Rectangle bounds = root.getBounds(); return !current.equals( bounds ); }
private void reset(){ station.getRoot().visit( new SplitNodeVisitor(){ public void handleRoot( Root root ){ root.createSpans(); } public void handlePlaceholder( Placeholder placeholder ){ // ignore } public void handleNode( Node node ){ // ignore } public void handleLeaf( Leaf leaf ){ leaf.createSpans(); } } ); }
/** * Gets the size and location of this node in pixel where the point * 0/0 is equal to the point 0/0 on the owner-station. This method calculates * these values anew, clients interested in the current bounds should * use {@link VisibleSplitNode#getCurrentBounds()}. * @return the size and location */ public Rectangle getBounds(){ Root root = getRoot(); double fw = root.getWidthFactor(); double fh = root.getHeightFactor(); Rectangle rec = new Rectangle( (int)(x * fw + 0.5), (int)(y * fh + 0.5), (int)(width * fw + 0.5), (int)(height * fh + 0.5 )); Rectangle base = root.getBaseBounds(); rec.x = Math.min( base.width, Math.max( base.x, rec.x )); rec.y = Math.min( base.height, Math.max( base.y, rec.y )); rec.width = Math.min( base.width - rec.x + base.x, Math.max( 0, rec.width )); rec.height = Math.min( base.height - rec.y + base.y, Math.max( 0, rec.height )); return rec; }
if( location instanceof SplitDockPlaceholderProperty ){ SplitDockPlaceholderProperty property = (SplitDockPlaceholderProperty)location; SplitNode node = root().getPlaceholderNode( property.getPlaceholder() ); if( node != null ){ node.aside( request ); Dockable fullscreen = getFullScreen(); if( fullscreen != null ){ Leaf leaf = getRoot().getLeaf( fullscreen ); if( request.getPlaceholder() != null ){ leaf.addPlaceholder( request.getPlaceholder() );
@Override public void updateBounds( Root root, double x, double y, double factorW, double factorH ) { Rectangle current = root.getCurrentBounds(); Rectangle bounds = root.getBounds(); boolean resize = isResize( root ); if( resize ){ resize = current.width > 10 && current.height > 10 && bounds.width > 10 && bounds.height > 10; } if( resize ){ try{ root.setBaseBounds( current ); super.updateBounds( root, x, y, factorW, factorH ); } finally{ root.setBaseBounds( null ); } updateBoundsLocked( root, x, y, factorW, factorH ); } else{ super.updateBounds( root, x, y, factorW, factorH ); } }
/** * Gets the space that a divider needs in the width. * @return the width of a divider */ public double getDividerWidth(){ return node.getStation().getDividerSize() / node.getRoot().getWidthFactor(); }
/** * Gets the space that a divider needs in the height. * @return the height of a divider */ public double getDividerHeight(){ return node.getStation().getDividerSize() / node.getRoot().getHeightFactor(); }
@Override public boolean isInOverrideZone( int x, int y, double factorW, double factorH ) { if( !getBounds().contains( x, y )) return false; if( child != null ) return child.isInOverrideZone( x, y, factorW, factorH ); else return false; }
/** * Ensures that the dropped {@link Dockable} does not come to rest at a location that would destroy the columns. */ @Override public boolean drop( Dockable dockable, SplitDockPlaceholderProperty property ){ SplitNode node = getRoot().getPlaceholderNode( property.getPlaceholder() ); if( node != null && !(node instanceof Leaf) && !(node instanceof Root)){ if( node instanceof Placeholder || ((Node)node).getOrientation() == side.getHeaderOrientation() ){ pushIntoHeader( node ); } } return super.drop( dockable, property ); }
public Root createRoot( SplitDockAccess access, long id ){ return new Root( access, id ); } }
public void handleRoot( Root root ){ root.createSpans(); }
if( rootKey != null ) { Map<Leaf, Dockable> linksToSet = new HashMap<Leaf, Dockable>(); root().evolve(rootKey, checkValidity, linksToSet); for( Map.Entry<Leaf, Dockable> entry : linksToSet.entrySet() ) { entry.getKey().setDockable( entry.getValue(), null );
private void reset(){ station.getRoot().visit( new SplitNodeVisitor(){ public void handleRoot( Root root ){ root.createSpans(); } public void handlePlaceholder( Placeholder placeholder ){ // ignore } public void handleNode( Node node ){ // ignore } public void handleLeaf( Leaf leaf ){ leaf.createSpans(); } } ); }