Skip to content

Commit

Permalink
Add contrast level to the APIs that load color schemes
Browse files Browse the repository at this point in the history
For #400
  • Loading branch information
kirill-grouchnikov committed Jan 24, 2025
1 parent 407af1c commit db419a1
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.pushingpixels.radiance.theming.api.painter.fill.SpecularRectangularFillPainter;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;
import org.pushingpixels.radiance.theming.api.palette.TonalSkin;
import org.pushingpixels.radiance.theming.api.shaper.ClassicButtonShaper;
import org.pushingpixels.radiance.theming.internal.RadianceSynapse;
Expand Down Expand Up @@ -102,8 +101,7 @@ public SampleSkin(RadianceColorScheme accentScheme) {
RadianceColorScheme2 lightColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.BalancedPaletteSource(Hct.fromInt(0xFF9020F4), 8.0, 6.0),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);

RadianceColorSchemeBundle2 bundle2 = new RadianceColorSchemeBundle2(lightColorScheme);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin;

import javax.swing.*;
Expand All @@ -60,13 +59,11 @@ public PaletteBalancedDemo() {
RadianceColorScheme2 lightColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.BalancedPaletteSource(Hct.fromInt(0xFF76A8C8), 16.0, 10.0),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
RadianceColorScheme2 darkColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.BalancedPaletteSource(Hct.fromInt(0xFF76A8C8), 16.0, 10.0),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ true);

builder.addSeparator("LIGHT").xy(3, row, CellConstraints.CENTER, CellConstraints.FILL);
builder.addSeparator("DARK").xy(5, row, CellConstraints.CENTER, CellConstraints.FILL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;
import org.pushingpixels.radiance.theming.api.skin.BusinessSkin;

import javax.swing.*;
Expand All @@ -61,14 +60,12 @@ public PaletteFidelityDemo() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFFDBD72), Hct.fromInt(0xFFFEDCB6), Hct.fromInt(0xFFFFE3C4)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
RadianceColorScheme2 darkColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF663E00), Hct.fromInt(0xFF402200), Hct.fromInt(0xFF201200)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ true);

builder.addSeparator("LIGHT").xy(3, row, CellConstraints.CENTER, CellConstraints.FILL);
builder.addSeparator("DARK").xy(5, row, CellConstraints.CENTER, CellConstraints.FILL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ public OfficeSilver2007TonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFC6CACF), Hct.fromInt(0xFFE6EAEE), Hct.fromInt(0xFFF2F5F5)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
RadianceColorSchemeBundle2 officeSilverDefaultBundle =
new RadianceColorSchemeBundle2(officeSilverColorScheme);

Expand Down Expand Up @@ -395,8 +394,7 @@ public OfficeSilver2007TonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFCFD4DE), Hct.fromInt(0xFFE6EAEE), Hct.fromInt(0xFFDDDEE1)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
this.registerAsDecorationArea(
officeSilverHeaderColorScheme.getExtendedTonalContainerTokens(),
DecorationAreaType.FOOTER, DecorationAreaType.HEADER, DecorationAreaType.TOOLBAR);
Expand All @@ -405,8 +403,7 @@ public OfficeSilver2007TonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFC6CACF), Hct.fromInt(0xFFE6EAEE), Hct.fromInt(0xFFCFCFD0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
this.registerAsDecorationArea(
officeSilverTitleColorScheme.getExtendedTonalContainerTokens(),
DecorationAreaType.CONTROL_PANE, DecorationAreaType.PRIMARY_TITLE_PANE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,14 +362,15 @@ public static RadianceColorScheme2 getColorScheme(
PalettesSource palettesSource,
RadianceThemingSlices.ActiveContainerType activeContainerType,
boolean isDark) {
return getColorScheme(palettesSource, activeContainerType, isDark,
return getColorScheme(palettesSource, activeContainerType, isDark, 0.0f,
SchemeResolverUtils.getSchemeColorResolver());
}

public static RadianceColorScheme2 getColorScheme(
PalettesSource palettesSource,
RadianceThemingSlices.ActiveContainerType activeContainerType,
boolean isDark,
double contrastLevel,
SchemeColorResolver schemeColorResolver) {

Palettes palettes = palettesSource.getPalettes();
Expand All @@ -380,7 +381,7 @@ public static RadianceColorScheme2 getColorScheme(
/* neutralSourceColorHct */ palettes.getNeutralSourceHct(),
/* isFidelity */ palettes.isFidelity(),
/* isDark */ isDark,
/* contrastLevel */ 0.0,
/* contrastLevel */ contrastLevel,
/* primaryPalette */ palettes.getPrimaryPalette(),
/* mutedPalette */ palettes.getMutedPalette(),
/* neutralPalette */ palettes.getNeutralPalette());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public AutumnTonalSkin() {
Hct.fromInt(0xFFFFCB90), Hct.fromInt(0xFFFEDCB6), Hct.fromInt(0xFFFFE2C1)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* contrastLevel */ 0.0f,
/* schemeColorResolver */ autumnColorResolver);

RadianceColorSchemeBundle2 autumnDefaultBundle =
Expand Down Expand Up @@ -241,6 +242,7 @@ public AutumnTonalSkin() {
Hct.fromInt(0xFFFDBD72), Hct.fromInt(0xFFFEDCB6), Hct.fromInt(0xFFFFDDB9)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* contrastLevel */ 0.0f,
/* schemeColorResolver */ autumnColorResolver);
RadianceColorSchemeBundle2 autumnControlPaneBundle =
new RadianceColorSchemeBundle2(autumnControlPaneColorScheme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.pushingpixels.radiance.theming.api.painter.overlay.TopShadowOverlayPainter;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;
import org.pushingpixels.radiance.theming.api.shaper.ClassicButtonShaper;

/**
Expand Down Expand Up @@ -87,8 +86,7 @@ protected BusinessAccentedTonalSkin(AccentBuilder accentBuilder) {
RadianceColorScheme2 controlPaneColorScheme = ColorSchemeUtils.getColorScheme(
/* palettesSource */ new ColorSchemeUtils.BalancedPaletteSource(Hct.fromInt(0xFFDBDFE4), 3.0, 1.0),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);
this.registerAsDecorationArea(controlPaneColorScheme.getExtendedTonalContainerTokens(),
RadianceThemingSlices.DecorationAreaType.CONTROL_PANE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;

/**
* <code>Business Black Steel</code> skin. This class is part of officially supported API.
Expand Down Expand Up @@ -113,8 +112,7 @@ public BusinessBlackSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF404040), Hct.fromInt(0xFF565656), Hct.fromInt(0xFF616161)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ true))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF85A3B5),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand All @@ -124,8 +122,7 @@ public BusinessBlackSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFA1BCCF),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand All @@ -136,8 +133,7 @@ public BusinessBlackSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFAFBEC7), Hct.fromInt(0xFFD5DBDF), Hct.fromInt(0xFFD0D7DC)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);

RadianceColorSchemeBundle2 businessBlueSteelControlBundle =
new RadianceColorSchemeBundle2(controlPaneColorScheme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.pushingpixels.radiance.theming.api.colorscheme.RadianceColorScheme;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.RadianceColorScheme2;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;

/**
* <code>Business Blue Steel</code> skin. This class is part of officially supported API.
Expand Down Expand Up @@ -103,8 +102,7 @@ public BusinessBlueSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFA1BCD0), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ false))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFF83AFCE),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand All @@ -114,8 +112,7 @@ public BusinessBlueSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF98B7CC), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand All @@ -126,8 +123,7 @@ public BusinessBlueSteelTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFF94B9D3), Hct.fromInt(0xFFBFCFDB), Hct.fromInt(0xFFBFCFDB)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);

RadianceColorSchemeBundle2 businessBlueSteelControlBundle =
new RadianceColorSchemeBundle2(controlPaneColorScheme);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.pushingpixels.ephemeral.chroma.hct.Hct;
import org.pushingpixels.radiance.theming.api.RadianceThemingSlices;
import org.pushingpixels.radiance.theming.api.palette.ColorSchemeUtils;
import org.pushingpixels.radiance.theming.api.palette.SchemeResolverUtils;

/**
* <code>Business</code> skin. This class is part of officially supported API.
Expand Down Expand Up @@ -70,8 +69,7 @@ public BusinessTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFBDC8D3), Hct.fromInt(0xFFDEDDDF), Hct.fromInt(0xFFE4EAF0)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ false))
.withWindowChromeHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand All @@ -81,8 +79,7 @@ public BusinessTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFEAEDF3), Hct.fromInt(0xFFC4C8CC), Hct.fromInt(0xFFE5EAEF)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver()))
/* isDark */ false))
.withHighlightsAccent(ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFEBD296),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ public MarinerTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFF6DD9D), Hct.fromInt(0xFFD9D8D5), Hct.fromInt(0xFFECF0F3)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);

ContainerColorTokens marinerSelectedContainerTokens = ColorSchemeUtils.getContainerTokens(
/* seed */ Hct.fromInt(0xFFF5D47A),
Expand Down Expand Up @@ -277,8 +276,7 @@ public MarinerTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFF5D47A), Hct.fromInt(0xFF281D1E), Hct.fromInt(0xFF2C2021)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ true,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ true);

RadianceColorSchemeBundle2 marinerHeaderBundle =
new RadianceColorSchemeBundle2(marinerHeaderColorScheme);
Expand Down Expand Up @@ -320,8 +318,7 @@ public MarinerTonalSkin() {
/* palettesSource */ new ColorSchemeUtils.FidelityPaletteSource(
Hct.fromInt(0xFFF6DD9D), Hct.fromInt(0xFFC5C4C2), Hct.fromInt(0xFFB9B7B9)),
/* activeStatesContainerType */ RadianceThemingSlices.ActiveContainerType.TONAL,
/* isDark */ false,
/* schemeColorResolver */ SchemeResolverUtils.getSchemeColorResolver());
/* isDark */ false);

RadianceColorSchemeBundle2 marinerFooterBundle =
new RadianceColorSchemeBundle2(marinerFooterColorScheme);
Expand Down
Loading

0 comments on commit db419a1

Please sign in to comment.