Class ColorScheme
A set of 45 colors based on the Material spec that can be used to configure the color properties of most components.
Colors in Material 3
In Material 3, colors are represented using color roles and
corresponding tokens. Each property in the ColorScheme class
represents one color role as defined in the spec above.
The main accent color groups in the scheme are ColorRole.PRIMARY, ColorRole.SECONDARY,
and ColorRole.TERTIARY.
-
Primary colors are used for key components across the UI, such as the FAB, prominent buttons, and active states.
-
Secondary colors are used for less prominent components in the UI, such as filter chips, while expanding the opportunity for color expression.
-
Tertiary colors are used for contrasting accents that can be used to balance primary and secondary colors or bring heightened attention to an element, such as an input field. The tertiary colors are left for makers to use at their discretion and are intended to support broader color expression in products.
Each accent color group (primary, secondary and tertiary) includes '-Fixed'
'-Dim' color roles, such as ColorRole.PRIMARY_FIXED and ColorRole.PRIMARY_FIXED_DIM. Fixed roles
are appropriate to use in places where Container roles are normally used,
but they stay the same color between light and dark themes. The '-Dim' roles
provide a stronger, more emphasized color with the same fixed behavior.
The remaining colors of the scheme are composed of neutral colors used for backgrounds and surfaces, as well as specific colors for errors, dividers and shadows. Surface colors are used for backgrounds and large, low-emphasis areas of the screen.
Material 3 also introduces tone-based surfaces and surface containers.
They replace the old opacity-based model which applied a tinted overlay on
top of surfaces based on their elevation. These colors include: ColorRole.SURFACE_BRIGHT,
ColorRole.SURFACE_DIM, ColorRole.SURFACE_CONTAINER_LOWEST, ColorRole.SURFACE_CONTAINER_LOW, ColorRole.SURFACE_CONTAINER,
ColorRole.SURFACE_CONTAINER_HIGH, and ColorRole.SURFACE_CONTAINER_HIGHEST.
Many of the colors have matching 'on' colors, which are used for drawing
content on top of the matching color. For example, if something is using
ColorRole.PRIMARY for a background color, ColorRole.ON_PRIMARY would be used to paint text
and icons on top of it. For this reason, the 'on' colors should have a
contrast ratio with their matching colors of at least 4.5:1 in order to
be readable. On '-FixedVariant' roles, such as ColorRole.ON_PRIMARY_FIXED_VARIANT,
also have the same color between light and dark themes, but compared
with on '-Fixed' roles, such as ColorRole.ON_PRIMARY_FIXED, they provide a
lower-emphasis option for text and icons.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic @NotNull ColorSchemefromImage(@NotNull javafx.scene.image.Image image) static ColorSchemefromSeed(@NotNull javafx.scene.paint.Color seedColor) javafx.scene.paint.Color@NotNull Brightnessjavafx.scene.paint.Color@NotNull ColorStyledoublejavafx.scene.paint.ColorgetError()@Nullable javafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Color@Nullable javafx.scene.paint.Color@Nullable javafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Color@NotNull javafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.ColorgetScrim()javafx.scene.paint.Color@Nullable javafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Color@Nullable javafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.Colorjavafx.scene.paint.ColorinthashCode()static ColorSchemeBuildertoString()toStyleSheet(@Nullable String cssClass, @Nullable String prefix, @Nullable Iterable<ColorRole> colorRoles)
-
Method Details
-
fromImage
@NotNull public static @NotNull ColorScheme fromImage(@NotNull @NotNull javafx.scene.image.Image image) -
fromSeed
-
newBuilder
-
getBrightness
-
getContrastLevel
public double getContrastLevel() -
getColorStyle
-
getPrimaryColorSeed
@NotNull public @NotNull javafx.scene.paint.Color getPrimaryColorSeed() -
getSecondaryColorSeed
@Nullable public @Nullable javafx.scene.paint.Color getSecondaryColorSeed() -
getTertiaryColorSeed
@Nullable public @Nullable javafx.scene.paint.Color getTertiaryColorSeed() -
getNeutralColorSeed
@Nullable public @Nullable javafx.scene.paint.Color getNeutralColorSeed() -
getNeutralVariantColorSeed
@Nullable public @Nullable javafx.scene.paint.Color getNeutralVariantColorSeed() -
getErrorColorSeed
@Nullable public @Nullable javafx.scene.paint.Color getErrorColorSeed() -
getColor
-
getPrimary
public javafx.scene.paint.Color getPrimary() -
getOnPrimary
public javafx.scene.paint.Color getOnPrimary() -
getPrimaryContainer
public javafx.scene.paint.Color getPrimaryContainer() -
getOnPrimaryContainer
public javafx.scene.paint.Color getOnPrimaryContainer() -
getPrimaryFixed
public javafx.scene.paint.Color getPrimaryFixed() -
getPrimaryFixedDim
public javafx.scene.paint.Color getPrimaryFixedDim() -
getOnPrimaryFixed
public javafx.scene.paint.Color getOnPrimaryFixed() -
getOnPrimaryFixedVariant
public javafx.scene.paint.Color getOnPrimaryFixedVariant() -
getSecondary
public javafx.scene.paint.Color getSecondary() -
getOnSecondary
public javafx.scene.paint.Color getOnSecondary() -
getSecondaryContainer
public javafx.scene.paint.Color getSecondaryContainer() -
getOnSecondaryContainer
public javafx.scene.paint.Color getOnSecondaryContainer() -
getSecondaryFixed
public javafx.scene.paint.Color getSecondaryFixed() -
getSecondaryFixedDim
public javafx.scene.paint.Color getSecondaryFixedDim() -
getOnSecondaryFixed
public javafx.scene.paint.Color getOnSecondaryFixed() -
getOnSecondaryFixedVariant
public javafx.scene.paint.Color getOnSecondaryFixedVariant() -
getTertiary
public javafx.scene.paint.Color getTertiary() -
getOnTertiary
public javafx.scene.paint.Color getOnTertiary() -
getTertiaryContainer
public javafx.scene.paint.Color getTertiaryContainer() -
getOnTertiaryContainer
public javafx.scene.paint.Color getOnTertiaryContainer() -
getTertiaryFixed
public javafx.scene.paint.Color getTertiaryFixed() -
getTertiaryFixedDim
public javafx.scene.paint.Color getTertiaryFixedDim() -
getOnTertiaryFixed
public javafx.scene.paint.Color getOnTertiaryFixed() -
getOnTertiaryFixedVariant
public javafx.scene.paint.Color getOnTertiaryFixedVariant() -
getError
public javafx.scene.paint.Color getError() -
getOnError
public javafx.scene.paint.Color getOnError() -
getErrorContainer
public javafx.scene.paint.Color getErrorContainer() -
getOnErrorContainer
public javafx.scene.paint.Color getOnErrorContainer() -
getSurface
public javafx.scene.paint.Color getSurface() -
getOnSurface
public javafx.scene.paint.Color getOnSurface() -
getSurfaceDim
public javafx.scene.paint.Color getSurfaceDim() -
getSurfaceBright
public javafx.scene.paint.Color getSurfaceBright() -
getSurfaceContainerLowest
public javafx.scene.paint.Color getSurfaceContainerLowest() -
getSurfaceContainerLow
public javafx.scene.paint.Color getSurfaceContainerLow() -
getSurfaceContainer
public javafx.scene.paint.Color getSurfaceContainer() -
getSurfaceContainerHigh
public javafx.scene.paint.Color getSurfaceContainerHigh() -
getSurfaceContainerHighest
public javafx.scene.paint.Color getSurfaceContainerHighest() -
getSurfaceVariant
public javafx.scene.paint.Color getSurfaceVariant() -
getOnSurfaceVariant
public javafx.scene.paint.Color getOnSurfaceVariant() -
getBackground
public javafx.scene.paint.Color getBackground() -
getOnBackground
public javafx.scene.paint.Color getOnBackground() -
getOutline
public javafx.scene.paint.Color getOutline() -
getOutlineVariant
public javafx.scene.paint.Color getOutlineVariant() -
getShadow
public javafx.scene.paint.Color getShadow() -
getScrim
public javafx.scene.paint.Color getScrim() -
getInverseSurface
public javafx.scene.paint.Color getInverseSurface() -
getInverseOnSurface
public javafx.scene.paint.Color getInverseOnSurface() -
getInversePrimary
public javafx.scene.paint.Color getInversePrimary() -
getSurfaceTint
public javafx.scene.paint.Color getSurfaceTint() -
toStyleSheet
-
toStyleSheet
-
hashCode
-
equals
-
toString
-