@Override public void setDimension(Dimension dim) { for (ResizableIcon icon : iconDeck.values()) { int currH = icon.getIconHeight(); int currW = icon.getIconWidth(); if ((currH != dim.height) || (currW != dim.width)) icon.setDimension(dim); } }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { this.delegate.paintIcon(c, g, x, y); for (IconDecorator decorator : this.decorators) { decorator.paintIconDecoration(c, g, x, y, this.delegate .getIconWidth(), this.delegate.getIconHeight()); } }
/** * Paints the icon of the popup area. * * @param g * Graphics context. * @param popupActionRect */ protected void paintPopupActionIcon(Graphics g, Rectangle popupActionRect) { int size = Math.max(popupActionRect.width - 2, 7); if (size % 2 == 0) size--; popupActionIcon.setDimension(new Dimension(size, size)); popupActionIcon.paintIcon(this.commandButton, g, popupActionRect.x + (popupActionRect.width - size) / 2, popupActionRect.y + (popupActionRect.height - size) / 2); }
/** * Sets new icon for this button. Fires an <code>icon</code> property change * event. * * @param defaultIcon * New default icon for this button. * @see #setDisabledIcon(ResizableIcon) * @see #getIcon() */ public void setIcon(ResizableIcon defaultIcon) { ResizableIcon oldValue = this.icon; this.icon = defaultIcon; firePropertyChange("icon", oldValue, defaultIcon); if (defaultIcon != oldValue) { if (defaultIcon == null || oldValue == null || defaultIcon.getIconWidth() != oldValue.getIconWidth() || defaultIcon.getIconHeight() != oldValue.getIconHeight()) { revalidate(); } repaint(); } }
@Override public int getIconWidth() { return layers[0].getIconWidth(); }
@Override public void setDimension(Dimension newDimension) { for (ResizableIcon layer : layers) layer.setDimension(newDimension); }
protected void syncIconDimension() { ResizableIcon icon = this.commandButton.getIcon(); CommandButtonDisplayState commandButtonState = this.commandButton .getDisplayState(); this.layoutManager = commandButtonState .createLayoutManager(this.commandButton); if (icon == null) return; int maxHeight = layoutManager.getPreferredIconSize(); if (maxHeight < 0) { maxHeight = this.commandButton.getIcon().getIconHeight(); } if (commandButtonState != CommandButtonDisplayState.FIT_TO_ICON) { @SuppressWarnings("SuspiciousNameCombination") Dimension newDim = new Dimension(maxHeight, maxHeight); icon.setDimension(newDim); } }
@Override public int getIconHeight() { return this.delegate.getIconHeight(); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { for (ResizableIcon layer : layers) layer.paintIcon(c, g, x, y); } }
@Override public Point getKeyTipAnchorCenterPoint(AbstractCommandButton commandButton) { Insets ins = commandButton.getInsets(); int height = commandButton.getHeight(); ResizableIcon buttonIcon = commandButton.getIcon(); // bottom-right corner of the icon area return new Point(ins.left + buttonIcon.getIconWidth(), (height + buttonIcon.getIconHeight()) / 2); }
private static Image getImage(ResizableIcon icon, int size) { icon.setDimension(new Dimension(size, size)); if (icon instanceof AsynchronousLoading) { AsynchronousLoading async = (AsynchronousLoading) icon; icon.paintIcon(null, g2d, 0, 0); g2d.dispose(); return result;
@Override public int getIconWidth() { return this.delegate.getIconWidth(); }
@Override public void setDimension(Dimension newDimension) { delegate.setDimension(newDimension); }
@Override public int getIconHeight() { return layers[0].getIconHeight(); }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { delegate.paintIcon(c, g, x, y); }
@Override public Point getKeyTipAnchorCenterPoint(AbstractCommandButton commandButton) { Insets ins = commandButton.getInsets(); int height = commandButton.getHeight(); ResizableIcon buttonIcon = commandButton.getIcon(); if (buttonIcon != null) { // bottom-right corner of the icon area return new Point(ins.left + buttonIcon.getIconWidth(), (height + buttonIcon.getIconHeight()) / 2); } else { // bottom-left corner of the button return new Point(ins.left, 3 * height / 4); } }
protected void syncDisabledIcon() { ResizableIcon currDisabledIcon = this.commandButton.getDisabledIcon(); ResizableIcon icon = this.commandButton.getIcon(); if ((currDisabledIcon == null) || (currDisabledIcon instanceof UIResource)) { if (icon != null) { this.commandButton.setDisabledIcon(new ResizableIconUIResource( new FilteredResizableIcon(icon, new ColorConvertOp( ColorSpace.getInstance(ColorSpace.CS_GRAY), null)))); } else { this.commandButton.setDisabledIcon(null); } } else { // disabled icon coming from app code if (icon != null) { this.commandButton.getDisabledIcon() .setDimension( new Dimension(icon.getIconWidth(), icon .getIconHeight())); } } }
@Override public int getIconWidth() { return delegate.getIconWidth(); }
@Override public void setDimension(Dimension newDimension) { delegate.setDimension(newDimension); }
@Override public int getIconHeight() { return delegate.getIconHeight(); }