use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor 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.wordprocessingml.x2006.main.CTColor in project poi by apache.
the class SXSSFSheet method setTabColor.
/**
* Set background color of the sheet tab
*
* @param colorIndex the indexed color to set, must be a constant from {@link IndexedColors}
*/
public void setTabColor(int colorIndex) {
CTWorksheet ct = _sh.getCTWorksheet();
CTSheetPr pr = ct.getSheetPr();
if (pr == null)
pr = ct.addNewSheetPr();
CTColor color = CTColor.Factory.newInstance();
color.setIndexed(colorIndex);
pr.setTabColor(color);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.
the class XSSFBorderFormatting method setVerticalBorderColor.
public void setVerticalBorderColor(short color) {
CTColor ctColor = CTColor.Factory.newInstance();
ctColor.setIndexed(color);
setVerticalBorderColor(ctColor);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.
the class XSSFBorderFormatting method setBottomBorderColor.
@Override
public void setBottomBorderColor(short color) {
CTColor ctColor = CTColor.Factory.newInstance();
ctColor.setIndexed(color);
setBottomBorderColor(ctColor);
}
use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.
the class XSSFBorderFormatting method setLeftBorderColor.
@Override
public void setLeftBorderColor(short color) {
CTColor ctColor = CTColor.Factory.newInstance();
ctColor.setIndexed(color);
setLeftBorderColor(ctColor);
}
Aggregations