// }
boolean isContentAreaFilled = button.isContentAreaFilled();
boolean isBorderPainted = button.isBorderPainted();
// compute color scheme
SubstanceColorScheme baseBorderScheme = SubstanceColorSchemeUtilities
.getColorScheme(button, ColorSchemeAssociationKind.BORDER,
currState);
// see if need to use attention-drawing animation
// boolean isWindowModified = false;
if (button.getUI() instanceof ModificationAwareUI) {
ModificationAwareUI modificationAwareUI = (ModificationAwareUI) button
.getUI();
Timeline modificationTimeline = modificationAwareUI
.getModificationTimeline();
if (modificationTimeline != null) {
if (modificationTimeline.getState() != TimelineState.IDLE) {
// isWindowModified = true;
SubstanceColorScheme colorScheme2 = SubstanceColorSchemeUtilities.YELLOW;
SubstanceColorScheme colorScheme = SubstanceColorSchemeUtilities.ORANGE;
cyclePos = modificationTimeline.getTimelinePosition();
HashMapKey key1 = SubstanceCoreUtilities.getHashKey(width,
height, colorScheme.getDisplayName(),
baseBorderScheme.getDisplayName(), shaper
.getDisplayName(), fillPainter
.getDisplayName(), borderPainter
.getDisplayName(), straightSides,
openSides, button.getClass().getName(),
isRoundButton, radius, isContentAreaFilled,
isBorderPainted, SubstanceSizeUtils
.getComponentFontSize(button));
BufferedImage layer1 = regularBackgrounds.get(key1);
if (layer1 == null) {
layer1 = createBackgroundImage(button, shaper,
fillPainter, borderPainter, width, height,
colorScheme, baseBorderScheme, openSides,
isContentAreaFilled, isBorderPainted);
regularBackgrounds.put(key1, layer1);
}
HashMapKey key2 = SubstanceCoreUtilities.getHashKey(width,
height, colorScheme2.getDisplayName(),
baseBorderScheme.getDisplayName(), shaper
.getDisplayName(), fillPainter
.getDisplayName(), borderPainter
.getDisplayName(), straightSides,
openSides, button.getClass().getName(),
isRoundButton, radius, isContentAreaFilled,
isBorderPainted, SubstanceSizeUtils
.getComponentFontSize(button));
BufferedImage layer2 = regularBackgrounds.get(key2);
if (layer2 == null) {
layer2 = createBackgroundImage(button, shaper,
fillPainter, borderPainter, width, height,
colorScheme2, baseBorderScheme, openSides,
isContentAreaFilled, isBorderPainted);
regularBackgrounds.put(key2, layer2);
}
BufferedImage result = SubstanceCoreUtilities
.getBlankImage(width, height);
Graphics2D g2d = result.createGraphics();
if (cyclePos < 1.0f)
g2d.drawImage(layer1, 0, 0, null);
if (cyclePos > 0.0f) {
g2d.setComposite(AlphaComposite.SrcOver
.derive(cyclePos));
g2d.drawImage(layer2, 0, 0, null);
}
g2d.dispose();
return result;
}
}
}
// see if need to use transition animation. Important - don't do it
// on pulsating buttons (such as default or close buttons
// of modified frames).
Map<ComponentState, StateTransitionTracker.StateContributionInfo> activeStates = modelStateInfo
.getStateContributionMap();
SubstanceColorScheme baseFillScheme = SubstanceColorSchemeUtilities
.getColorScheme(button, currState);
HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(width, height,
baseFillScheme.getDisplayName(), baseBorderScheme
.getDisplayName(), shaper.getDisplayName(), fillPainter
.getDisplayName(), borderPainter.getDisplayName(),
straightSides, openSides, button.getClass().getName(),
isRoundButton, (int) (1000 * radius), isContentAreaFilled,
isBorderPainted, SubstanceSizeUtils
.getComponentFontSize(button));
BufferedImage layerBase = regularBackgrounds.get(keyBase);
if (layerBase == null) {
layerBase = createBackgroundImage(button, shaper, fillPainter,
borderPainter, width, height, baseFillScheme,
baseBorderScheme, openSides, isContentAreaFilled,
isBorderPainted);
regularBackgrounds.put(keyBase, layerBase);
}
if (currState.isDisabled() || (activeStates.size() == 1)) {
return layerBase;
}
BufferedImage result = SubstanceCoreUtilities.getBlankImage(width,
height);
Graphics2D g2d = result.createGraphics();
// draw the base layer
g2d.drawImage(layerBase, 0, 0, null);
// System.out.println("\nPainting base state " + currState);
// draw the 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 fillScheme = SubstanceColorSchemeUtilities
.getColorScheme(button, activeState);
SubstanceColorScheme borderScheme = SubstanceColorSchemeUtilities
.getColorScheme(button,
ColorSchemeAssociationKind.BORDER, activeState);
HashMapKey key = SubstanceCoreUtilities.getHashKey(width,
height, fillScheme.getDisplayName(), borderScheme
.getDisplayName(), shaper.getDisplayName(),
fillPainter.getDisplayName(), borderPainter
.getDisplayName(), straightSides, openSides,
button.getClass().getName(), isRoundButton,
(int) (1000 * radius), isContentAreaFilled,