use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class HSLFTextRun method setFontColor.
@Override
public void setFontColor(PaintStyle color) {
if (!(color instanceof SolidPaint)) {
throw new IllegalArgumentException("HSLF only supports solid paint");
}
// In PowerPont RGB bytes are swapped, as BGR
SolidPaint sp = (SolidPaint) color;
Color c = DrawPaint.applyColorTransform(sp.getSolidColor());
int rgb = new Color(c.getBlue(), c.getGreen(), c.getRed(), 254).getRGB();
setFontColor(rgb);
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class DrawSimpleShape method drawShadow.
protected void drawShadow(Graphics2D graphics, Collection<Outline> outlines, Paint fill, Paint line) {
Shadow<?, ?> shadow = getShape().getShadow();
if (shadow == null || (fill == null && line == null)) {
return;
}
SolidPaint shadowPaint = shadow.getFillStyle();
Color shadowColor = DrawPaint.applyColorTransform(shadowPaint.getSolidColor());
double shapeRotation = getShape().getRotation();
if (getShape().getFlipVertical()) {
shapeRotation += 180;
}
double angle = shadow.getAngle() - shapeRotation;
double dist = shadow.getDistance();
double dx = dist * Math.cos(Math.toRadians(angle));
double dy = dist * Math.sin(Math.toRadians(angle));
graphics.translate(dx, dy);
for (Outline o : outlines) {
java.awt.Shape s = o.getOutline();
Path p = o.getPath();
graphics.setRenderingHint(Drawable.GRADIENT_SHAPE, s);
graphics.setPaint(shadowColor);
if (fill != null && p.isFilled()) {
graphics.fill(s);
} else if (line != null && p.isStroked()) {
graphics.draw(s);
}
}
graphics.translate(-dx, -dy);
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class TestXSLFTheme method slide4.
void slide4(XSLFSlide slide) {
PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
assertTrue(fs instanceof GradientPaint);
XSLFTextShape sh1 = (XSLFTextShape) getShape(slide, "Rectangle 4");
XSLFTextRun run1 = sh1.getTextParagraphs().get(0).getTextRuns().get(0);
assertTrue(sameColor(Color.white, run1.getFontColor()));
assertEquals(new Color(148, 198, 0), sh1.getFillColor());
// solid fill
assertTrue(sh1.getFillStyle().getPaint() instanceof SolidPaint);
XSLFTextShape sh2 = (XSLFTextShape) getShape(slide, "Title 3");
XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
assertTrue(sameColor(new Color(148, 198, 0), run2.getFontColor()));
// no fill
assertNull(sh2.getFillColor());
assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class HSLFTextRun method getFontColor.
/**
* @return font color as PaintStyle
*/
@Override
public SolidPaint getFontColor() {
TextProp tp = getTextParagraph().getPropVal(characterStyle, masterStyle, "font.color");
if (tp == null) {
return null;
}
Color color = HSLFTextParagraph.getColorFromColorIndexStruct(tp.getValue(), parentParagraph.getSheet());
SolidPaint ps = DrawPaint.createSolidPaint(color);
return ps;
}
use of org.apache.poi.sl.usermodel.PaintStyle.SolidPaint in project poi by apache.
the class HSLFTextParagraph method getBulletStyle.
@Override
public BulletStyle getBulletStyle() {
if (!isBullet() && getAutoNumberingScheme() == null) {
return null;
}
return new BulletStyle() {
@Override
public String getBulletCharacter() {
Character chr = HSLFTextParagraph.this.getBulletChar();
return (chr == null || chr == 0) ? "" : "" + chr;
}
@Override
public String getBulletFont() {
return HSLFTextParagraph.this.getBulletFont();
}
@Override
public Double getBulletFontSize() {
return HSLFTextParagraph.this.getBulletSize();
}
@Override
public void setBulletFontColor(Color color) {
setBulletFontColor(DrawPaint.createSolidPaint(color));
}
@Override
public void setBulletFontColor(PaintStyle color) {
if (!(color instanceof SolidPaint)) {
throw new IllegalArgumentException("HSLF only supports SolidPaint");
}
SolidPaint sp = (SolidPaint) color;
Color col = DrawPaint.applyColorTransform(sp.getSolidColor());
HSLFTextParagraph.this.setBulletColor(col);
}
@Override
public PaintStyle getBulletFontColor() {
Color col = HSLFTextParagraph.this.getBulletColor();
return DrawPaint.createSolidPaint(col);
}
@Override
public AutoNumberingScheme getAutoNumberingScheme() {
return HSLFTextParagraph.this.getAutoNumberingScheme();
}
@Override
public Integer getAutoNumberingStartAt() {
return HSLFTextParagraph.this.getAutoNumberingStartAt();
}
};
}
Aggregations