[prev in list] [next in list] [prev in thread] [next in thread] 

List:       batik-dev
Subject:    [jira] [Updated] (BATIK-1144) a text animation faults with null pointer exception, when scripting wi
From:       "simon steiner (JIRA)" <jira () apache ! org>
Date:       2017-09-19 11:44:00
Message-ID: JIRA.12953366.1458849498000.145948.1505821440589 () Atlassian ! JIRA
[Download RAW message or body]


     [ https://issues.apache.org/jira/browse/BATIK-1144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel \
]

simon steiner updated BATIK-1144:
---------------------------------
    Description: 
when trying to dynamically animate a color change for a text element, got a null \
pointer exception in the SVGOMAnimationElement:beginElement() method because \
getSvgContext was returning null.

introspection with a debugger turned up the fact that in \
SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent evt) the setting of the \
svg context was not being done. this is called when the animation element is appended \
as a child to the text element.

SVGTextElementBridge extends AbstractGraphicsNodeBridge and in particular overrides \
handleDOMNodeInsertedEvent(MutationEvent evt) which would normally set the svg \
context.

as a local fix changing SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent \
evt) and how it handles an ELEMENT node from: {code}
    public void handleDOMNodeInsertedEvent(MutationEvent evt) {
        Node childNode = (Node)evt.getTarget();

        //check the type of the node inserted before discard the layout
        //in the case of <title> or <desc> or <metadata>, the layout
        //is unchanged
        switch(childNode.getNodeType()) {
            case Node.TEXT_NODE:        // fall-through is intended
            case Node.CDATA_SECTION_NODE:
                laidoutText = null;
                break;
            case Node.ELEMENT_NODE: {
                Element childElement = (Element)childNode;
                if (isTextChild(childElement)) {
                    addContextToChild(ctx, childElement);
                    laidoutText = null;
                }
                break;
            }
        }
        if (laidoutText == null) {
            computeLaidoutText(ctx, e, getTextNode());
        }
    }
{code}
--
to fix, added else to isTextChild conditional, to:
{code}
    public void handleDOMNodeInsertedEvent(MutationEvent evt) {
        Node childNode = (Node)evt.getTarget();

        //check the type of the node inserted before discard the layout
        //in the case of <title> or <desc> or <metadata>, the layout
        //is unchanged
        switch(childNode.getNodeType()) {
            case Node.TEXT_NODE:        // fall-through is intended
            case Node.CDATA_SECTION_NODE:
                laidoutText = null;
                break;
            case Node.ELEMENT_NODE: {
                Element childElement = (Element)childNode;
                if (isTextChild(childElement)) {
                    addContextToChild(ctx, childElement);
                    laidoutText = null;
                }
               // ADDED ELSE so animation nodes get std treatment
                else {
                        super.handleDOMNodeInsertedEvent(evt);
                }
                break;
            }
        }
        if (laidoutText == null) {
            computeLaidoutText(ctx, e, getTextNode());
        }
    }
{code}
--

not clear that this is a complete fix or not.




  was:
when trying to dynamically animate a color change for a text element, got a null \
pointer exception in the SVGOMAnimationElement:beginElement() method because \
getSvgContext was returning null.

introspection with a debugger turned up the fact that in \
SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent evt) the setting of the \
svg context was not being done. this is called when the animation element is appended \
as a child to the text element.

SVGTextElementBridge extends AbstractGraphicsNodeBridge and in particular overrides \
handleDOMNodeInsertedEvent(MutationEvent evt) which would normally set the svg \
context.

as a local fix changing SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent \
evt) and how it handles an ELEMENT node from: {code}
    public void handleDOMNodeInsertedEvent(MutationEvent evt) {
        Node childNode = (Node)evt.getTarget();

        //check the type of the node inserted before discard the layout
        //in the case of <title> or <desc> or <metadata>, the layout
        //is unchanged
        switch(childNode.getNodeType()) {
            case Node.TEXT_NODE:        // fall-through is intended
            case Node.CDATA_SECTION_NODE:
                laidoutText = null;
                break;
            case Node.ELEMENT_NODE: {
                Element childElement = (Element)childNode;
                if (isTextChild(childElement)) {
                    addContextToChild(ctx, childElement);
                    laidoutText = null;
                }
                break;
            }
        }
        if (laidoutText == null) {
            computeLaidoutText(ctx, e, getTextNode());
        }
    }
--
to fix, added else to isTextChild conditional, to:

    public void handleDOMNodeInsertedEvent(MutationEvent evt) {
        Node childNode = (Node)evt.getTarget();

        //check the type of the node inserted before discard the layout
        //in the case of <title> or <desc> or <metadata>, the layout
        //is unchanged
        switch(childNode.getNodeType()) {
            case Node.TEXT_NODE:        // fall-through is intended
            case Node.CDATA_SECTION_NODE:
                laidoutText = null;
                break;
            case Node.ELEMENT_NODE: {
                Element childElement = (Element)childNode;
                if (isTextChild(childElement)) {
                    addContextToChild(ctx, childElement);
                    laidoutText = null;
                }
               // ADDED ELSE so animation nodes get std treatment
                else {
                        super.handleDOMNodeInsertedEvent(evt);
                }
                break;
            }
        }
        if (laidoutText == null) {
            computeLaidoutText(ctx, e, getTextNode());
        }
    }
{code}
--

not clear that this is a complete fix or not.





> a text animation faults with null pointer exception, when scripting with java
> -----------------------------------------------------------------------------
> 
> Key: BATIK-1144
> URL: https://issues.apache.org/jira/browse/BATIK-1144
> Project: Batik
> Issue Type: Bug
> Components: Animation engine, Bridge, Scripting
> Affects Versions: 1.8
> Environment: first noticed on windows 7,  jdk 1.8
> Reporter: mitchell bass
> 
> when trying to dynamically animate a color change for a text element, got a null \
> pointer exception in the SVGOMAnimationElement:beginElement() method because \
> getSvgContext was returning null. introspection with a debugger turned up the fact \
> that in SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent evt) the \
> setting of the svg context was not being done. this is called when the animation \
> element is appended as a child to the text element. SVGTextElementBridge extends \
> AbstractGraphicsNodeBridge and in particular overrides \
> handleDOMNodeInsertedEvent(MutationEvent evt) which would normally set the svg \
> context. as a local fix changing \
> SVGTextElementBridge.handleDOMNodeInsertedEvent(MutationEvent evt) and how it \
> handles an ELEMENT node from: {code}
> public void handleDOMNodeInsertedEvent(MutationEvent evt) {
> Node childNode = (Node)evt.getTarget();
> //check the type of the node inserted before discard the layout
> //in the case of <title> or <desc> or <metadata>, the layout
> //is unchanged
> switch(childNode.getNodeType()) {
> case Node.TEXT_NODE:        // fall-through is intended
> case Node.CDATA_SECTION_NODE:
> laidoutText = null;
> break;
> case Node.ELEMENT_NODE: {
> Element childElement = (Element)childNode;
> if (isTextChild(childElement)) {
> addContextToChild(ctx, childElement);
> laidoutText = null;
> }
> break;
> }
> }
> if (laidoutText == null) {
> computeLaidoutText(ctx, e, getTextNode());
> }
> }
> {code}
> --
> to fix, added else to isTextChild conditional, to:
> {code}
> public void handleDOMNodeInsertedEvent(MutationEvent evt) {
> Node childNode = (Node)evt.getTarget();
> //check the type of the node inserted before discard the layout
> //in the case of <title> or <desc> or <metadata>, the layout
> //is unchanged
> switch(childNode.getNodeType()) {
> case Node.TEXT_NODE:        // fall-through is intended
> case Node.CDATA_SECTION_NODE:
> laidoutText = null;
> break;
> case Node.ELEMENT_NODE: {
> Element childElement = (Element)childNode;
> if (isTextChild(childElement)) {
> addContextToChild(ctx, childElement);
> laidoutText = null;
> }
> // ADDED ELSE so animation nodes get std treatment
> else {
> super.handleDOMNodeInsertedEvent(evt);
> }
> break;
> }
> }
> if (laidoutText == null) {
> computeLaidoutText(ctx, e, getTextNode());
> }
> }
> {code}
> --
> not clear that this is a complete fix or not.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: batik-dev-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-dev-help@xmlgraphics.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic