Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-887

NPE when changing an element during animation

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: 1.8
    • Fix Version/s: None
    • Component/s: Animation engine
    • Labels:
      None
    • Environment:
      Operating System: Windows Server 2003
      Platform: PC

      Description

      JDK: 1.6.0_07
      Batik: batik-src-09-01-04.zip

      When you have an animated element and you change e.g. the border colour you get a NullPointerException.

      SVG file cut:

      <rect x="20" y="20" width="100" height="100" style="stroke:#ffffff;stroke-width:1;" fill="blue" id="hlRect">
      <animate attributeType="CSS" attributeName="opacity" from="1" to="0" begin="0s;blue_fade_in.end" dur="1s" id="blue_fade_out"/>
      <animate attributeType="CSS" attributeName="opacity" from="0" to="1" begin="blue_fade_out.end" dur="1s" id="blue_fade_in"/>
      </rect>

      In this case it's a simple rect but the same will happen when you animate a group which contains elements on which you perform the action.
      When you start the application the animation will run as expected. As soon as you change e.g. the stroke colour with Java you'll get a NPE.

      Java code cut:

      svgCanvas.getUpdateManager().getUpdateRunnableQueue().invokeLater(new Runnable() {
      public void run()

      { SVGDocument svgDoc = svgCanvas.getSVGDocument(); Element hlElement = svgDoc.getElementById("hlRect"); ((org.w3c.dom.svg.SVGStylable)hlElement).getStyle().setProperty("stroke", "deepskyblue", ""); }

      });

      NPE:

      java.lang.NullPointerException
      at org.apache.batik.anim.timing.TimedElement.addInstanceTime(Unknown Source)
      at org.apache.batik.anim.timing.SyncbaseTimingSpecifier.newInterval(Unknown Source)
      at org.apache.batik.anim.timing.TimedElement.notifyNewInterval(Unknown Source)
      at org.apache.batik.anim.timing.TimedElement.selectNewInterval(Unknown Source)
      at org.apache.batik.anim.timing.TimedElement.sampleAt(Unknown Source)
      at org.apache.batik.anim.timing.TimedDocumentRoot.seekTo(Unknown Source)
      at org.apache.batik.anim.AnimationEngine.tick(Unknown Source)
      at org.apache.batik.bridge.SVGAnimationEngine.access$600(Unknown Source)
      at org.apache.batik.bridge.SVGAnimationEngine$AnimationTickRunnable.run(Unknown Source)
      at org.apache.batik.util.RunnableQueue.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:619)

      This NPE will be displayed repeatedly.
      Let me know if you need any more info.

        Attachments

          Activity

            People

            • Assignee:
              batik-dev@xmlgraphics.apache.org Batik Developer's Mailing list
              Reporter:
              age@hobba.nl Age Bosma
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: