@Override public Dimension getPreferredSize(){ return getBasePane().getPreferredSize(); }
@Override protected void paintOverlay( Graphics g ){ final Graphics2D g2D = (Graphics2D) g; paintRemoval( g ); if( dropInfo != null ) { Insets insets = dockablePane.getInsets(); insets = new Insets( 0, 0, 0, 0 ); insets = subtractComponent( dockablePane, insets ); width = getWidth() - x - insets.right; height = getHeight() - insets.top - insets.bottom; height = getHeight() - y - insets.top; width = getWidth() - insets.left - insets.right; Rectangle stationBounds = new Rectangle( 0, 0, getWidth(), getHeight() ); paint.drawInsertion( g2D, stationBounds, new Rectangle( x, y, width, height ) );
mainPanel.getDockablePane().remove( handle.getDisplayer().getComponent() ); mainPanel.doLayout(); mainPanel.revalidate(); mainPanel.repaint(); handle.destroy(); listeners.fireDockableRemoved( dockable );
mainPanel.getDockablePane().remove( handle.getDisplayer().getComponent() ); mainPanel.doLayout(); mainPanel.getContentPane().revalidate(); mainPanel.getContentPane().repaint(); handle.destroy(); listeners.fireDockableRemoved( dockable );
@Override public StationDropOperation prepareDrop( StationDropItem item ){ // System.out.println(this.toString() + "## prepareDrop(...) ##"); final DockController controller = getController(); if( getExpandedState() == ExpandedState.EXPANDED ) { return null; } Dockable dockable = item.getDockable(); // check if the dockable and the station accept each other if( this.accept( dockable ) && dockable.accept( this ) ) { // check if controller exist and if the controller accept that // the dockable become a child of this station if( controller != null ) { if( !controller.getAcceptance().accept( this, dockable ) ) { return null; } } Point mouse = new Point( item.getMouseX(), item.getMouseY() ); SwingUtilities.convertPointFromScreen( mouse, mainPanel.getDockablePane() ); int index = layoutManager.getInsertionIndex( mouse.x, mouse.y ); DropInfo info = new DropInfo( dockable, index ); if( info.hasNoEffect() ) { return null; } return info; } else { return null; } }
/** * Replaces <code>displayer</code> with a new {@link DockableDisplayer}. * * @param displayer * the displayer to replace * @throws IllegalArgumentException * if <code>displayer</code> is not a child of this station */ @Override protected void discard( DockableDisplayer displayer ){ final Dockable dockable = displayer.getDockable(); final int index = indexOf( dockable ); if( index < 0 ) { throw new IllegalArgumentException( "displayer is not a child of this station: " + displayer ); } final StationChildHandle handle = dockables.dockables().get( index ); mainPanel.getDockablePane().remove( handle.getDisplayer().getComponent() ); handle.updateDisplayer(); insertAt( handle, index ); }
@Override public Dimension getMaximumSize(){ return getPreferredSize(); }
@Override public Dimension getMinimumSize(){ return getPreferredSize(); }
@Override public void draw(){ dropInfo = this; layoutManager.setSpanSize( getItem() ); layoutManager.setExpandedSpan( getIndex(), true ); mainPanel.repaint(); } }
/** * Called by the constructor, this method creates the main component of this station. * @return the main component, must not be <code>null</code> */ protected OverpaintablePanelBase createMainPanel(){ return new OverpaintablePanelBase(); }
@Override public void destroy( StationDropOperation next ){ if( dropInfo == this ) { dropInfo = null; } if( next == null || next.getTarget() != getTarget() ) { layoutManager.setExpandedSpan( -1, true ); } mainPanel.repaint(); }
protected void insertAt( StationChildHandle handle, int index ){ final Dockable dockable = handle.getDockable(); dockable.setDockParent( this ); mainPanel.getDockablePane().add( handle.getDisplayer().getComponent(), index ); mainPanel.getDockablePane().invalidate(); mainPanel.revalidate(); mainPanel.getContentPane().repaint(); }
private Insets subtractComponent( JComponent component, Insets insets ){ Point topLeft = new Point( 0, 0 ); topLeft = SwingUtilities.convertPoint( component, topLeft, this ); insets.left += topLeft.x; insets.top += topLeft.y; insets.right += (getWidth() - component.getWidth()) - topLeft.x; insets.bottom += (getHeight() - component.getHeight()) - topLeft.y; return insets; }