Example usage for org.apache.poi.xssf.model ThemesTable getThemeColor

List of usage examples for org.apache.poi.xssf.model ThemesTable getThemeColor

Introduction

In this page you can find the example usage for org.apache.poi.xssf.model ThemesTable getThemeColor.

Prototype

@Override
public XSSFColor getThemeColor(int idx) 

Source Link

Document

Convert a theme "index" (as used by fonts etc) into a color.

Usage

From source file:org.tiefaces.components.websheet.utility.ColorUtility.java

License:MIT License

/**
 * Get xcolor with color schema name. Normally the names are accent1 to 7.
 * Sometimes also have lumOff/lumMod/alphaInt setting.
 * //from   w  w  w .j a v a 2 s. co m
 * @param colorSchema
 *            color schema
 * @param preTint
 *            tint
 * @param ctsColor
 *            ctsColor instance.
 * @param themeTable
 *            themeTable.
 * @return xcolor.
 */
private static XColor getXColorWithSchema(final String colorSchema, final double preTint,
        final CTSchemeColor ctsColor, final ThemesTable themeTable) {
    int colorIndex = getThemeIndexFromName(colorSchema);
    if (colorIndex < 0) {
        return null;
    }
    XSSFColor bcolor = themeTable.getThemeColor(colorIndex);
    if (bcolor == null) {
        return null;
    }
    int lumOff = 0;
    int lumMod = 0;
    int alphaInt = 0;
    if (ctsColor != null) {
        try {
            lumOff = ctsColor.getLumOffArray(0).getVal();
        } catch (Exception ex) {
            LOG.log(Level.FINE, "No lumOff entry", ex);
        }
        try {
            lumMod = ctsColor.getLumModArray(0).getVal();
        } catch (Exception ex) {
            LOG.log(Level.FINE, "No lumMod entry", ex);
        }
        try {
            alphaInt = ctsColor.getAlphaArray(0).getVal();
        } catch (Exception ex) {
            LOG.log(Level.FINE, "No alpha entry", ex);
        }
    }
    return assembleXcolor(bcolor, preTint, lumOff, lumMod, alphaInt);
}