use of org.apache.poi.sl.usermodel.PaintStyle.TexturePaint in project poi by apache.
the class TestXSLFBugs method bug55714.
@Test
public void bug55714() throws IOException {
XMLSlideShow srcPptx = XSLFTestDataSamples.openSampleDocument("pptx2svg.pptx");
XMLSlideShow newPptx = new XMLSlideShow();
XSLFSlide srcSlide = srcPptx.getSlides().get(0);
XSLFSlide newSlide = newPptx.createSlide();
XSLFSlideLayout srcSlideLayout = srcSlide.getSlideLayout();
XSLFSlideLayout newSlideLayout = newSlide.getSlideLayout();
newSlideLayout.importContent(srcSlideLayout);
XSLFSlideMaster srcSlideMaster = srcSlide.getSlideMaster();
XSLFSlideMaster newSlideMaster = newSlide.getSlideMaster();
newSlideMaster.importContent(srcSlideMaster);
newSlide.importContent(srcSlide);
XMLSlideShow rwPptx = XSLFTestDataSamples.writeOutAndReadBack(newPptx);
PaintStyle ps = rwPptx.getSlides().get(0).getBackground().getFillStyle().getPaint();
assertTrue(ps instanceof TexturePaint);
rwPptx.close();
newPptx.close();
srcPptx.close();
}
use of org.apache.poi.sl.usermodel.PaintStyle.TexturePaint in project poi by apache.
the class DrawPaint method getTexturePaint.
protected Paint getTexturePaint(TexturePaint fill, Graphics2D graphics) {
InputStream is = fill.getImageData();
if (is == null) {
return null;
}
assert (graphics != null);
ImageRenderer renderer = DrawPictureShape.getImageRenderer(graphics, fill.getContentType());
try {
try {
renderer.loadImage(is, fill.getContentType());
} finally {
is.close();
}
} catch (IOException e) {
LOG.log(POILogger.ERROR, "Can't load image data - using transparent color", e);
return null;
}
int alpha = fill.getAlpha();
if (0 <= alpha && alpha < 100000) {
renderer.setAlpha(alpha / 100000.f);
}
Rectangle2D textAnchor = shape.getAnchor();
BufferedImage image;
if ("image/x-wmf".equals(fill.getContentType())) {
// don't rely on wmf dimensions, use dimension of anchor
// TODO: check pixels vs. points for image dimension
image = renderer.getImage(new Dimension((int) textAnchor.getWidth(), (int) textAnchor.getHeight()));
} else {
image = renderer.getImage();
}
if (image == null) {
LOG.log(POILogger.ERROR, "Can't load image data");
return null;
}
Paint paint = new java.awt.TexturePaint(image, textAnchor);
return paint;
}
use of org.apache.poi.sl.usermodel.PaintStyle.TexturePaint in project poi by apache.
the class TestXSLFTheme method slide5.
void slide5(XSLFSlide slide) {
PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
assertTrue(fs instanceof TexturePaint);
XSLFTextShape sh2 = (XSLFTextShape) getShape(slide, "Title 1");
XSLFTextRun run2 = sh2.getTextParagraphs().get(0).getTextRuns().get(0);
assertTrue(sameColor(new Color(148, 198, 0), run2.getFontColor()));
// no fill
assertNull(sh2.getFillColor());
// font size is 40pt and scale factor is 90%
assertEquals(36.0, run2.getFontSize(), 0);
assertTrue(slide.getSlideLayout().getFollowMasterGraphics());
}
use of org.apache.poi.sl.usermodel.PaintStyle.TexturePaint in project poi by apache.
the class TestXSLFTheme method slide9.
void slide9(XSLFSlide slide) {
PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
assertTrue(fs instanceof TexturePaint);
}
use of org.apache.poi.sl.usermodel.PaintStyle.TexturePaint in project poi by apache.
the class TestXSLFTheme method slide8.
void slide8(XSLFSlide slide) {
PaintStyle fs = slide.getBackground().getFillStyle().getPaint();
assertTrue(fs instanceof TexturePaint);
}
Aggregations