SubstanceColorScheme baseScheme = SubstanceColorSchemeUtilities
.getColorScheme(this.component, baseAssociationKind, currState);
float baseAlpha = SubstanceColorSchemeUtilities.getAlpha(
this.component, currState);
HashMapKey keyBase = SubstanceCoreUtilities.getHashKey(this.component
.getClass().getName(), this.orientation, SubstanceSizeUtils
.getComponentFontSize(this.component), baseScheme
.getDisplayName(), baseAlpha);
Icon layerBase = iconMap.get(keyBase);
if (layerBase == null) {
Icon baseFullOpacity = this.delegate.getColorSchemeIcon(baseScheme);
if (baseAlpha == 1.0f) {
layerBase = baseFullOpacity;
iconMap.put(keyBase, layerBase);
} else {
BufferedImage baseImage = SubstanceCoreUtilities.getBlankImage(
baseFullOpacity.getIconWidth(), baseFullOpacity
.getIconHeight());
Graphics2D g2base = baseImage.createGraphics();
g2base.setComposite(AlphaComposite.SrcOver.derive(baseAlpha));
baseFullOpacity.paintIcon(this.component, g2base, 0, 0);
g2base.dispose();
layerBase = new ImageIcon(baseImage);
iconMap.put(keyBase, layerBase);
}
}
// System.out.println("Contribution map in painting");
// for (Map.Entry<ComponentState,
// StateTransitionTracker.StateContributionInfo> existing : activeStates
// .entrySet()) {
// System.out.println("\t" + existing.getKey() + " in ["
// + existing.getValue().start + ":" + existing.getValue().end
// + "] : " + existing.getValue().curr);
// }
if (currState.isDisabled() || (activeStates.size() == 1)) {
return layerBase;
}
BufferedImage result = SubstanceCoreUtilities.getBlankImage(layerBase
.getIconWidth(), layerBase.getIconHeight());
Graphics2D g2d = result.createGraphics();
// draw the base layer
// System.out.println("Painting currState " + currState + ":" +
// baseAlpha);
layerBase.paintIcon(this.component, g2d, 0, 0);
// 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();
// System.out.println("Painting activeState "
// + activeState
// + ":"
// + stateContribution
// + "*"
// + SubstanceColorSchemeUtilities.getAlpha(this.component,
// activeState));
if (stateContribution > 0.0f) {
g2d.setComposite(AlphaComposite.SrcOver
.derive(stateContribution));
ColorSchemeAssociationKind associationKind = isMenu
&& activeState
.isFacetActive(ComponentStateFacet.ROLLOVER) ? ColorSchemeAssociationKind.HIGHLIGHT
: ColorSchemeAssociationKind.MARK;
SubstanceColorScheme scheme = SubstanceColorSchemeUtilities
.getColorScheme(this.component, associationKind,
activeState);
float alpha = SubstanceColorSchemeUtilities.getAlpha(
this.component, activeState);
HashMapKey key = SubstanceCoreUtilities
.getHashKey(this.component.getClass().getName(),
this.orientation, SubstanceSizeUtils
.getComponentFontSize(this.component),
scheme.getDisplayName(), alpha);
Icon layer = iconMap.get(key);