/* * (non-Javadoc) * * @seeorg.jvnet.flamingo.common.ui.BasicCommandButtonUI# * paintButtonVerticalSeparator(java.awt.Graphics, int) */ @Override protected void paintButtonVerticalSeparator(Graphics graphics, Rectangle separatorArea) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.translate(separatorArea.x, 0); SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.getColorScheme( this.commandButton, ColorSchemeAssociationKind.SEPARATOR, ComponentState.getState(this.commandButton.getActionModel(), this.commandButton)); float fadeAlpha = this.getSeparatorAlpha(); g2d.setComposite(AlphaComposite.SrcOver.derive(fadeAlpha)); SeparatorPainterUtils.paintSeparator( this.commandButton, g2d, colorScheme, 1, this.commandButton.getHeight(), JSlider.VERTICAL, true, 4, 4, true); g2d.dispose(); }
/* * (non-Javadoc) * * @see * org.jvnet.flamingo.common.ui.BasicCommandButtonUI#paintButtonBackground * (java.awt.Graphics, java.awt.Rectangle) */ @Override protected void paintButtonBackground(Graphics graphics, Rectangle toFill) { if (SubstanceCoreUtilities.isButtonNeverPainted(this.commandButton)) return; ButtonModel actionModel = this.commandButton.getActionModel(); PopupButtonModel popupModel = ((JCommandButton) this.commandButton).getPopupModel(); Rectangle actionArea = this.getLayoutInfo().actionClickArea; Rectangle popupArea = this.getLayoutInfo().popupClickArea; BufferedImage fullAlphaBackground = CommandButtonBackgroundDelegate.getCombinedCommandButtonBackground( this.commandButton, actionModel, actionArea, popupModel, popupArea); // Two special cases here: // 1. Button has flat appearance and doesn't show the popup // 2. Button is disabled. // For both cases, we need to set custom translucency. boolean isFlat = this.commandButton.isFlat() && !((JCommandButton) this.commandButton).getPopupModel().isPopupShowing(); boolean isSpecial = isFlat || !this.commandButton.isEnabled(); float extraAlpha = 1.0f; if (isSpecial) { if (isFlat) { float extraActionAlpha = 0.0f; for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : getActionTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) { ComponentState activeState = activeEntry.getKey(); if (activeState.isDisabled()) continue; if (activeState == ComponentState.ENABLED) continue; extraActionAlpha += activeEntry.getValue().getContribution(); } float extraPopupAlpha = 0.0f; for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : getPopupTransitionTracker().getModelStateInfo().getStateContributionMap().entrySet()) { ComponentState activeState = activeEntry.getKey(); if (activeState.isDisabled()) continue; if (activeState == ComponentState.ENABLED) continue; extraPopupAlpha += activeEntry.getValue().getContribution(); } extraAlpha = Math.max(extraActionAlpha, extraPopupAlpha); } else { ComponentState actionAreaState = ComponentState.getState(actionModel, this.commandButton); if (actionAreaState.isDisabled()) { extraAlpha = SubstanceColorSchemeUtilities.getAlpha(this.commandButton, actionAreaState); } } } // System.out.println(extraAlpha); extraAlpha = Math.min(1.0f, extraAlpha); if (extraAlpha > 0.0f) { Graphics2D g2d = (Graphics2D) graphics.create(); g2d.setComposite( LafWidgetUtilities.getAlphaComposite(this.commandButton, extraAlpha, graphics)); g2d.drawImage(fullAlphaBackground, 0, 0, null); g2d.dispose(); } }