/** * Gets the station this node belongs to. * @return the station */ public SplitDockStation getStation(){ return access.getOwner(); }
public DockStation getTarget(){ return access.getOwner(); }
public DockStation getParent(){ return access.getOwner(); }
public DockStation getTarget(){ return access.getOwner(); }
/** * Changes the orientation of this node. * @param orientation the new orientation */ public void setOrientation( Orientation orientation ) { if( orientation == null ) throw new NullPointerException( "orientation must not be null" ); this.orientation = orientation; getAccess().getOwner().revalidate(); }
private Dimension getSize( Dimension left, Dimension right ){ if( left != null && right != null ){ int divider = getAccess().getOwner().getDividerSize(); if( orientation == Orientation.HORIZONTAL ){ return new Dimension( left.width + divider + right.width, Math.max( left.height, right.height )); } else{ return new Dimension( Math.max( left.width, right.width ), left.height + divider + right.height ); } } else if( left != null ){ return left; } else if( right != null ){ return right; } else{ return new Dimension(); } }
/** * Tells whether the position of the mouse <code>x/y</code> would result in a drag and drop operation where * {@link Put#CENTER} is appropriate. * @param bounds the boundaries of the {@link Dockable}, this {@link Leaf} or any other representation of * the {@link Dockable} * @param x the x-coordinate of the mouse * @param y the y-coordinate of the mouse * @return whether the location of the mouse would allow a combination of the {@link Dockable}s */ protected boolean isCenterPut( Rectangle bounds, int x, int y ){ float sideSnapSize = getAccess().getOwner().getSideSnapSize(); return x > bounds.x + sideSnapSize*bounds.width && x < bounds.x + bounds.width - sideSnapSize*bounds.width && y > bounds.y + sideSnapSize*bounds.height && y < bounds.y + bounds.height - sideSnapSize*bounds.height; }
@Override public boolean isInOverrideZone( int x, int y, double factorW, double factorH ){ float sideSnapSize = getAccess().getOwner().getSideSnapSize(); Rectangle bounds = getBounds(); if( x > bounds.x + sideSnapSize*bounds.width && x < bounds.x + bounds.width - sideSnapSize*bounds.width && y > bounds.y + sideSnapSize*bounds.height && y < bounds.y + bounds.height - sideSnapSize*bounds.height ){ return false; } return true; }
/** * Gets the location and size of the area which can be occupied by the children. * @return the boundaries of the base {@link Component} * @see #setBaseBounds(Rectangle) */ public Rectangle getBaseBounds(){ if( baseBounds != null ){ return baseBounds; } JComponent base = getAccess().getOwner().getBasePane(); Insets insets = base.getInsets(); int x = 0; int y = 0; int width = base.getWidth(); int height = base.getHeight(); if( insets != null ){ x = insets.left; y = insets.top; width -= insets.left + insets.right; height -= insets.top + insets.bottom; } return new Rectangle( x, y, width, height ); }
/** * Ensures that <code>node</code> is associated with the placeholder for <code>dockable</code>. * @param node the owner of <code>dockable</code>, can be <code>null</code> to indicate * that noone must use the placeholder of <code>dockable</code> * @param dockable the item whose placeholder is updated * @param protectedNodes nodes that will not be removed even if they are no longer {@link SplitNode#isOfUse() useful} */ public void set( SplitNode node, Dockable dockable, SplitNode... protectedNodes ){ PlaceholderStrategy strategy = access.getOwner().getPlaceholderStrategy(); if( strategy != null ){ Path placeholder = strategy.getPlaceholderFor( dockable ); if( placeholder != null ){ set( node, placeholder, protectedNodes ); } } }
/** * Ensures that <code>node</code> is associated with the placeholder for <code>dockable</code>. * @param node the owner of <code>dockable</code>, can be <code>null</code> to indicate * that no-one must use the placeholder of <code>dockable</code> * @param dockable the item whose placeholder is updated * @param protectedNodes nodes that will not be removed even if they are no longer {@link SplitNode#isOfUse() useful} */ public void set( SplitNode node, Dockable dockable, SplitNode... protectedNodes ){ PlaceholderStrategy strategy = access.getOwner().getPlaceholderStrategy(); if( strategy != null ){ Path placeholder = strategy.getPlaceholderFor( dockable ); if( placeholder != null ){ set( node, placeholder, protectedNodes ); } } }
@Override public void updateBounds( double x, double y, double width, double height, double factorW, double factorH, boolean updateComponentBounds ){ super.updateBounds( x, y, width, height, factorW, factorH, updateComponentBounds ); getAccess().getOwner().revalidate(); currentBounds = getBounds(); }
public void destroy( StationDropOperation next ){ if( access.getOwner().getDropInfo() == putInfo ){ access.setDropInfo( null ); if( next == null || !(next instanceof SplitDropOperation) || next.getTarget() != getTarget() ){ access.unsetDropInfo(); } } }
public void destroy( StationDropOperation next ){ if( access.getOwner().getDropInfo() == putInfo ){ access.setDropInfo( null ); if( next == null || !(next instanceof SplitDropOperation) || next.getTarget() != getTarget() ){ access.unsetDropInfo(); } } }
/** * Sets information about the placeholders of a {@link DockStation} that was * child of this node. * @param placeholderMap the placeholder information, can be <code>null</code> */ public void setPlaceholderMap( PlaceholderMap placeholderMap ){ if( this.placeholderMap != null ){ this.placeholderMap.setPlaceholderStrategy( null ); } this.placeholderMap = placeholderMap; if( this.placeholderMap != null ){ this.placeholderMap.setPlaceholderStrategy( getAccess().getOwner().getPlaceholderStrategy() ); getAccess().getPlaceholderSet().removeDoublePlaceholders( this, placeholderMap ); } }
/** * Sets the right child of this node. The area of this child * will be in the right or the bottom half of the area of this * node.<br> * Note that setting the child to <code>null</code> does not delete * the child from the system, only a call to {@link SplitNode#delete(boolean)} * does that. * @param right the right child */ public void setRight( SplitNode right ){ if( this.right != null ) this.right.setParent( null ); this.right = right; clearVisibility(); if( right != null ){ right.setParent( this ); } treeChanged(); if( right != null ){ ensureIdUniqueAsync(); } getAccess().getOwner().revalidate(); getAccess().getOwner().repaint(); getAccess().repositioned( this ); }
/** * Sets the left child of this node. The area of this child * will be in the left or the upper half of the area of this node.<br> * Note that setting the child to <code>null</code> does not delete * the child from the system, only a call to {@link SplitNode#delete(boolean)} * does that. * @param left the left child or <code>null</code> */ public void setLeft( SplitNode left ){ if( this.left != null ) this.left.setParent( null ); this.left = left; clearVisibility(); if( left != null ){ left.setParent( this ); } treeChanged(); if( left != null ){ ensureIdUniqueAsync(); } getAccess().getOwner().revalidate(); getAccess().getOwner().repaint(); getAccess().repositioned( this ); }
/** * Creates a leaf for <code>dockable</code>. This method only * creates the leaf, but does not connect leaf and <code>dockable</code>. * @param dockable the element to put into a leaf * @param id the unique identifier of the new leaf, can be -1 * @return the new leaf or <code>null</code> if the leaf would not be valid */ protected Leaf create( Dockable dockable, long id ){ SplitDockStation split = access.getOwner(); DockController controller = split.getController(); DockAcceptance acceptance = controller == null ? null : controller.getAcceptance(); if( !dockable.accept( split ) || !split.accept( dockable )) return null; if( acceptance != null ){ if( !acceptance.accept( split, dockable )) return null; } Leaf leaf = createLeaf( id ); return leaf; }
private boolean replace( Path placeholder, Dockable dockable ){ // replace this placeholder with a leaf Leaf leaf = create( dockable, getId() ); if( leaf == null ) return false; ensureOnlyOnThisNode( placeholder ); ensureOnlyOnThisNode( getAccess().getOwner().getPlaceholderStrategy().getPlaceholderFor( dockable ) ); leaf.setPlaceholders( getPlaceholders() ); replace( leaf ); leaf.setPlaceholderMap( getPlaceholderMap() ); leaf.setDockable( dockable, null ); return true; }