Hi everybody !
I've got a little problem when I try to ad an animateColor element to
an existing element in my document: I've got a NullPointerException
thrown:
Can you help me, please, to find the mistake? I dont see what could be
the problem (nothing is null in the appendChild method I call...) ! I
often add nodes to documents in my projects, and it's the first time i
had to face this kind of error.
Let's see my code :
################################################
The code
################################################
public void run(){
System.out.println("BLINK lancé");
Element element =
this.document.getElementById("button_"+this.iD), child;
if (this.color1==null){
//Treantments if the color1 field of my thread is null
(code missing in order to read my program more easily: here is not the
problem)
}
} else{
//Declaration and initialization of the strings red1 red2,
green1, green2, blue1, blue2 (code missing in order to read my program
more easily: here is not the problem)
// Creation and initialization of the animateColor
elements (following code)
Element toColor2 =
this.document.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"animateColor"),
toColor1 =
this.document.createElementNS(SVGDOMImplementation.SVG_NAMESPACE_URI,"animateColor");
toColor2.setAttributeNS(null, "id","blink2");
toColor2.setAttributeNS(null, "attributeName","fill");
toColor2.setAttributeNS(null, "attributeType","XML");
toColor2.setAttributeNS(null, "from", "#"+red1+green1+blue1);
toColor2.setAttributeNS(null, "to", "#"+red2+green2+blue2);
toColor2.setAttributeNS(null, "begin", "0s;blink1.end");
toColor2.setAttributeNS(null, "dur", "0.5s");
toColor1.setAttributeNS(null, "id","blink1");
toColor1.setAttributeNS(null, "attributeName","fill");
toColor1.setAttributeNS(null, "attributeType","XML");
toColor1.setAttributeNS(null, "to", "#"+red1+green1+blue1);
toColor1.setAttributeNS(null, "from", "#"+red2+green2+blue2);
toColor1.setAttributeNS(null, "begin", "blink2.end");
toColor1.setAttributeNS(null, "dur", "0.5s");
//The two following lines show me that neither element or toColor2
System.out.println("Element: "+element);
System.out.println(toColor2);
//The following line reports the exception
element.appendChild(toColor2);
element.appendChild(toColor1);
}
}
################################################
Here is the report of the exception
################################################
java.lang.NullPointerException
at
org.apache.batik.anim.timing.SyncbaseTimingSpecifier.<init>(SyncbaseTimingSpecifier.java:65)
at
org.apache.batik.anim.timing.TimingSpecifierListProducer.syncbase(TimingSpecifierListProducer.java:99)
at
org.apache.batik.parser.TimingSpecifierParser.handleTimingSpecifier(TimingSpecifierParser.java:90)
at
org.apache.batik.parser.TimingSpecifierListParser.doParse(TimingSpecifierListParser.java:74)
at org.apache.batik.parser.AbstractParser.parse(AbstractParser.java:150)
at
org.apache.batik.anim.timing.TimingSpecifierListProducer.parseTimingSpecifierList(TimingSpecifierListProducer.java:79)
at
org.apache.batik.anim.timing.TimedElement.parseBegin(TimedElement.java:1097)
at
org.apache.batik.anim.timing.TimedElement.parseAttributes(TimedElement.java:1072)
at
org.apache.batik.bridge.SVGAnimationElementBridge.initializeTimedElement(SVGAnimationElementBridge.java:301)
at
org.apache.batik.bridge.SVGAnimationElementBridge.initializeTimedElement(SVGAnimationElementBridge.java:261)
at
org.apache.batik.bridge.SVGAnimationElementBridge.handleElement(SVGAnimationElementBridge.java:155)
at
org.apache.batik.bridge.AbstractGraphicsNodeBridge.handleDOMNodeInsertedEvent(AbstractGraphicsNodeBridge.java:284)
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 src.threads.ThreadBlink.run(ThreadBlink.java:103) => The
incriminated line in the code upper in this mail
at org.apache.batik.util.RunnableQueue.run(RunnableQueue.java:237)
at java.lang.Thread.run(Thread.java:636)
Can you help me, please, to find the mistake? I dont see what could be
the problem (nothing is null in the appendChild method I call...) ! I
often add nodes to documents in my projects, and it's the first time i
had to face this kind of error.
Thanks.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]