Package io.keikai.axyra.sheets.style
Class Theme
java.lang.Object
io.keikai.axyra.sheets.style.Theme
An immutable workbook theme: the 12-slot color scheme plus the major
(heading) and minor (body) font names.
Color.theme(int) references
resolve against these colors. Read it with Workbook.theme(), which
returns null when the workbook has no theme. Write it with
Workbook.setTheme(Theme).
Color slots are six-digit hex tokens without a leading #, e.g.
"4472C4". A system color in the source file (<a:sysClr>)
reads back as its last resolved value: "000000" for windowText,
"FFFFFF" for window. color(Slot) returns the raw token and
rgb(Slot) the parsed Color.
The slot order is the theme-file order (Theme.Slot). It differs from the
index that Color.theme(int) takes: there, 0 is light 1 and 1 is
dark 1.
Theme t = workbook.theme().toBuilder()
.color(Theme.Slot.ACCENT1, Color.rgb(0x1F, 0x4E, 0x79))
.build();
workbook.setTheme(t);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic enumThe 12 theme color slots, in ECMA-376<a:clrScheme>order. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Theme.Builderbuilder()A builder with every color slot unset and the fonts "Calibri Light" (major) and "Calibri" (minor).color(Theme.Slot slot) The raw color token of a slot, e.g.String[]colors()The 12 raw color tokens inTheme.Slotorder.The major (heading) font name, e.g.The minor (body) font name, e.g.static ThemeBuilds a theme from raw tokens.rgb(Theme.Slot slot) The color of a slot as an RGBColor.A builder pre-loaded with this theme's colors and fonts, for changing a few slots.
-
Field Details
-
SLOT_COUNT
public static final int SLOT_COUNTNumber of color slots in a theme.- See Also:
-
-
Method Details
-
of
Builds a theme from raw tokens. Preferbuilder()in application code.- Parameters:
colors- the color tokens inTheme.Slotorder; a shorter array leaves the remaining slotsnull, a longer one is cut to 12, andnullleaves every slotnullmajorFont- the heading font name;nullbecomes""minorFont- the body font name;nullbecomes""- Returns:
- the theme
-
color
The raw color token of a slot, e.g."4472C4".- Parameters:
slot- the slot- Returns:
- the token, or
nullwhen the slot is unset
-
rgb
The color of a slot as an RGBColor.- Parameters:
slot- the slot- Returns:
- the color, or
nullwhen the slot is unset, empty or not a hex token
-
majorFont
The major (heading) font name, e.g."Calibri Light"; nevernull. -
minorFont
The minor (body) font name, e.g."Calibri"; nevernull. Cells whose font uses the minor scheme render in it. -
colors
The 12 raw color tokens inTheme.Slotorder.- Returns:
- a new array on each call; entries may be
null
-
toBuilder
A builder pre-loaded with this theme's colors and fonts, for changing a few slots.- Returns:
- a new builder
-
builder
A builder with every color slot unset and the fonts "Calibri Light" (major) and "Calibri" (minor). Set all 12 slots beforeWorkbook.setTheme: an unset slot is saved as an empty, invalid color. To change a few slots, start fromworkbook.theme().toBuilder().- Returns:
- a new builder
-