Search in sources :

Example 1 with CTSRgbColor

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor in project poi by apache.

the class XSLFTextParagraph method setBulletFontColor.

/**
     * Set the color to be used on bullet characters within a given paragraph.
     *
     * @param color the bullet color
     */
public void setBulletFontColor(PaintStyle color) {
    if (!(color instanceof SolidPaint)) {
        throw new IllegalArgumentException("Currently XSLF only supports SolidPaint");
    }
    // TODO: implement setting bullet color to null
    SolidPaint sp = (SolidPaint) color;
    Color col = DrawPaint.applyColorTransform(sp.getSolidColor());
    CTTextParagraphProperties pr = _p.isSetPPr() ? _p.getPPr() : _p.addNewPPr();
    CTColor c = pr.isSetBuClr() ? pr.getBuClr() : pr.addNewBuClr();
    CTSRgbColor clr = c.isSetSrgbClr() ? c.getSrgbClr() : c.addNewSrgbClr();
    clr.setVal(new byte[] { (byte) col.getRed(), (byte) col.getGreen(), (byte) col.getBlue() });
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) CTColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColor) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTTextParagraphProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextParagraphProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTColor(org.openxmlformats.schemas.drawingml.x2006.main.CTColor)

Example 2 with CTSRgbColor

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor in project poi by apache.

the class XSSFShape method setFillColor.

@Override
public void setFillColor(int red, int green, int blue) {
    CTShapeProperties props = getShapeProperties();
    CTSolidColorFillProperties fill = props.isSetSolidFill() ? props.getSolidFill() : props.addNewSolidFill();
    CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
    rgb.setVal(new byte[] { (byte) red, (byte) green, (byte) blue });
    fill.setSrgbClr(rgb);
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 3 with CTSRgbColor

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor in project poi by apache.

the class XSSFShape method setLineStyleColor.

@Override
public void setLineStyleColor(int red, int green, int blue) {
    CTShapeProperties props = getShapeProperties();
    CTLineProperties ln = props.isSetLn() ? props.getLn() : props.addNewLn();
    CTSolidColorFillProperties fill = ln.isSetSolidFill() ? ln.getSolidFill() : ln.addNewSolidFill();
    CTSRgbColor rgb = CTSRgbColor.Factory.newInstance();
    rgb.setVal(new byte[] { (byte) red, (byte) green, (byte) blue });
    fill.setSrgbClr(rgb);
}
Also used : CTShapeProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties) CTLineProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 4 with CTSRgbColor

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor in project poi by apache.

the class XSSFTextRun method getFontColor.

public Color getFontColor() {
    CTTextCharacterProperties rPr = getRPr();
    if (rPr.isSetSolidFill()) {
        CTSolidColorFillProperties fill = rPr.getSolidFill();
        if (fill.isSetSrgbClr()) {
            CTSRgbColor clr = fill.getSrgbClr();
            byte[] rgb = clr.getVal();
            return new Color(0xFF & rgb[0], 0xFF & rgb[1], 0xFF & rgb[2]);
        }
    }
    return new Color(0, 0, 0);
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) Color(java.awt.Color) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Example 5 with CTSRgbColor

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor in project poi by apache.

the class XSSFTextRun method setFontColor.

public void setFontColor(Color color) {
    CTTextCharacterProperties rPr = getRPr();
    CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
    CTSRgbColor clr = fill.isSetSrgbClr() ? fill.getSrgbClr() : fill.addNewSrgbClr();
    clr.setVal(new byte[] { (byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue() });
    if (fill.isSetHslClr())
        fill.unsetHslClr();
    if (fill.isSetPrstClr())
        fill.unsetPrstClr();
    if (fill.isSetSchemeClr())
        fill.unsetSchemeClr();
    if (fill.isSetScrgbClr())
        fill.unsetScrgbClr();
    if (fill.isSetSysClr())
        fill.unsetSysClr();
}
Also used : CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties) CTSRgbColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)

Aggregations

CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)8 CTSolidColorFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)5 Color (java.awt.Color)3 CTColor (org.openxmlformats.schemas.drawingml.x2006.main.CTColor)3 CTScRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor)2 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)2 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)2 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 PresetColor (org.apache.poi.sl.usermodel.PresetColor)1 Internal (org.apache.poi.util.Internal)1 XmlObject (org.apache.xmlbeans.XmlObject)1 Test (org.junit.Test)1 CTFontReference (org.openxmlformats.schemas.drawingml.x2006.main.CTFontReference)1 CTHslColor (org.openxmlformats.schemas.drawingml.x2006.main.CTHslColor)1 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)1 CTPositiveFixedPercentage (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveFixedPercentage)1 CTPresetColor (org.openxmlformats.schemas.drawingml.x2006.main.CTPresetColor)1 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)1 CTSystemColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSystemColor)1