@Override public Dimension getPreferredSize() { if( isPreferredSizeSet() ) return super.getPreferredSize(); Dimension size = content.getPreferredSize(); if( model.getOrientation().isHorizontal() ) return new Dimension( size.width + 6 + dropIcon.getIconWidth(), size.height+2 ); else return new Dimension( size.width+2, size.height + 6 + dropIcon.getIconHeight() ); }
@Override public Dimension getPreferredSize() { if( isPreferredSizeSet() ) return super.getPreferredSize(); Dimension size = content.getPreferredSize(); if( model.getOrientation().isHorizontal() ) return new Dimension( size.width + 6 + dropIcon.getIconWidth(), size.height+2 ); else return new Dimension( size.width+2, size.height + 6 + dropIcon.getIconHeight() ); }
@Override public Dimension getPreferredSize() { if( isPreferredSizeSet() ) return super.getPreferredSize(); Dimension contentSize = content.getPreferredSize(); if( model.getOrientation().isHorizontal() ) return new Dimension( (int)(0.5 * contentSize.height + contentSize.width + 1 + 1.5*dropIcon.getIconWidth()), (int)(1.5 * contentSize.height)); else return new Dimension( (int)(1.5 * contentSize.width), (int)(0.5 * contentSize.width + contentSize.height + 1 + 1.5 * dropIcon.getIconHeight()) ); }
/** * Shows the popup menu */ public void popupTriggered(){ BasicDropDownButtonModel model = getModel(); JComponent button = model.getOwner(); if( model.getOrientation().isHorizontal() ){ menu.show( button, 0, button.getHeight() ); } else{ menu.show( button, button.getWidth(), 0 ); } }
/** * Tells whether the location <code>x/y</code> is within the area * that will always trigger the dropdown menu. * @param x some x coordinate * @param y some y coordinate * @return <code>true</code> if the point x/y is within the dropdown-area */ public boolean inDropDownArea( int x, int y ){ if( !contains( x, y )) return false; if( model.getOrientation().isHorizontal() ){ return x >= getWidth() - dropIcon.getIconWidth() - 5; } else{ return y >= getHeight() - dropIcon.getIconHeight() - 5; } }
@Override public Dimension getPreferredSize(){ if( isPreferredSizeSet() ) return super.getPreferredSize(); Insets insets = getMaxBorderInsets(); Dimension icon = getContent().getPreferredSize(); if( getModel().getOrientation().isHorizontal() ){ int width = insets.left + 2*insets.right + icon.width; width += dropIcon.getIconWidth(); int height = dropIcon.getIconHeight(); height = Math.max( height, icon.height ); height += insets.top + insets.bottom; return new Dimension( width, height ); } else{ int height = insets.top + 2*insets.bottom + icon.height; height += dropIcon.getIconHeight(); int width = dropIcon.getIconWidth(); width = Math.max( width, icon.width ); width += insets.left + insets.right; return new Dimension( width, height ); } }
/** * Tells whether the location <code>x/y</code> is within the area * that will always trigger the dropdown menu. * @param x some x coordinate * @param y some y coordinate * @return <code>true</code> if the point x/y is within the dropdown-area */ public boolean inDropDownArea( int x, int y ){ if( !contains( x, y )) return false; if( model.getOrientation().isHorizontal() ){ return x >= getWidth() - dropIcon.getIconWidth() - 5; } else{ return y >= getHeight() - dropIcon.getIconHeight() - 5; } }
@Override public Dimension getPreferredSize(){ if( isPreferredSizeSet() ) return super.getPreferredSize(); Insets insets = getMaxBorderInsets(); Dimension icon = getContent().getPreferredSize(); if( getModel().getOrientation().isHorizontal() ){ int width = insets.left + 2*insets.right + icon.width; width += dropIcon.getIconWidth(); int height = dropIcon.getIconHeight(); height = Math.max( height, icon.height ); height += insets.top + insets.bottom; return new Dimension( width, height ); } else{ int height = insets.top + 2*insets.bottom + icon.height; height += dropIcon.getIconHeight(); int width = dropIcon.getIconWidth(); width = Math.max( width, icon.width ); width += insets.left + insets.right; return new Dimension( width, height ); } }
/** * Tells whether the point x,y is over the icon that represents the drop-area. * @param x the x-coordinate * @param y the y-coordinate * @return <code>true</code> if pressing the mouse at that location would * open a popup menu */ public boolean overDropIcon( int x, int y ){ if( !contains( x, y )) return false; int rx = 0; int ry = 0; int rw = getWidth(); int rh = getHeight(); int dropIconWidth = dropIcon == null ? 0 : dropIcon.getIconWidth(); int dropIconHeight = dropIcon == null ? 0 : dropIcon.getIconHeight(); if( model.getOrientation().isHorizontal() ){ // int mx = rx + (int)( 0.5 * 1.25 * iconWidth + 0.5 * (rw - 1.25 * dropIconWidth) ); int mx = rx + rw - (int)(1.5 * dropIconWidth) - 1; return x >= mx; } else{ // int my = ry + (int)( 0.5 * 1.25 * iconHeight + 0.5 * (rh - 1.25 * dropIconHeight) ); int my = ry + rh - (int)(1.5 * dropIconHeight) - 1; return y >= my; } }
@Override public void doLayout(){ if( model.getOrientation().isHorizontal() ){ content.setBounds( 1, 1, getWidth()-5-dropIcon.getIconWidth(), getHeight()-2 ); } else{ content.setBounds( 1, 1, getWidth()-2, getHeight()-5-dropIcon.getIconHeight() ); } }
@Override public void doLayout(){ if( model.getOrientation().isHorizontal() ){ content.setBounds( 1, 1, getWidth()-5-dropIcon.getIconWidth(), getHeight()-2 ); } else{ content.setBounds( 1, 1, getWidth()-2, getHeight()-5-dropIcon.getIconHeight() ); } }
private void doPaintBackground( Graphics g ){ Graphics2D g2 = (Graphics2D)g; int x = 0; int y = 0; int w = getWidth(); int h = getHeight(); if( model.getOrientation().isHorizontal() ){ g2.setColor( animation.getColor( "background" ) ); g2.fillRoundRect( x, y, w, h, h, h ); } else{ g2.setColor( animation.getColor( "background" ) ); g2.fillRoundRect( x, y, w, h, w, w ); } }
@Override public void doLayout(){ MiniButtonContent content = getContent(); Insets insets = getMaxBorderInsets(); if( getModel().getOrientation().isHorizontal() ){ int dropWidth = dropIcon.getIconWidth(); content.setBounds( insets.left+1, insets.top, getWidth()-insets.left-2*insets.right-1-dropWidth, getHeight()-insets.top-insets.bottom ); } else{ int dropHeight = dropIcon.getIconHeight(); content.setBounds( insets.left, insets.top+1, getWidth()-insets.left-insets.right, getHeight()-insets.top-2*insets.bottom-1-dropHeight ); } }
@Override public void doLayout(){ if( model.getOrientation().isHorizontal() ){ content.setBounds( getHeight() / 3, getHeight() / 6, (int)(getWidth() - 1 - 1.5*dropIcon.getIconWidth()), (int)(getHeight() / 1.5)); } else{ content.setBounds( getWidth() / 3, getWidth() / 6, (int)(getWidth() / 1.5), (int)(getHeight() - 1 - 1.5*dropIcon.getIconHeight())); } }
@Override public void doLayout(){ MiniButtonContent content = getContent(); Insets insets = getMaxBorderInsets(); if( getModel().getOrientation().isHorizontal() ){ int dropWidth = dropIcon.getIconWidth(); content.setBounds( insets.left+1, insets.top, getWidth()-insets.left-2*insets.right-1-dropWidth, getHeight()-insets.top-insets.bottom ); } else{ int dropHeight = dropIcon.getIconHeight(); content.setBounds( insets.left, insets.top+1, getWidth()-insets.left-insets.right, getHeight()-insets.top-2*insets.bottom-1-dropHeight ); } }
@Override public boolean contains( int x, int y ){ if( !super.contains( x, y )) return false; int w = getWidth(); int h = getHeight(); RoundRectangle2D rect; if( model.getOrientation().isHorizontal() ) rect = new RoundRectangle2D.Double( 0, 0, w, h, h, h ); else rect = new RoundRectangle2D.Double( 0, 0, w, h, w, w ); return rect.contains( x, y ); }
if( getModel().getOrientation().isHorizontal() ){ int iconWidth = getContent().getWidth(); int dropWidth = dropIcon.getIconWidth();
if( getModel().getOrientation().isHorizontal() ){ int iconWidth = getContent().getWidth(); int dropWidth = dropIcon.getIconWidth();
Insets insets = getMaxBorderInsets(); if( getModel().getOrientation().isHorizontal() ){ int iconWidth = getContent().getWidth(); int dropWidth = dropIcon.getIconWidth();
Insets insets = getMaxBorderInsets(); if( getModel().getOrientation().isHorizontal() ){ int iconWidth = getContent().getWidth(); int dropWidth = dropIcon.getIconWidth();