You are viewing a plain text version of this content. The canonical link for it is here.
Posted to batik-users@xmlgraphics.apache.org by Leslie Ramer <le...@peregrine.com> on 2001/11/06 20:46:09 UTC

Problem with batik's DOM and animate element

The problem:

When setting the "fill" attribute on an "animate" element, the value when
dumped to my XML/SVG file  gets represented as:
	style="fill:freeze;"
instead of...
	fill="freeze"
like I expect.

I reasoned that this could be happening because 'fill' is an attribute
common to shapes and text that is commonly placed in a composite 'style'
attribute... and therefore the reason that the 'fill' attribute is tossed
into the 'style' attribute.

My simple workaround (i.e., hack) is to create a 'set' element that begins
when the fade-in 'animate' completes.  This just feels wrong, and I don't
know where to go next.  If possible, I would like to avoid using javascript
to solve this problem.


My code:

I'm using the following excerpt of code to create a fade-in animation for a
tooltip...

    private static Element createTipAnimation( Document d, String id, 
        String from, String to, String when, String duration )
    {
        Element e = d.createElement( "animate" );
        if ( id != null )
        {
            e.setAttribute( "id", id );
        }
        e.setAttribute( "attributeName", "opacity" );
        e.setAttribute( "from", from );
        e.setAttribute( "to", to );
        e.setAttribute( "fill", "freeze" );
        e.setAttribute( "begin", when );
        e.setAttribute( "dur", duration );

        return e;
    }


I use this method from another place in the code...

    //...
	SVGGraphics2D g; // g is assigned somewhere else...
        Element	tip = g.getTopLevelGroup( false );
        Document	d = g.getDOMFactory( );
        String 	_toolId; // _toolId is assigned somewhere else...
    //...
        //fade tool tip in...
        Element fadeIn = createTipAnimation( d, "temp", "0", "0.8",
            _toolId + ".mouseover+1s", "1s", _toolId + ".mouseout" );

        tip.appendChild( fadeIn );
    //...

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


Re: Problem with batik's DOM and animate element

Posted by Vincent Hardy <vi...@sun.com>.
Leslie,

I think you have found a bug in the SVGGraphics2D. To work around it
for the time being, you can output your SVG content using XML attributes
instead of the CSS style attribute. That is, do:

boolean useCSS = false; // Do not use CSS style attribute
Writer out = new OutputStreamWriter(System.out, "UTF-8");
svgGenerator.stream(out, useCSS);

Cheers,
Vincent.

Leslie Ramer wrote:
> 
> The problem:
> 
> When setting the "fill" attribute on an "animate" element, the value when
> dumped to my XML/SVG file  gets represented as:
>         style="fill:freeze;"
> instead of...
>         fill="freeze"
> like I expect.
> 
> I reasoned that this could be happening because 'fill' is an attribute
> common to shapes and text that is commonly placed in a composite 'style'
> attribute... and therefore the reason that the 'fill' attribute is tossed
> into the 'style' attribute.
> 
> My simple workaround (i.e., hack) is to create a 'set' element that begins
> when the fade-in 'animate' completes.  This just feels wrong, and I don't
> know where to go next.  If possible, I would like to avoid using javascript
> to solve this problem.
> 
> My code:
> 
> I'm using the following excerpt of code to create a fade-in animation for a
> tooltip...
> 
>     private static Element createTipAnimation( Document d, String id,
>         String from, String to, String when, String duration )
>     {
>         Element e = d.createElement( "animate" );
>         if ( id != null )
>         {
>             e.setAttribute( "id", id );
>         }
>         e.setAttribute( "attributeName", "opacity" );
>         e.setAttribute( "from", from );
>         e.setAttribute( "to", to );
>         e.setAttribute( "fill", "freeze" );
>         e.setAttribute( "begin", when );
>         e.setAttribute( "dur", duration );
> 
>         return e;
>     }
> 
> I use this method from another place in the code...
> 
>     //...
>         SVGGraphics2D g; // g is assigned somewhere else...
>         Element tip = g.getTopLevelGroup( false );
>         Document        d = g.getDOMFactory( );
>         String  _toolId; // _toolId is assigned somewhere else...
>     //...
>         //fade tool tip in...
>         Element fadeIn = createTipAnimation( d, "temp", "0", "0.8",
>             _toolId + ".mouseover+1s", "1s", _toolId + ".mouseout" );
> 
>         tip.appendChild( fadeIn );
>     //...
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: batik-users-unsubscribe@xml.apache.org
> For additional commands, e-mail: batik-users-help@xml.apache.org

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