/** Creates a new UI delegate for ribbon button. */ public SubstanceCommandButtonUI(JCommandButton button) { super(); this.backgroundDelegate = new ButtonBackgroundDelegate(); this.overallRolloverModel = new DefaultButtonModel(); this.overallRolloverModel.setArmed(false); this.overallRolloverModel.setSelected(false); this.overallRolloverModel.setPressed(false); this.overallRolloverModel.setRollover(false); this.overallRolloverModel.setEnabled(button.isEnabled()); this.overallStateTransitionTracker = new StateTransitionTracker(button, this.overallRolloverModel); this.substanceVisualStateTracker = new CommandButtonVisualStateTracker(); }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paintButtonIcon(java * .awt.Graphics, java.awt.Rectangle) */ @Override protected void paintButtonIcon(Graphics g, Rectangle iconRect) { JCommandButton jcb = (JCommandButton) this.commandButton; Icon regular = jcb.getIcon(); if (toUseDisabledIcon() && (jcb.getDisabledIcon() != null) && ((regular != null) && !regular.getClass().isAnnotationPresent(TransitionAware.class))) regular = jcb.getDisabledIcon(); if ((iconRect == null) || (regular == null) || (iconRect.width == 0) || (iconRect.height == 0)) { return; } boolean useThemed = SubstanceCoreUtilities.useThemedDefaultIcon(this.commandButton); if (regular != null) { Graphics2D g2d = (Graphics2D) g.create(); GhostPaintingUtils.paintGhostIcon(g2d, jcb, regular, iconRect); g2d.setComposite(LafWidgetUtilities.getAlphaComposite(jcb, g)); if (!useThemed) { regular.paintIcon(jcb, g2d, iconRect.x, iconRect.y); } else { StateTransitionTracker tracker = this.substanceVisualStateTracker.getActionStateTransitionTracker(); ButtonModel model = commandButton.getActionModel(); if (jcb.getCommandButtonKind() == CommandButtonKind.POPUP_ONLY) { tracker = this.substanceVisualStateTracker.getPopupStateTransitionTracker(); model = jcb.getPopupModel(); } CommandButtonBackgroundDelegate.paintThemedCommandButtonIcon( g2d, iconRect, jcb, regular, model, tracker); } g2d.dispose(); } }