Search in sources :

Example 21 with CTColor

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.

the class XSSFCellFill method setFillForegroundColor.

/**
     * Set the foreground fill color as a indexed color value
     *
     * @param index - the color to use
     */
public void setFillForegroundColor(int index) {
    CTPatternFill ptrn = ensureCTPatternFill();
    CTColor ctColor = ptrn.isSetFgColor() ? ptrn.getFgColor() : ptrn.addNewFgColor();
    ctColor.setIndexed(index);
}
Also used : CTPatternFill(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)

Example 22 with CTColor

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.

the class XSSFCellFill method getFillBackgroundColor.

/**
     * Get the background fill color.
     *
     * @return fill color, null if color is not set
     */
public XSSFColor getFillBackgroundColor() {
    CTPatternFill ptrn = _fill.getPatternFill();
    if (ptrn == null)
        return null;
    CTColor ctColor = ptrn.getBgColor();
    return ctColor == null ? null : new XSSFColor(ctColor, _indexedColorMap);
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) CTPatternFill(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)

Example 23 with CTColor

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor in project poi by apache.

the class XSSFCellFill method getFillForegroundColor.

/**
     * Get the foreground fill color.
     *
     * @return XSSFColor - foreground color. null if color is not set
     */
public XSSFColor getFillForegroundColor() {
    CTPatternFill ptrn = _fill.getPatternFill();
    if (ptrn == null)
        return null;
    CTColor ctColor = ptrn.getFgColor();
    return ctColor == null ? null : new XSSFColor(ctColor, _indexedColorMap);
}
Also used : XSSFColor(org.apache.poi.xssf.usermodel.XSSFColor) CTPatternFill(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)

Example 24 with CTColor

use of org.openxmlformats.schemas.wordprocessingml.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);
}
Also used : CTPatternFill(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)

Example 25 with CTColor

use of org.openxmlformats.schemas.wordprocessingml.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());
}
Also used : CTFont(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont) CTColor(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor) Test(org.junit.Test)

Aggregations

CTColor (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor)27 Test (org.junit.Test)12 CTColor (org.openxmlformats.schemas.drawingml.x2006.main.CTColor)10 CTPatternFill (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill)6 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)5 Color (java.awt.Color)4 XSSFColor (org.apache.poi.xssf.usermodel.XSSFColor)4 CTHslColor (org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor)4 CTSystemColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor)4 CTFont (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont)4 PresetColor (org.apache.poi.sl.usermodel.PresetColor)3 XmlObject (org.apache.xmlbeans.XmlObject)2 CTColorScheme (org.openxmlformats.schemas.drawingml.x2006.main.CTColorScheme)2 CTFill (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill)2 CTColor (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTColor)2 CTRPr (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRPr)2 FileOutputStream (java.io.FileOutputStream)1 LinkedHashMap (java.util.LinkedHashMap)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1