com.aspose.words
Class ThemeColor

java.lang.Object
    extended by com.aspose.words.ThemeColor

public class ThemeColor 
extends java.lang.Object

Utility class containing constants. Specifies the theme colors for document themes.

To learn more, visit the Working with Styles and Themes documentation article.

The specified theme color is a reference to one of the predefined theme colors, located in the document's Theme part, which allows color information to be set centrally in the document.

Example:

Shows how to create and use themed style.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.writeln();

// Create some style with theme font properties.
Style style = doc.getStyles().add(StyleType.PARAGRAPH, "ThemedStyle");
style.getFont().setThemeFont(ThemeFont.MAJOR);
style.getFont().setThemeColor(ThemeColor.ACCENT_5);
style.getFont().setTintAndShade(0.3);

builder.getParagraphFormat().setStyleName("ThemedStyle");
builder.writeln("Text with themed style");

Example:

Shows how to work with theme fonts and colors.
Document doc = new Document();

// Define fonts for languages uses by default.
doc.getTheme().getMinorFonts().setLatin("Algerian");
doc.getTheme().getMinorFonts().setEastAsian("Aharoni");
doc.getTheme().getMinorFonts().setComplexScript("Andalus");

Font font = doc.getStyles().get("Normal").getFont();
System.out.println(MessageFormat.format("Originally the Normal style theme color is: {0} and RGB color is: {1}\n", font.getThemeColor(), font.getColor()));

// We can use theme font and color instead of default values.
font.setThemeFont(ThemeFont.MINOR);
font.setThemeColor(ThemeColor.ACCENT_2);

Assert.assertEquals(ThemeFont.MINOR, font.getThemeFont());
Assert.assertEquals("Algerian", font.getName());

Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontAscii());
Assert.assertEquals("Algerian", font.getNameAscii());

Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontBi());
Assert.assertEquals("Andalus", font.getNameBi());

Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontFarEast());
Assert.assertEquals("Aharoni", font.getNameFarEast());

Assert.assertEquals(ThemeFont.MINOR, font.getThemeFontOther());
Assert.assertEquals("Algerian", font.getNameOther());

Assert.assertEquals(ThemeColor.ACCENT_2, font.getThemeColor());
Assert.assertEquals(0, font.getColor().getRGB());

// There are several ways of reset them font and color.
// 1 -  By setting ThemeFont.None/ThemeColor.None:
font.setThemeFont(ThemeFont.NONE);
font.setThemeColor(ThemeColor.NONE);

Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
Assert.assertEquals("Algerian", font.getName());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
Assert.assertEquals("Algerian", font.getNameAscii());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
Assert.assertEquals("Andalus", font.getNameBi());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
Assert.assertEquals("Aharoni", font.getNameFarEast());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
Assert.assertEquals("Algerian", font.getNameOther());

Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
Assert.assertEquals(0, font.getColor().getRGB());

// 2 -  By setting non-theme font/color names:
font.setName("Arial");
font.setColor(Color.BLUE);

Assert.assertEquals(ThemeFont.NONE, font.getThemeFont());
Assert.assertEquals("Arial", font.getName());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontAscii());
Assert.assertEquals("Arial", font.getNameAscii());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontBi());
Assert.assertEquals("Arial", font.getNameBi());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontFarEast());
Assert.assertEquals("Arial", font.getNameFarEast());

Assert.assertEquals(ThemeFont.NONE, font.getThemeFontOther());
Assert.assertEquals("Arial", font.getNameOther());

Assert.assertEquals(ThemeColor.NONE, font.getThemeColor());
Assert.assertEquals(Color.BLUE.getRGB(), font.getColor().getRGB());

Field Summary
static final intNONE = -1
           No color.
static final intDARK_1 = 0
           Dark main color 1.
static final intLIGHT_1 = 1
           Light main color 1.
static final intDARK_2 = 2
           Dark main color 2.
static final intLIGHT_2 = 3
           Light main color 2.
static final intACCENT_1 = 4
           Accent color 1.
static final intACCENT_2 = 5
           Accent color 2.
static final intACCENT_3 = 6
           Accent color 3.
static final intACCENT_4 = 7
           Accent color 4.
static final intACCENT_5 = 8
           Accent color 5.
static final intACCENT_6 = 9
           Accent color 6.
static final intHYPERLINK = 10
           Hyperlink color.
static final intFOLLOWED_HYPERLINK = 11
           Followed hyperlink color.
static final intTEXT_1 = 12
           Text color 1.
static final intTEXT_2 = 13
           Text color 2.
static final intBACKGROUND_1 = 14
           Background color 1.
static final intBACKGROUND_2 = 15
           Background color 2.
 

Field Detail

NONE = -1

public static final int NONE
No color.

DARK_1 = 0

public static final int DARK_1
Dark main color 1.

LIGHT_1 = 1

public static final int LIGHT_1
Light main color 1.

DARK_2 = 2

public static final int DARK_2
Dark main color 2.

LIGHT_2 = 3

public static final int LIGHT_2
Light main color 2.

ACCENT_1 = 4

public static final int ACCENT_1
Accent color 1.

ACCENT_2 = 5

public static final int ACCENT_2
Accent color 2.

ACCENT_3 = 6

public static final int ACCENT_3
Accent color 3.

ACCENT_4 = 7

public static final int ACCENT_4
Accent color 4.

ACCENT_5 = 8

public static final int ACCENT_5
Accent color 5.

ACCENT_6 = 9

public static final int ACCENT_6
Accent color 6.

HYPERLINK = 10

public static final int HYPERLINK
Hyperlink color.

FOLLOWED_HYPERLINK = 11

public static final int FOLLOWED_HYPERLINK
Followed hyperlink color.

TEXT_1 = 12

public static final int TEXT_1
Text color 1.

TEXT_2 = 13

public static final int TEXT_2
Text color 2.

BACKGROUND_1 = 14

public static final int BACKGROUND_1
Background color 1.

BACKGROUND_2 = 15

public static final int BACKGROUND_2
Background color 2.

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.