diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceColorSchemeBundle2.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceColorSchemeBundle2.java index ed97b03aa..e676e36dd 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceColorSchemeBundle2.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/RadianceColorSchemeBundle2.java @@ -99,6 +99,46 @@ public void registerColorScheme(RadianceColorScheme2 stateColorScheme, Component states); } + /** + * Registers the color scheme to be used for the specified visual area of + * controls under the specified states. For example, if the light orange + * scheme has to be used for gradient fill for rollover selected and rollover + * controls, the parameters would be: + * + * + * + * @param scheme Color scheme. + * @param associationKind Color scheme association kind that specifies the visual areas + * of controls to be painted with this color scheme. + * @param states Component states that further restrict the usage of the + * specified color scheme. + */ + public void registerColorScheme(RadianceColorScheme2 scheme, + RadianceThemingSlices.ContainerColorTokensAssociationKind associationKind, + ComponentState... states) { + if (scheme == null) { + throw new IllegalArgumentException("Cannot pass null color scheme"); + } + + if ((states == null) || (states.length == 0)) { + throw new IllegalArgumentException("Must pass at least one state"); + } + + for (ComponentState state : states) { + if (state.isDisabled() || !state.isActive()) { + throw new IllegalArgumentException("Only active states can have custom color schemes"); + } + this.colorTokensForActiveStates.get(associationKind).put(state, scheme.getActiveContainerTokens()); + } + } + /** * Returns the color scheme of the specified component in the specified * component state. @@ -149,46 +189,6 @@ public RadianceColorScheme2 getMainColorScheme() { return this.mainColorScheme; } - /** - * Registers the color scheme to be used for the specified visual area of - * controls under the specified states. For example, if the light orange - * scheme has to be used for gradient fill for rollover selected and rollover - * controls, the parameters would be: - * - * - * - * @param scheme Color scheme. - * @param associationKind Color scheme association kind that specifies the visual areas - * of controls to be painted with this color scheme. - * @param states Component states that further restrict the usage of the - * specified color scheme. - */ - public void registerColorScheme(RadianceColorScheme2 scheme, - RadianceThemingSlices.ContainerColorTokensAssociationKind associationKind, - ComponentState... states) { - if (scheme == null) { - throw new IllegalArgumentException("Cannot pass null color scheme"); - } - - if ((states == null) || (states.length == 0)) { - throw new IllegalArgumentException("Must pass at least one state"); - } - - for (ComponentState state : states) { - if (state.isDisabled() || !state.isActive()) { - throw new IllegalArgumentException("Only active states can have custom color schemes"); - } - this.colorTokensForActiveStates.get(associationKind).put(state, scheme.getActiveContainerTokens()); - } - } - /** * Returns the color scheme to be used for painting the specified visual * area of the component under the specified component state. diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java index 1de1ee905..6cef64186 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/ColorSchemeUtils.java @@ -45,7 +45,7 @@ public enum ActiveStatesContainerType { } private static ContainerColorTokens getContainerTokens( - DynamicScheme dynamicScheme, PaletteContainerColorsResolver tonalContainerColorResolver) { + DynamicScheme dynamicScheme, SchemeContainerColorsResolver tonalContainerColorResolver) { return new ContainerColorTokens() { @Override @@ -134,44 +134,44 @@ public static RadianceColorScheme2 getLightColorScheme( /* systemSuccessPalette */ palettes.getSystemSuccessPalette(), /* systemEmergencyPalette */ palettes.getSystemEmergencyPalette()); - PaletteColorResolver paletteColorResolver = PaletteResolverUtils.getPaletteColorResolver(); + SchemeColorResolver schemeColorResolver = SchemeResolverUtils.getSchemeColorResolver(); ContainerColorTokens neutralContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getNeutralContainerResolver()); + lightScheme, schemeColorResolver.getNeutralContainerResolver()); ContainerColorTokens mutedContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getMutedContainerResolver()); + lightScheme, schemeColorResolver.getMutedContainerResolver()); ContainerColorTokens tonalContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getTonalContainerResolver()); + lightScheme, schemeColorResolver.getTonalContainerResolver()); ContainerColorTokens primaryContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getPrimaryContainerResolver()); + lightScheme, schemeColorResolver.getPrimaryContainerResolver()); ContainerColorTokens systemInfoContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getSystemInfoContainerResolver()); + lightScheme, schemeColorResolver.getSystemInfoContainerResolver()); ContainerColorTokens systemWarningContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getSystemWarningContainerResolver()); + lightScheme, schemeColorResolver.getSystemWarningContainerResolver()); ContainerColorTokens systemErrorContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getSystemErrorContainerResolver()); + lightScheme, schemeColorResolver.getSystemErrorContainerResolver()); ContainerColorTokens systemSuccessContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getSystemSuccessContainerResolver()); + lightScheme, schemeColorResolver.getSystemSuccessContainerResolver()); ContainerColorTokens systemEmergencyContainerTokens = getContainerTokens( - lightScheme, paletteColorResolver.getSystemEmergencyContainerResolver()); + lightScheme, schemeColorResolver.getSystemEmergencyContainerResolver()); return new RadianceColorScheme2() { private HashMap stateTokens = new HashMap<>(); @Override public Color getSurface() { - return paletteColorResolver.getSurface(lightScheme); + return schemeColorResolver.getSurface(lightScheme); } @Override public Color getSurfaceDim() { - return paletteColorResolver.getSurfaceDim(lightScheme); + return schemeColorResolver.getSurfaceDim(lightScheme); } @Override public Color getSurfaceBright() { - return paletteColorResolver.getSurfaceBright(lightScheme); + return schemeColorResolver.getSurfaceBright(lightScheme); } @Override @@ -306,44 +306,44 @@ public static RadianceColorScheme2 getDarkColorScheme( /* systemSuccessPalette */ palettes.getSystemSuccessPalette(), /* systemEmergencyPalette */ palettes.getSystemEmergencyPalette()); - PaletteColorResolver paletteColorResolver = PaletteResolverUtils.getPaletteColorResolver(); + SchemeColorResolver schemeColorResolver = SchemeResolverUtils.getSchemeColorResolver(); ContainerColorTokens neutralContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getNeutralContainerResolver()); + darkScheme, schemeColorResolver.getNeutralContainerResolver()); ContainerColorTokens mutedContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getMutedContainerResolver()); + darkScheme, schemeColorResolver.getMutedContainerResolver()); ContainerColorTokens tonalContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getTonalContainerResolver()); + darkScheme, schemeColorResolver.getTonalContainerResolver()); ContainerColorTokens primaryContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getPrimaryContainerResolver()); + darkScheme, schemeColorResolver.getPrimaryContainerResolver()); ContainerColorTokens systemInfoContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getSystemInfoContainerResolver()); + darkScheme, schemeColorResolver.getSystemInfoContainerResolver()); ContainerColorTokens systemWarningContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getSystemWarningContainerResolver()); + darkScheme, schemeColorResolver.getSystemWarningContainerResolver()); ContainerColorTokens systemErrorContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getSystemErrorContainerResolver()); + darkScheme, schemeColorResolver.getSystemErrorContainerResolver()); ContainerColorTokens systemSuccessContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getSystemSuccessContainerResolver()); + darkScheme, schemeColorResolver.getSystemSuccessContainerResolver()); ContainerColorTokens systemEmergencyContainerTokens = getContainerTokens( - darkScheme, paletteColorResolver.getSystemEmergencyContainerResolver()); + darkScheme, schemeColorResolver.getSystemEmergencyContainerResolver()); return new RadianceColorScheme2() { private HashMap stateTokens = new HashMap<>(); @Override public Color getSurface() { - return paletteColorResolver.getSurface(darkScheme); + return schemeColorResolver.getSurface(darkScheme); } @Override public Color getSurfaceDim() { - return paletteColorResolver.getSurfaceDim(darkScheme); + return schemeColorResolver.getSurfaceDim(darkScheme); } @Override public Color getSurfaceBright() { - return paletteColorResolver.getSurfaceBright(darkScheme); + return schemeColorResolver.getSurfaceBright(darkScheme); } @Override diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteColorResolver.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeColorResolver.java similarity index 74% rename from theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteColorResolver.java rename to theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeColorResolver.java index 99c0344d9..f0a1f26d6 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteColorResolver.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeColorResolver.java @@ -33,19 +33,19 @@ import java.awt.*; -public interface PaletteColorResolver { +public interface SchemeColorResolver { Color getSurface(DynamicScheme dynamicScheme); Color getSurfaceDim(DynamicScheme dynamicScheme); Color getSurfaceBright(DynamicScheme dynamicScheme); - PaletteContainerColorsResolver getNeutralContainerResolver(); - PaletteContainerColorsResolver getMutedContainerResolver(); - PaletteContainerColorsResolver getTonalContainerResolver(); - PaletteContainerColorsResolver getPrimaryContainerResolver(); + SchemeContainerColorsResolver getNeutralContainerResolver(); + SchemeContainerColorsResolver getMutedContainerResolver(); + SchemeContainerColorsResolver getTonalContainerResolver(); + SchemeContainerColorsResolver getPrimaryContainerResolver(); - PaletteContainerColorsResolver getSystemInfoContainerResolver(); - PaletteContainerColorsResolver getSystemWarningContainerResolver(); - PaletteContainerColorsResolver getSystemErrorContainerResolver(); - PaletteContainerColorsResolver getSystemSuccessContainerResolver(); - PaletteContainerColorsResolver getSystemEmergencyContainerResolver(); + SchemeContainerColorsResolver getSystemInfoContainerResolver(); + SchemeContainerColorsResolver getSystemWarningContainerResolver(); + SchemeContainerColorsResolver getSystemErrorContainerResolver(); + SchemeContainerColorsResolver getSystemSuccessContainerResolver(); + SchemeContainerColorsResolver getSystemEmergencyContainerResolver(); } diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteContainerColorsResolver.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeContainerColorsResolver.java similarity index 97% rename from theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteContainerColorsResolver.java rename to theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeContainerColorsResolver.java index c8c99f3ac..c3b97ddd6 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteContainerColorsResolver.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeContainerColorsResolver.java @@ -33,7 +33,7 @@ import java.awt.*; -public interface PaletteContainerColorsResolver { +public interface SchemeContainerColorsResolver { Color getContainerSurfaceLowest(DynamicScheme dynamicScheme); Color getContainerSurfaceLow(DynamicScheme dynamicScheme); Color getContainerSurface(DynamicScheme dynamicScheme); diff --git a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeResolverUtils.java similarity index 91% rename from theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java rename to theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeResolverUtils.java index 7eab77e99..18d021cc5 100644 --- a/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/PaletteResolverUtils.java +++ b/theming/src/main/java/org/pushingpixels/radiance/theming/api/palette/SchemeResolverUtils.java @@ -33,10 +33,10 @@ import java.awt.*; -public class PaletteResolverUtils { - public static PaletteColorResolver getPaletteColorResolver() { - PaletteContainerColorsResolver neutralContainerResolver = - new PaletteContainerColorsResolver() { +public class SchemeResolverUtils { + public static SchemeColorResolver getSchemeColorResolver() { + SchemeContainerColorsResolver neutralContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getNeutralContainerSurfaceLowest()); @@ -83,8 +83,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver mutedContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver mutedContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getMutedContainerSurfaceLowest()); @@ -131,8 +131,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver tonalContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver tonalContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getTonalContainerSurfaceLowest()); @@ -179,8 +179,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver primaryContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver primaryContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getPrimaryContainerSurfaceLowest()); @@ -227,8 +227,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver systemInfoContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver systemInfoContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSystemInfoContainerSurfaceLowest()); @@ -275,8 +275,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver systemWarningContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver systemWarningContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSystemWarningContainerSurfaceLowest()); @@ -323,8 +323,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver systemErrorContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver systemErrorContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSystemErrorContainerSurfaceLowest()); @@ -371,8 +371,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver systemSuccessContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver systemSuccessContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSystemSuccessContainerSurfaceLowest()); @@ -419,8 +419,8 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - PaletteContainerColorsResolver systemEmergencyContainerResolver = - new PaletteContainerColorsResolver() { + SchemeContainerColorsResolver systemEmergencyContainerResolver = + new SchemeContainerColorsResolver() { @Override public Color getContainerSurfaceLowest(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSystemEmergencyContainerSurfaceLowest()); @@ -467,7 +467,7 @@ public Color getContainerOutlineVariant(DynamicScheme dynamicScheme) { } }; - return new PaletteColorResolver() { + return new SchemeColorResolver() { @Override public Color getSurface(DynamicScheme dynamicScheme) { return new Color(dynamicScheme.getSurface()); @@ -484,47 +484,47 @@ public Color getSurfaceBright(DynamicScheme dynamicScheme) { } @Override - public PaletteContainerColorsResolver getNeutralContainerResolver() { + public SchemeContainerColorsResolver getNeutralContainerResolver() { return neutralContainerResolver; } @Override - public PaletteContainerColorsResolver getMutedContainerResolver() { + public SchemeContainerColorsResolver getMutedContainerResolver() { return mutedContainerResolver; } @Override - public PaletteContainerColorsResolver getTonalContainerResolver() { + public SchemeContainerColorsResolver getTonalContainerResolver() { return tonalContainerResolver; } @Override - public PaletteContainerColorsResolver getPrimaryContainerResolver() { + public SchemeContainerColorsResolver getPrimaryContainerResolver() { return primaryContainerResolver; } @Override - public PaletteContainerColorsResolver getSystemInfoContainerResolver() { + public SchemeContainerColorsResolver getSystemInfoContainerResolver() { return systemInfoContainerResolver; } @Override - public PaletteContainerColorsResolver getSystemWarningContainerResolver() { + public SchemeContainerColorsResolver getSystemWarningContainerResolver() { return systemWarningContainerResolver; } @Override - public PaletteContainerColorsResolver getSystemErrorContainerResolver() { + public SchemeContainerColorsResolver getSystemErrorContainerResolver() { return systemErrorContainerResolver; } @Override - public PaletteContainerColorsResolver getSystemSuccessContainerResolver() { + public SchemeContainerColorsResolver getSystemSuccessContainerResolver() { return systemSuccessContainerResolver; } @Override - public PaletteContainerColorsResolver getSystemEmergencyContainerResolver() { + public SchemeContainerColorsResolver getSystemEmergencyContainerResolver() { return systemEmergencyContainerResolver; } };