use of org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme in project poi by apache.
the class ThemesTable method getThemeColor.
/**
* Convert a theme "index" (as used by fonts etc) into a color.
* @param idx A theme "index"
* @return The mapped XSSFColor, or null if not mapped.
*/
public XSSFColor getThemeColor(int idx) {
// Theme color references are NOT positional indices into the color scheme,
// i.e. these keys are NOT the same as the order in which theme colors appear
// in theme1.xml. They are keys to a mapped color.
CTColorScheme colorScheme = theme.getTheme().getThemeElements().getClrScheme();
CTColor ctColor;
switch(ThemeElement.byId(idx)) {
case LT1:
ctColor = colorScheme.getLt1();
break;
case DK1:
ctColor = colorScheme.getDk1();
break;
case LT2:
ctColor = colorScheme.getLt2();
break;
case DK2:
ctColor = colorScheme.getDk2();
break;
case ACCENT1:
ctColor = colorScheme.getAccent1();
break;
case ACCENT2:
ctColor = colorScheme.getAccent2();
break;
case ACCENT3:
ctColor = colorScheme.getAccent3();
break;
case ACCENT4:
ctColor = colorScheme.getAccent4();
break;
case ACCENT5:
ctColor = colorScheme.getAccent5();
break;
case ACCENT6:
ctColor = colorScheme.getAccent6();
break;
case HLINK:
ctColor = colorScheme.getHlink();
break;
case FOLHLINK:
ctColor = colorScheme.getFolHlink();
break;
default:
return null;
}
byte[] rgb = null;
if (ctColor.isSetSrgbClr()) {
// Color is a regular one
rgb = ctColor.getSrgbClr().getVal();
} else if (ctColor.isSetSysClr()) {
// Color is a tint of white or black
rgb = ctColor.getSysClr().getLastClr();
} else {
return null;
}
return new XSSFColor(rgb, colorMap);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme in project poi by apache.
the class XSLFTheme method initialize.
private void initialize() {
CTBaseStyles elems = _theme.getThemeElements();
CTColorScheme scheme = elems.getClrScheme();
// The color scheme is responsible for defining a list of twelve colors.
_schemeColors = new HashMap<String, CTColor>(12);
for (XmlObject o : scheme.selectPath("*")) {
CTColor c = (CTColor) o;
String name = c.getDomNode().getLocalName();
_schemeColors.put(name, c);
}
}
Aggregations