Loading ...
Sorry, an error occurred while loading the content.
 

Batik Error when invoking getComputedTextLength on TSPAN tag

Expand Messages
  • nboire
    Hi , I have a null pointer exception when i tried to get computedLength of a text woth batik 1.6 java.lang.NullPointerException at
    Message 1 of 3 , Apr 2 9:57 AM
      Hi ,

      I have a null pointer exception when i tried to get computedLength of a
      text woth batik 1.6

      java.lang.NullPointerException
      at
      org.apache.batik.dom.svg.SVGTextContentSupport.getComputedTextLength(Unk\
      nown Source)

      Code :

      SVGDocument doc = new SVGDom().getSVGDocument(uri);
      Element txt2 = doc.getElementById("txt2");
      SVGOMTSpanElement SVGtxt2 = (SVGOMTSpanElement)txt2;
      SVGtxt2.getComputedTextLength(); -> NullPointerexception

      <text id="txt1" font-size="23" x="90" y="88" text-anchor="middle"><tspan
      fill="#455567" font-style="normal" font-weight="normal">T</tspan><tspan
      id="txt2" fill="#000000" font-size="23" font-style="normal"
      font-weight="normal">est</tspan></text>



      Thks for your help.

      Niko
    • Cameron McCormack
      Hi Niko. ... To get such ‘dynamic’ information from the SVG DOM, you need to make sure that the graphics tree has been built. See:
      Message 2 of 3 , Apr 2 4:35 PM
        Hi Niko.

        nboire:
        > I have a null pointer exception when i tried to get computedLength of a
        > text woth batik 1.6
        >
        > java.lang.NullPointerException
        > at
        > org.apache.batik.dom.svg.SVGTextContentSupport.getComputedTextLength(Unk\
        > nown Source)
        >
        > Code :
        >
        > SVGDocument doc = new SVGDom().getSVGDocument(uri);
        > Element txt2 = doc.getElementById("txt2");
        > SVGOMTSpanElement SVGtxt2 = (SVGOMTSpanElement)txt2;
        > SVGtxt2.getComputedTextLength(); -> NullPointerexception

        To get such ‘dynamic’ information from the SVG DOM, you need to make
        sure that the graphics tree has been built. See:

        http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom

        --
        Cameron McCormack, http://mcc.id.au/
        xmpp:heycam@... ▪ ICQ 26955922 ▪ MSN cam@...
      • Tonny Kohar
        Hi, When you get NullPointerException, did you boot the SVG DOM ? See: http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom Regards Tonny Kohar -- Sketsa
        Message 3 of 3 , Apr 2 7:28 PM
          Hi,

          When you get NullPointerException, did you boot the SVG DOM ?
          See: http://wiki.apache.org/xmlgraphics-batik/BootSvgAndCssDom

          Regards
          Tonny Kohar
          --
          Sketsa
          SVG Graphics Editor
          http://www.kiyut.com
        Your message has been successfully submitted and would be delivered to recipients shortly.