use of org.apache.poi.sl.usermodel.PaintStyle in project poi by apache.
the class TestXSLFTheme method slide8.
void slide8(XSLFSlide slide) {
PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
assertTrue(fs instanceof TexturePaint);
}
use of org.apache.poi.sl.usermodel.PaintStyle in project poi by apache.
the class XSLFShape method getFillPaint.
protected PaintStyle getFillPaint() {
final XSLFTheme theme = getSheet().getTheme();
final boolean hasPlaceholder = getPlaceholder() != null;
PropertyFetcher<PaintStyle> fetcher = new PropertyFetcher<PaintStyle>() {
public boolean fetch(XSLFShape shape) {
XSLFFillProperties fp = XSLFPropertiesDelegate.getFillDelegate(shape.getShapeProperties());
if (fp == null) {
return false;
}
if (fp.isSetNoFill()) {
setValue(null);
return true;
}
PackagePart pp = shape.getSheet().getPackagePart();
PaintStyle paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
if (paint != null) {
setValue(paint);
return true;
}
CTShapeStyle style = shape.getSpStyle();
if (style != null) {
fp = XSLFPropertiesDelegate.getFillDelegate(style.getFillRef());
paint = selectPaint(fp, null, pp, theme, hasPlaceholder);
}
if (paint != null) {
setValue(paint);
return true;
}
return false;
}
};
fetchShapeProperty(fetcher);
return fetcher.getValue();
}
use of org.apache.poi.sl.usermodel.PaintStyle in project poi by apache.
the class TestBugs method bug55983.
@Test
public void bug55983() throws IOException {
HSLFSlideShow ppt1 = new HSLFSlideShow();
HSLFSlide sl = ppt1.createSlide();
sl.getBackground().getFill().setForegroundColor(Color.blue);
HSLFFreeformShape fs = sl.createFreeform();
Ellipse2D.Double el = new Ellipse2D.Double(0, 0, 300, 200);
fs.setAnchor(new Rectangle2D.Double(100, 100, 300, 200));
fs.setPath(new Path2D.Double(el));
Color cExp = new Color(50, 100, 150, 200);
fs.setFillColor(cExp);
HSLFSlideShow ppt2 = HSLFTestDataSamples.writeOutAndReadBack(ppt1);
ppt1.close();
sl = ppt2.getSlides().get(0);
fs = (HSLFFreeformShape) sl.getShapes().get(0);
Color cAct = fs.getFillColor();
assertEquals(cExp.getRed(), cAct.getRed());
assertEquals(cExp.getGreen(), cAct.getGreen());
assertEquals(cExp.getBlue(), cAct.getBlue());
assertEquals(cExp.getAlpha(), cAct.getAlpha(), 1);
PaintStyle ps = fs.getFillStyle().getPaint();
assertTrue(ps instanceof SolidPaint);
ColorStyle cs = ((SolidPaint) ps).getSolidColor();
cAct = cs.getColor();
assertEquals(cExp.getRed(), cAct.getRed());
assertEquals(cExp.getGreen(), cAct.getGreen());
assertEquals(cExp.getBlue(), cAct.getBlue());
assertEquals(255, cAct.getAlpha());
assertEquals(cExp.getAlpha() * 100000. / 255., cs.getAlpha(), 1);
ppt2.close();
}
use of org.apache.poi.sl.usermodel.PaintStyle in project poi by apache.
the class TestBugs method bug45124.
@Test
public void bug45124() throws IOException {
SlideShow<?, ?> ppt = open("bug45124.ppt");
Slide<?, ?> slide1 = ppt.getSlides().get(1);
TextBox<?, ?> res = slide1.createTextBox();
res.setAnchor(new java.awt.Rectangle(60, 150, 700, 100));
res.setText("I am italic-false, bold-true inserted text");
TextParagraph<?, ?, ?> tp = res.getTextParagraphs().get(0);
TextRun rt = tp.getTextRuns().get(0);
rt.setItalic(false);
assertTrue(rt.isBold());
tp.setBulletStyle(Color.red, 'A');
SlideShow<?, ?> ppt2 = HSLFTestDataSamples.writeOutAndReadBack((HSLFSlideShow) ppt);
ppt.close();
res = (TextBox<?, ?>) ppt2.getSlides().get(1).getShapes().get(1);
tp = res.getTextParagraphs().get(0);
rt = tp.getTextRuns().get(0);
assertFalse(rt.isItalic());
assertTrue(rt.isBold());
PaintStyle ps = tp.getBulletStyle().getBulletFontColor();
assertTrue(ps instanceof SolidPaint);
Color actColor = DrawPaint.applyColorTransform(((SolidPaint) ps).getSolidColor());
assertEquals(Color.red, actColor);
assertEquals("A", tp.getBulletStyle().getBulletCharacter());
ppt2.close();
}
use of org.apache.poi.sl.usermodel.PaintStyle in project tephra by heisedebaise.
the class PptxImpl method fillTexture.
private void fillTexture(JSONArray elements, JSONObject element, PaintStyle paintStyle, StreamWriter streamWriter) {
PaintStyle.TexturePaint texturePaint = (PaintStyle.TexturePaint) paintStyle;
try {
InputStream inputStream = texturePaint.getImageData();
JSONObject object = new JSONObject();
object.putAll(element);
object.put(Parser.TYPE_IMAGE, streamWriter.write(texturePaint.getContentType(), "", inputStream));
elements.add(object);
inputStream.close();
} catch (IOException e) {
logger.warn(e, "保存图片[{}]流数据时发生异常!", texturePaint.getContentType());
}
}
Aggregations