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:33 UTC

DO NOT REPLY [Bug 50362] New: NullPointException after calling image transcoder API while appending child element

https://issues.apache.org/bugzilla/show_bug.cgi?id=50362

           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 50362] NullPointException after calling image transcoder API while appending child element

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50362

Amir Mandzuka <am...@ic-mp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #1 from Amir Mandzuka <am...@ic-mp.org> 2010-11-29 04:56:41 EST ---


*** This bug has been marked as a duplicate of bug 50361 ***

-- 
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