Search in sources :

Example 6 with CTSolidColorFillProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties 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 7 with CTSolidColorFillProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties 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 8 with CTSolidColorFillProperties

use of org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties 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)

Example 9 with CTSolidColorFillProperties

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

the class XSLFBackground method setFillColor.

public void setFillColor(Color color) {
    CTBackgroundProperties bgPr = getBgPr(true);
    if (color == null) {
        if (bgPr.isSetSolidFill()) {
            bgPr.unsetSolidFill();
        }
        if (!bgPr.isSetNoFill()) {
            bgPr.addNewNoFill();
        }
    } else {
        if (bgPr.isSetNoFill()) {
            bgPr.unsetNoFill();
        }
        CTSolidColorFillProperties fill = bgPr.isSetSolidFill() ? bgPr.getSolidFill() : bgPr.addNewSolidFill();
        XSLFColor col = new XSLFColor(fill, getSheet().getTheme(), fill.getSchemeClr());
        col.setColor(color);
    }
}
Also used : CTBackgroundProperties(org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)

Example 10 with CTSolidColorFillProperties

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

the class XSSFSimpleShape method prototype.

/**
     * Prototype with the default structure of a new auto-shape.
     */
protected static CTShape prototype() {
    if (prototype == null) {
        CTShape shape = CTShape.Factory.newInstance();
        CTShapeNonVisual nv = shape.addNewNvSpPr();
        CTNonVisualDrawingProps nvp = nv.addNewCNvPr();
        nvp.setId(1);
        nvp.setName("Shape 1");
        nv.addNewCNvSpPr();
        CTShapeProperties sp = shape.addNewSpPr();
        CTTransform2D t2d = sp.addNewXfrm();
        CTPositiveSize2D p1 = t2d.addNewExt();
        p1.setCx(0);
        p1.setCy(0);
        CTPoint2D p2 = t2d.addNewOff();
        p2.setX(0);
        p2.setY(0);
        CTPresetGeometry2D geom = sp.addNewPrstGeom();
        geom.setPrst(STShapeType.RECT);
        geom.addNewAvLst();
        CTTextBody body = shape.addNewTxBody();
        CTTextBodyProperties bodypr = body.addNewBodyPr();
        bodypr.setAnchor(STTextAnchoringType.T);
        bodypr.setRtlCol(false);
        CTTextParagraph p = body.addNewP();
        p.addNewPPr().setAlgn(STTextAlignType.L);
        CTTextCharacterProperties endPr = p.addNewEndParaRPr();
        endPr.setLang("en-US");
        endPr.setSz(1100);
        CTSolidColorFillProperties scfpr = endPr.addNewSolidFill();
        scfpr.addNewSrgbClr().setVal(new byte[] { 0, 0, 0 });
        body.addNewLstStyle();
        prototype = shape;
    }
    return prototype;
}
Also used : CTShape(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShape) CTShapeNonVisual(org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTShapeNonVisual)

Aggregations

CTSolidColorFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)13 CTLineProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTLineProperties)5 CTSRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSRgbColor)5 CTTextCharacterProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties)4 CTShapeProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTShapeProperties)3 Color (java.awt.Color)2 CTTableCellProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTTableCellProperties)2 CTBackgroundProperties (org.openxmlformats.schemas.presentationml.x2006.main.CTBackgroundProperties)2 SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)1 Internal (org.apache.poi.util.Internal)1 XSLFFillProperties (org.apache.poi.xslf.usermodel.XSLFPropertiesDelegate.XSLFFillProperties)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CTBlipFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTBlipFillProperties)1 CTFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTFillProperties)1 CTGradientFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGradientFillProperties)1 CTGroupFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTGroupFillProperties)1 CTNoFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTNoFillProperties)1 CTPatternFillProperties (org.openxmlformats.schemas.drawingml.x2006.main.CTPatternFillProperties)1 CTPositiveFixedPercentage (org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveFixedPercentage)1 CTScRgbColor (org.openxmlformats.schemas.drawingml.x2006.main.CTScRgbColor)1