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;
}
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() });
}
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);
}
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);
}
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);
}
Aggregations