You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/01/16 14:07:53 UTC
[Bug 54433] New: NullPointerException when Initializing the
AffineTransform Object as part of the XSLFGroupShape.draw(Graphics2D
graphics) method
https://issues.apache.org/bugzilla/show_bug.cgi?id=54433
Bug ID: 54433
Summary: NullPointerException when Initializing the
AffineTransform Object as part of the
XSLFGroupShape.draw(Graphics2D graphics) method
Product: POI
Version: 3.8
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: XSLF
Assignee: dev@poi.apache.org
Reporter: Craig@Stoss.ca
Classification: Unclassified
Attempting to transform all XSLFShapes to PNGs using PPTX2PNG as an example I
used this modified code:
XMLSlideShow ppt = new XMLSlideShow(OPCPackage.open(file));
Dimension pgsize = ppt.getPageSize();
int width = (int) (pgsize.width * scale);
int height = (int) (pgsize.height * scale);
XSLFSlide[] slide = ppt.getSlides();
for (int i = 0; i < slide.length; i++) {
if (slidenum != -1 && slidenum != (i + 1)) continue;
String title = slide[i].getTitle();
System.out.println("Rendering slide " + (i + 1) + (title == null ?
"" : ": " + title));
XSLFShape[] pdps = slide[i].getShapes();
int count = 0;
for(XSLFShape pdp : pdps){
BufferedImage img = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
// default rendering options
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setColor(Color.BLUE);
graphics.clearRect(0, 0, width, height);
graphics.scale(scale, scale);
graphics.getTransform().setToIdentity();
// draw stuff
// save the result
int sep = file.lastIndexOf(".");
String fname = file.substring(0, sep == -1 ? file.length() :
sep) + "-" + (i + 1) +"_"+ count++ + ".png";
pdp.draw(graphics);
FileOutputStream out = new FileOutputStream(fname);
ImageIO.write(img, "png", out);
out.close();
}
When pdp instanceof XSLFGroupShape is true, I receive:
Exception in thread "main" java.lang.NullPointerException
at java.awt.geom.AffineTransform.<init>(Unknown Source)
at
org.apache.poi.xslf.usermodel.XSLFGroupShape.draw(XSLFGroupShape.java:296)
...
As far as I can tell this is a bug. I cannot find the Null Object that is being
used.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 54433] NullPointerException when Initializing the
AffineTransform Object as part of the XSLFGroupShape.draw(Graphics2D
graphics) method
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54433
--- Comment #2 from Craig@Stoss.ca ---
Unless I am missing something obvious, that doesn't seem to change the
behaviour.
// default rendering options
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM
,graphics.getTransform());
graphics.setColor(Color.BLUE);
graphics.clearRect(0, 0, width, height);
graphics.scale(scale, scale);
pdp.draw(graphics);
Appreciate the mention of the graphics.getTransform().setToIdentity(); line. I
was just trying to print/modify various attributes to see what perhaps the NPE
was referencing.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 54433] NullPointerException when Initializing the
AffineTransform Object as part of the XSLFGroupShape.draw(Graphics2D
graphics) method
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54433
Yegor Kozlov <ye...@dinom.ru> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |WONTFIX
OS| |All
--- Comment #1 from Yegor Kozlov <ye...@dinom.ru> ---
try to add the following line before drawing:
graphics.setRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM, new
AffineTransform());
P.S. graphics.getTransform() returns a copy of the current transform and
graphics.getTransform().setToIdentity() has no effect in your code. The correct
code is to get, modify and set:
AffineTransform at = graphics.getTransform();
at.setToIdentity();
graphics.setTransform(at);
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org
[Bug 54433] NullPointerException when Initializing the
AffineTransform Object as part of the XSLFGroupShape.draw(Graphics2D
graphics) method
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=54433
--- Comment #3 from Craig@Stoss.ca ---
Apologies, ignore that previous comment code... my code matches yours, I must
have had copy/paste mistake:
// default rendering options
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
graphics.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
graphics.setRenderingHint(XSLFRenderingHint.GROUP_TRANSFORM
,new AffineTransform());
graphics.setColor(Color.BLUE);
graphics.clearRect(0, 0, width, height);
graphics.scale(scale, scale);
pdp.draw(graphics);
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org