use of org.openxmlformats.schemas.drawingml.x2006.main.CTColor in project poi by apache.
the class XWPFRun method setColor.
/**
* Set text color.
*
* @param rgbStr - the desired color, in the hex form "RRGGBB".
*/
public void setColor(String rgbStr) {
CTRPr pr = run.isSetRPr() ? run.getRPr() : run.addNewRPr();
CTColor color = pr.isSetColor() ? pr.getColor() : pr.addNewColor();
color.setVal(rgbStr);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTColor in project poi by apache.
the class XSSFCellFill method setFillBackgroundColor.
/**
* Set the background fill color represented as a indexed color value.
*
* @param index
*/
public void setFillBackgroundColor(int index) {
CTPatternFill ptrn = ensureCTPatternFill();
CTColor ctColor = ptrn.isSetBgColor() ? ptrn.getBgColor() : ptrn.addNewBgColor();
ctColor.setIndexed(index);
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTColor in project poi by apache.
the class TestXSSFFont method testThemeColor.
@Test
public void testThemeColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setTheme(1);
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(ctFont.getColorArray(0).getTheme(), xssfFont.getThemeColor());
xssfFont.setThemeColor(IndexedColors.RED.getIndex());
assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getTheme());
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTColor in project poi by apache.
the class TestXSSFFont method testColor.
@Test
public void testColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(IndexedColors.BLACK.getIndex(), xssfFont.getColor());
xssfFont.setColor(IndexedColors.RED.getIndex());
assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
}
use of org.openxmlformats.schemas.drawingml.x2006.main.CTColor in project poi by apache.
the class TestXSSFFont method testRgbColor.
@Test
public void testRgbColor() {
CTFont ctFont = CTFont.Factory.newInstance();
CTColor color = ctFont.addNewColor();
color.setRgb(Integer.toHexString(0xFFFFFF).getBytes(LocaleUtil.CHARSET_1252));
ctFont.setColorArray(0, color);
XSSFFont xssfFont = new XSSFFont(ctFont);
assertEquals(ctFont.getColorArray(0).getRgb()[0], xssfFont.getXSSFColor().getRGB()[0]);
assertEquals(ctFont.getColorArray(0).getRgb()[1], xssfFont.getXSSFColor().getRGB()[1]);
assertEquals(ctFont.getColorArray(0).getRgb()[2], xssfFont.getXSSFColor().getRGB()[2]);
assertEquals(ctFont.getColorArray(0).getRgb()[3], xssfFont.getXSSFColor().getRGB()[3]);
xssfFont.setColor((short) 23);
byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
color.setRgb(bytes);
XSSFColor newColor = new XSSFColor(color, null);
xssfFont.setColor(newColor);
assertEquals(ctFont.getColorArray(0).getRgb()[2], newColor.getRGB()[2]);
assertArrayEquals(bytes, xssfFont.getXSSFColor().getRGB());
assertEquals(0, xssfFont.getColor());
}
Aggregations