Java Code Examples for org.pushingpixels.substance.internal.animation.StateTransitionTracker#getFacetStrength()
The following examples show how to use
org.pushingpixels.substance.internal.animation.StateTransitionTracker#getFacetStrength() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubstanceTextUtilities.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static Color getTextBackgroundFillColor(JComponent comp) { Color backgroundFillColor = SubstanceColorUtilities.getBackgroundFillColor(comp); JTextComponent componentForTransitions = SubstanceCoreUtilities .getTextComponentForTransitions(comp); if (componentForTransitions != null) { ComponentUI ui = componentForTransitions.getUI(); if (ui instanceof TransitionAwareUI) { TransitionAwareUI trackable = (TransitionAwareUI) ui; StateTransitionTracker stateTransitionTracker = trackable.getTransitionTracker(); Color lighterFill = SubstanceColorUtilities.getLighterColor(backgroundFillColor, 0.4f); lighterFill = SubstanceColorUtilities.getInterpolatedColor(lighterFill, backgroundFillColor, 0.6); float selectionStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.SELECTION); float rolloverStrength = stateTransitionTracker .getFacetStrength(ComponentStateFacet.ROLLOVER); backgroundFillColor = SubstanceColorUtilities.getInterpolatedColor(lighterFill, backgroundFillColor, Math.max(selectionStrength, rolloverStrength) / 4.0f); } } return backgroundFillColor; }
Example 2
Source File: RadioButtonMenuItemIcon.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns the current icon to paint. * * @return Icon to paint. */ private ImageWrapperIcon getIconToPaint() { if (this.menuItem == null) return null; TransitionAwareUI transitionAwareUI = (TransitionAwareUI) this.menuItem .getUI(); StateTransitionTracker stateTransitionTracker = transitionAwareUI .getTransitionTracker(); StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker .getModelStateInfo(); Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo .getStateContributionMap(); int fontSize = SubstanceSizeUtils.getComponentFontSize(this.menuItem); int checkMarkSize = this.size; SubstanceFillPainter fillPainter = SubstanceCoreUtilities.getFillPainter(this.menuItem); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities.getBorderPainter(this.menuItem); ComponentState currState = modelStateInfo.getCurrModelState(); SubstanceColorScheme baseFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK_BOX, currState); SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme baseBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, currState); float visibility = stateTransitionTracker.getFacetStrength(ComponentStateFacet.SELECTION); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.menuItem, currState); HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), baseFillColorScheme.getDisplayName(), baseMarkColorScheme.getDisplayName(), baseBorderColorScheme.getDisplayName(), visibility, alpha); ImageWrapperIcon iconBase = iconMap.get(keyBase); if (iconBase == null) { iconBase = new ImageWrapperIcon(SubstanceImageCreator.getRadioButton( this.menuItem, fillPainter, borderPainter, checkMarkSize, currState, 0, baseFillColorScheme, baseMarkColorScheme, baseBorderColorScheme, visibility, alpha)); iconMap.put(keyBase, iconBase); } if (currState.isDisabled() || (activeStates.size() == 1)) { return iconBase; } BufferedImage result = SubstanceCoreUtilities.getBlankImage(iconBase .getIconWidth(), iconBase.getIconHeight()); Graphics2D g2d = result.createGraphics(); // draw the base layer iconBase.paintIcon(this.menuItem, g2d, 0, 0); // draw other active layers for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates .entrySet()) { ComponentState activeState = activeEntry.getKey(); // System.out.println("Painting state " + activeState + "[curr is " // + currState + "] with " + activeEntry.getValue()); if (activeState == currState) continue; float stateContribution = activeEntry.getValue().getContribution(); if (stateContribution > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(stateContribution)); SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK_BOX, activeState); SubstanceColorScheme markColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, activeState); SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, activeState); HashMapKey keyLayer = SubstanceCoreUtilities.getHashKey( fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), fillColorScheme.getDisplayName(), markColorScheme.getDisplayName(), borderColorScheme.getDisplayName(), visibility, alpha); ImageWrapperIcon iconLayer = iconMap.get(keyLayer); if (iconLayer == null) { iconLayer = new ImageWrapperIcon(SubstanceImageCreator .getRadioButton(this.menuItem, fillPainter, borderPainter, checkMarkSize, currState, 0, fillColorScheme, markColorScheme, borderColorScheme, visibility, alpha)); iconMap.put(keyLayer, iconLayer); } iconLayer.paintIcon(this.menuItem, g2d, 0, 0); } } g2d.dispose(); return new ImageWrapperIcon(result); }
Example 3
Source File: CheckBoxMenuItemIcon.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns the current icon to paint. * * @return Icon to paint. */ private ImageWrapperIcon getIconToPaint() { if (this.menuItem == null) return null; TransitionAwareUI transitionAwareUI = (TransitionAwareUI) this.menuItem.getUI(); StateTransitionTracker stateTransitionTracker = transitionAwareUI.getTransitionTracker(); StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker .getModelStateInfo(); Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo .getStateContributionMap(); SubstanceFillPainter fillPainter = SubstanceCoreUtilities.getFillPainter(this.menuItem); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities .getBorderPainter(this.menuItem); ComponentState currState = modelStateInfo.getCurrModelState(); SubstanceColorScheme baseFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK_BOX, currState); SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme baseBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, currState); float visibility = stateTransitionTracker.getFacetStrength(ComponentStateFacet.SELECTION); boolean isCheckMarkFadingOut = !currState.isFacetActive(ComponentStateFacet.SELECTION); float alpha = SubstanceColorSchemeUtilities.getAlpha(this.menuItem, currState); int fontSize = SubstanceSizeUtils.getComponentFontSize(this.menuItem); int checkMarkSize = this.size + 3; HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), baseFillColorScheme.getDisplayName(), baseMarkColorScheme.getDisplayName(), baseBorderColorScheme.getDisplayName(), visibility, isCheckMarkFadingOut, alpha); ImageWrapperIcon iconBase = iconMap.get(keyBase); if (iconBase == null) { iconBase = new ImageWrapperIcon( SubstanceImageCreator.getCheckBox(this.menuItem, fillPainter, borderPainter, checkMarkSize, currState, baseFillColorScheme, baseMarkColorScheme, baseBorderColorScheme, visibility, isCheckMarkFadingOut, alpha)); iconMap.put(keyBase, iconBase); } if (currState.isDisabled() || (activeStates.size() == 1)) { return iconBase; } BufferedImage result = SubstanceCoreUtilities.getBlankImage(iconBase.getIconWidth(), iconBase.getIconHeight()); Graphics2D g2d = result.createGraphics(); // draw the base layer iconBase.paintIcon(this.menuItem, g2d, 0, 0); // draw other active layers for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates .entrySet()) { ComponentState activeState = activeEntry.getKey(); // System.out.println("Painting state " + activeState + "[curr is " // + currState + "] with " + activeEntry.getValue()); if (activeState == currState) continue; float stateContribution = activeEntry.getValue().getContribution(); if (stateContribution > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(stateContribution)); SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities.getColorScheme( this.menuItem, ColorSchemeAssociationKind.MARK_BOX, activeState); SubstanceColorScheme markColorScheme = SubstanceColorSchemeUtilities.getColorScheme( this.menuItem, ColorSchemeAssociationKind.MARK, activeState); SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(this.menuItem, ColorSchemeAssociationKind.BORDER, activeState); HashMapKey keyLayer = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), fillColorScheme.getDisplayName(), markColorScheme.getDisplayName(), borderColorScheme.getDisplayName(), visibility, alpha); ImageWrapperIcon iconLayer = iconMap.get(keyLayer); if (iconLayer == null) { iconLayer = new ImageWrapperIcon(SubstanceImageCreator.getCheckBox( this.menuItem, fillPainter, borderPainter, checkMarkSize, currState, fillColorScheme, markColorScheme, borderColorScheme, visibility, isCheckMarkFadingOut, alpha)); iconMap.put(keyLayer, iconLayer); } iconLayer.paintIcon(this.menuItem, g2d, 0, 0); } } g2d.dispose(); return new ImageWrapperIcon(result); }
Example 4
Source File: SubstanceRadioButtonUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns the icon that matches the current and previous states of the radio button. * * @param button * Button (should be {@link JRadioButton}). * @param stateTransitionTracker * State transition tracker for the radio button. * @return Matching icon. */ private static ImageWrapperIcon getIcon(JToggleButton button, StateTransitionTracker stateTransitionTracker) { StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker .getModelStateInfo(); Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo .getStateContributionMap(); int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int checkMarkSize = SubstanceSizeUtils.getRadioButtonMarkSize(fontSize); SubstanceFillPainter fillPainter = SubstanceCoreUtilities.getFillPainter(button); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities.getBorderPainter(button); ComponentState currState = modelStateInfo.getCurrModelState(); SubstanceColorScheme baseFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK_BOX, currState); SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme baseBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, currState); float visibility = stateTransitionTracker.getFacetStrength(ComponentStateFacet.SELECTION); float alpha = SubstanceColorSchemeUtilities.getAlpha(button, currState); HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), baseFillColorScheme.getDisplayName(), baseMarkColorScheme.getDisplayName(), baseBorderColorScheme.getDisplayName(), visibility, alpha); ImageWrapperIcon iconBase = icons.get(keyBase); if (iconBase == null) { iconBase = new ImageWrapperIcon(SubstanceImageCreator.getRadioButton(button, fillPainter, borderPainter, checkMarkSize, currState, 0, baseFillColorScheme, baseMarkColorScheme, baseBorderColorScheme, visibility, alpha)); icons.put(keyBase, iconBase); } if (currState.isDisabled() || (activeStates.size() == 1)) { return iconBase; } BufferedImage result = SubstanceCoreUtilities.getBlankImage(iconBase.getIconWidth(), iconBase.getIconHeight()); Graphics2D g2d = result.createGraphics(); // draw the base layer iconBase.paintIcon(button, g2d, 0, 0); // draw other active layers for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates .entrySet()) { ComponentState activeState = activeEntry.getKey(); // System.out.println("Painting state " + activeState + "[curr is " // + currState + "] with " + activeEntry.getValue()); if (activeState == currState) continue; float stateContribution = activeEntry.getValue().getContribution(); if (stateContribution > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(stateContribution)); SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK_BOX, activeState); SubstanceColorScheme markColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, activeState); SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, activeState); HashMapKey keyLayer = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), fillColorScheme.getDisplayName(), markColorScheme.getDisplayName(), borderColorScheme.getDisplayName(), visibility, alpha); ImageWrapperIcon iconLayer = icons.get(keyLayer); if (iconLayer == null) { iconLayer = new ImageWrapperIcon( SubstanceImageCreator.getRadioButton(button, fillPainter, borderPainter, checkMarkSize, currState, 0, fillColorScheme, markColorScheme, borderColorScheme, visibility, alpha)); icons.put(keyLayer, iconLayer); } iconLayer.paintIcon(button, g2d, 0, 0); } } g2d.dispose(); return new ImageWrapperIcon(result); }
Example 5
Source File: SubstanceCheckBoxUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * Returns the icon that matches the current and previous states of the checkbox. * * @param button Button (should be {@link JCheckBox}). * @param stateTransitionTracker State transition tracker for the checkbox. * @return Matching icon. */ private static Icon getIcon(JToggleButton button, StateTransitionTracker stateTransitionTracker) { StateTransitionTracker.ModelStateInfo modelStateInfo = stateTransitionTracker.getModelStateInfo(); Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo.getStateContributionMap(); SubstanceFillPainter fillPainter = SubstanceCoreUtilities.getFillPainter(button); SubstanceBorderPainter borderPainter = SubstanceCoreUtilities.getBorderPainter(button); ComponentState currState = modelStateInfo.getCurrModelState(); SubstanceColorScheme baseFillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK_BOX, currState); SubstanceColorScheme baseMarkColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, currState); SubstanceColorScheme baseBorderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, currState); float visibility = stateTransitionTracker.getFacetStrength(ComponentStateFacet.SELECTION); boolean isCheckMarkFadingOut = !currState.isFacetActive(ComponentStateFacet.SELECTION); float alpha = SubstanceColorSchemeUtilities.getAlpha(button, currState); int fontSize = SubstanceSizeUtils.getComponentFontSize(button); int checkMarkSize = SubstanceSizeUtils.getCheckBoxMarkSize(fontSize); HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), baseFillColorScheme.getDisplayName(), baseMarkColorScheme.getDisplayName(), baseBorderColorScheme.getDisplayName(), visibility, isCheckMarkFadingOut, alpha); ImageWrapperIcon iconBase = icons.get(keyBase); if (iconBase == null) { iconBase = new ImageWrapperIcon( SubstanceImageCreator.getCheckBox(button, fillPainter, borderPainter, checkMarkSize, currState, baseFillColorScheme, baseMarkColorScheme, baseBorderColorScheme, visibility, isCheckMarkFadingOut, alpha)); icons.put(keyBase, iconBase); } if (currState.isDisabled() || (activeStates.size() == 1)) { return iconBase; } BufferedImage result = SubstanceCoreUtilities.getBlankImage(iconBase.getIconWidth(), iconBase.getIconHeight()); Graphics2D g2d = result.createGraphics(); // draw the base layer iconBase.paintIcon(button, g2d, 0, 0); // draw other active layers for (Map.Entry<ComponentState, StateTransitionTracker.StateContributionInfo> activeEntry : activeStates.entrySet()) { ComponentState activeState = activeEntry.getKey(); // System.out.println("Painting state " + activeState + "[curr is " // + currState + "] with " + activeEntry.getValue()); if (activeState == currState) { continue; } float stateContribution = activeEntry.getValue().getContribution(); if (stateContribution > 0.0f) { g2d.setComposite(AlphaComposite.SrcOver.derive(stateContribution)); SubstanceColorScheme fillColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK_BOX, activeState); SubstanceColorScheme markColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.MARK, activeState); SubstanceColorScheme borderColorScheme = SubstanceColorSchemeUtilities .getColorScheme(button, ColorSchemeAssociationKind.BORDER, activeState); HashMapKey keyLayer = SubstanceCoreUtilities.getHashKey(fontSize, checkMarkSize, fillPainter.getDisplayName(), borderPainter.getDisplayName(), fillColorScheme.getDisplayName(), markColorScheme.getDisplayName(), borderColorScheme.getDisplayName(), visibility); ImageWrapperIcon iconLayer = icons.get(keyLayer); if (iconLayer == null) { iconLayer = new ImageWrapperIcon( SubstanceImageCreator.getCheckBox(button, fillPainter, borderPainter, checkMarkSize, currState, fillColorScheme, markColorScheme, borderColorScheme, visibility, isCheckMarkFadingOut, alpha)); icons.put(keyLayer, iconLayer); } iconLayer.paintIcon(button, g2d, 0, 0); } } g2d.dispose(); return new ImageWrapperIcon(result); }