Search in sources :

Example 1 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class XSLFShadow method getFillColor.

/**
     * @return the color of this shadow. 
     * Depending whether the parent shape is filled or stroked, this color is used to fill or stroke this shadow
     */
public Color getFillColor() {
    SolidPaint ps = getFillStyle();
    if (ps == null)
        return null;
    Color col = DrawPaint.applyColorTransform(ps.getSolidColor());
    return col;
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)

Example 2 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint 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 3 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class XSLFTextRun method setFontColor.

@Override
public void setFontColor(PaintStyle color) {
    if (!(color instanceof SolidPaint)) {
        throw new IllegalArgumentException("Currently only SolidPaint is supported!");
    }
    SolidPaint sp = (SolidPaint) color;
    Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
    CTTextCharacterProperties rPr = getRPr(true);
    CTSolidColorFillProperties fill = rPr.isSetSolidFill() ? rPr.getSolidFill() : rPr.addNewSolidFill();
    XSLFColor col = new XSLFColor(fill, getParentParagraph().getParentShape().getSheet().getTheme(), fill.getSchemeClr());
    col.setColor(c);
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color) CTSchemeColor(org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor) CTTextCharacterProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTTextCharacterProperties) CTSolidColorFillProperties(org.openxmlformats.schemas.drawingml.x2006.main.CTSolidColorFillProperties)

Example 4 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class TestXSLFBugs method checkColor.

private static void checkColor(Color expected, PaintStyle actualStyle) {
    assertTrue(actualStyle instanceof SolidPaint);
    SolidPaint ps = (SolidPaint) actualStyle;
    Color actual = DrawPaint.applyColorTransform(ps.getSolidColor());
    float[] expRGB = expected.getRGBComponents(null);
    float[] actRGB = actual.getRGBComponents(null);
    assertArrayEquals(expRGB, actRGB, 0.0001f);
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) Color(java.awt.Color)

Example 5 with SolidPaint

use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.

the class HSLFTextParagraph method getBulletColor.

/**
     * Returns the bullet color
     */
public Color getBulletColor() {
    TextProp tp = getPropVal(_paragraphStyle, _masterStyle, "bullet.color");
    boolean hasColor = getFlag(ParagraphFlagsTextProp.BULLET_HARDCOLOR_IDX);
    if (tp == null || !hasColor) {
        // if bullet color is undefined, return color of first run
        if (_runs.isEmpty()) {
            return null;
        }
        SolidPaint sp = _runs.get(0).getFontColor();
        if (sp == null) {
            return null;
        }
        return DrawPaint.applyColorTransform(sp.getSolidColor());
    }
    return getColorFromColorIndexStruct(tp.getValue(), _sheet);
}
Also used : SolidPaint(org.apache.poi.sl.usermodel.PaintStyle.SolidPaint) BitMaskTextProp(org.apache.poi.hslf.model.textproperties.BitMaskTextProp) TextProp(org.apache.poi.hslf.model.textproperties.TextProp) ParagraphFlagsTextProp(org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)

Aggregations

SolidPaint (org.apache.poi.sl.usermodel.PaintStyle.SolidPaint)14 Color (java.awt.Color)12 PaintStyle (org.apache.poi.sl.usermodel.PaintStyle)4 BitMaskTextProp (org.apache.poi.hslf.model.textproperties.BitMaskTextProp)2 TextProp (org.apache.poi.hslf.model.textproperties.TextProp)2 TestCommonSL.sameColor (org.apache.poi.sl.TestCommonSL.sameColor)2 ColorStyle (org.apache.poi.sl.usermodel.ColorStyle)2 GradientPaint (org.apache.poi.sl.usermodel.PaintStyle.GradientPaint)2 Test (org.junit.Test)2 CTSchemeColor (org.openxmlformats.schemas.drawingml.x2006.main.CTSchemeColor)2 LinearGradientPaint (java.awt.LinearGradientPaint)1 Paint (java.awt.Paint)1 RadialGradientPaint (java.awt.RadialGradientPaint)1 Ellipse2D (java.awt.geom.Ellipse2D)1 Path2D (java.awt.geom.Path2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 CharFlagsTextProp (org.apache.poi.hslf.model.textproperties.CharFlagsTextProp)1 ParagraphFlagsTextProp (org.apache.poi.hslf.model.textproperties.ParagraphFlagsTextProp)1 DrawPaint (org.apache.poi.sl.draw.DrawPaint)1 Outline (org.apache.poi.sl.draw.geom.Outline)1