You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-dev@xmlgraphics.apache.org by bu...@apache.org on 2010/11/29 10:40:32 UTC
DO NOT REPLY [Bug 50361] New: NullPointException after calling image
transcoder API while appending child element
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
Summary: NullPointException after calling image transcoder API
while appending child element
Product: Batik
Version: 1.7
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: SVG Rasterizer
AssignedTo: batik-dev@xmlgraphics.apache.org
ReportedBy: amir.mandzuka@ic-mp.org
Hi, With JSVGCanvas I load predefinded svg skeleton image and add various kind
of elements like rectangle, circle, polyline etc later.
New elements can be added unlimited numer of times until svg is converted to
jpeg using transcoder API fith the folowing lines
String
skeletalImagePath=System.getProperty("java.io.tmpdir")+"\\skeleton.jpg";
try {
JPEGTranscoder t = new JPEGTranscoder();
// Set the transcoding hints.
t.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.99));
TranscoderInput input = new TranscoderInput(doc);
// Create the transcoder output.
OutputStream ostream = new FileOutputStream(skeletalImagePath);
TranscoderOutput output = new TranscoderOutput(ostream);
// Save the image.
try {
t.transcode(input, output);
} catch (TranscoderException et) {
et.printStackTrace();
}
// Flush and close the stream.
ostream.flush();
ostream.close();
} catch (FileNotFoundException eu) {
JOptionPane.showMessageDialog(null, eu.getMessage(), "",
JOptionPane.INFORMATION_MESSAGE);
eu.printStackTrace();
} catch (IOException et) {
JOptionPane.showMessageDialog(null, et.getMessage(), "",
JOptionPane.INFORMATION_MESSAGE);
et.printStackTrace();
}
After that if new element is added using folowing function null point exection
error appears.
private void addPMDefect(final int x,final int y,final int bodyPartBoneId,
final int id){
UpdateManager um = jSVGCanvas1.getUpdateManager();
um.getUpdateRunnableQueue().invokeLater(new Runnable() {
public void run() {
SVGElement svgRoot = svgDocument.getRootElement();
String dot1,dot2,dot3, dot4;
dot1=Integer.toString(x-15)+","+Integer.toString(y+5);
dot2=Integer.toString(x-5)+","+Integer.toString(y-5);
dot3=Integer.toString(x+5)+","+Integer.toString(y+5);
dot4=Integer.toString(x+15)+","+Integer.toString(y-5);
Element el = svgDocument.createElementNS (svgNS, "polyline");
el.setAttributeNS (null, "fill", "none");
el.setAttributeNS (null, "stroke", PMDefectColor);
el.setAttributeNS (null, "stroke-width", "2");
el.setAttributeNS (null, "points", dot1+" "+dot2+" "+dot3+" "+dot4);
el.setAttributeNS (null, "id", "observ1"+Integer.toString(id));
svgRoot.appendChild(el);
}
}
);
}
Error message:
java.lang.NullPointerException
at
org.apache.batik.bridge.CSSUtilities.convertDisplay(CSSUtilities.java:565)
at
org.apache.batik.bridge.AbstractGraphicsNodeBridge.getDisplay(AbstractGraphicsNodeBridge.java:158)
at org.apache.batik.bridge.GVTBuilder.build(GVTBuilder.java:134)
at
org.apache.batik.bridge.SVGGElementBridge.handleElementAdded(SVGGElementBridge.java:123)
at
org.apache.batik.bridge.SVGGElementBridge.handleDOMNodeInsertedEvent(SVGGElementBridge.java:107)
at
org.apache.batik.bridge.BridgeContext$DOMNodeInsertedEventListener.handleEvent(BridgeContext.java:1601)
at
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:324)
at
org.apache.batik.dom.events.EventSupport.fireEventListeners(EventSupport.java:366)
at
org.apache.batik.dom.events.EventSupport.dispatchEvent(EventSupport.java:258)
at org.apache.batik.dom.AbstractNode.dispatchEvent(AbstractNode.java:1014)
at
org.apache.batik.dom.AbstractParentNode.fireDOMNodeInsertedEvent(AbstractParentNode.java:422)
at
org.apache.batik.dom.AbstractParentNode.appendChild(AbstractParentNode.java:224)
at view.JSkeletonCanvas$6.run(JSkeletonCanvas.java:351)
at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
at java.lang.Thread.run(Thread.java:619)
Line 351 is: svgRoot.appendChild(el);
Am I doind something wrong?
Thanks
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
Thomas Deweese <de...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |INVALID
--- Comment #2 from Thomas Deweese <de...@apache.org> 2010-11-29 05:47:42 EST ---
I believe your problem is that you can not use the Image Transcoder with a
document while it is attached to the Canvas (the Image transcoder will replace
the canvas's rendering tree with it's own).
You need to either clone the document and use the cloned version with the Image
transcoder or detach the document from the canvas before transcoding and then
attach it again after.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
--- Comment #1 from Amir Mandzuka <am...@ic-mp.org> 2010-11-29 04:56:42 EST ---
*** Bug 50362 has been marked as a duplicate of this bug. ***
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
Amir Mandzuka <am...@ic-mp.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|INVALID |
--- Comment #3 from Amir Mandzuka <am...@ic-mp.org> 2010-11-29 06:28:38 EST ---
Thanks for quick reply.
Do you have some link to working example on how to clone SVGDocument.
I have tried
SVGDocument tempDoc;
try {
tempDoc = (SVGDocument)jSVGCanvas1.getSVGDocument().clone();
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
and error is raised
Error(5686,65): method clone() not found in interface
org.w3c.dom.svg.SVGDocument
Also
SVGDocument tempDoc=jSVGCanvas1.getSVGDocument();
and calling transcoder on tempDoc still corrupts that canvas's rendering tree.
Regards
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
Helder Magalhães <he...@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|REOPENED |NEEDINFO
--- Comment #5 from Helder Magalhães <he...@gmail.com> 2010-11-30 05:17:17 EST ---
(In reply to comment #4)
> For now this seams that it works very well
Does this mean that the issue is now solved? If so, why haven't you closed it
("invalid", as Thomas hinted)?
If the issue is still reproducible, please attach a *reduced* test case and add
further information (Java version, operating system, double check Batik version
and/or test with a 1.8 development snapshot, etc.), so that further analysis
can be done. Note that the issue tracker isn't meant for support requests,
those are better aimed at batik-users@ (or batik-dev@ for development-related
matters) [2].
[1]
http://xmlgraphics.apache.org/batik/download.cgi#Current+development+snapshot
[2] http://xmlgraphics.apache.org/batik/mailing-lists.html
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
Amir Mandzuka <am...@ic-mp.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |RESOLVED
Resolution| |INVALID
--- Comment #6 from Amir Mandzuka <am...@ic-mp.org> 2010-11-30 05:25:03 EST ---
I thought that this was a bug. It is solved now. Sorry because i left it as
still active issue.
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org
DO NOT REPLY [Bug 50361] NullPointException after calling image
transcoder API while appending child element
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50361
--- Comment #4 from Amir Mandzuka <am...@ic-mp.org> 2010-11-29 06:54:37 EST ---
For now this seams that it works very well
SVGDocument tempDoc=(SVGDocument)svgDocument.cloneNode(true);
svgDocument is attached to JSVGCanvas and
tempDoc is used with transcoder
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org