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

List:       batik-users
Subject:    Re: [SVGGraphics2D] Need single shape elements for fill and stroke
From:       thomas.deweese () kodak ! com
Date:       2010-05-13 10:14:08
Message-ID: OFB590811F.EB2226D7-ON85257722.0037B7AE-85257722.003839F4 () knotes ! kodak ! com
[Download RAW message or body]

--=_alternative 003839F385257722_=
Content-Type: text/plain; charset="US-ASCII"

Hi Teck,

Teck Hua Lee <gteckhua@gmail.com> wrote on 05/11/2010 01:53:41 PM:

> Let's say I want to draw a blue rectangle with a red border.
> Ideally the SVG element should look like this: 
        <rect style="fill:blue;stroke:red"/>

> The generated code makes sense from a Java2D perspective, but it is
> not optimal for SVG since it effectively doubles the footprint of the
> output.
> Does anyone know if Batik provides a way to generate the optimal
> single element syntax?

        It does not.

> It sounds like I need to extend my own SVGGraphics2D to associate a
> shape instance to a cached element instance and set the fill/stroke
> manually based on the drawing commands.

        You need to be very careful here since, the shape element
passed in can change between calls, and in the case of 'fillRect'
'drawRect' the two shape elements will be different.  This means
that the code needs to iterate over the shape element to see if 
it matches the previous shape element (which it needed to copy from
the last call).  Also care needs to be taken that 'other methods'
like transform calls haven't intervened to make it impossible to
collapse the two elements.

        I've actually thought that walking the output tree might
be easier since it's fairly simple to see if the two adjacent
elements match except for fill/stroke.  This could of course
make the 'current element' a bit of a tricky concept.


--=_alternative 003839F385257722_=
Content-Type: text/html; charset="US-ASCII"

<font size=2 face="sans-serif">Hi Teck,</font>
<br>
<br><tt><font size=2>Teck Hua Lee &lt;gteckhua@gmail.com&gt; wrote on 05/11/2010
01:53:41 PM:<br>
<br>
&gt; Let's say I want to draw a blue rectangle with a red border.<br>
&gt; Ideally the SVG element should look like this: </font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; &lt;rect style=&quot;fill:blue;stroke:red&quot;/&gt;<br>
</font></tt>
<br><tt><font size=2>&gt; The generated code makes sense from a Java2D
perspective, but it is<br>
&gt; not optimal for SVG since it effectively doubles the footprint of
the<br>
&gt; output.<br>
&gt; Does anyone know if Batik provides a way to generate the optimal<br>
&gt; single element syntax?<br>
</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; It does not.</font></tt>
<br>
<br><tt><font size=2>&gt; It sounds like I need to extend my own SVGGraphics2D
to associate a<br>
&gt; shape instance to a cached element instance and set the fill/stroke<br>
&gt; manually based on the drawing commands.<br>
</font></tt>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; You need to be
very careful here since, the shape element</font></tt>
<br><tt><font size=2>passed in can change between calls, and in the case
of 'fillRect'</font></tt>
<br><tt><font size=2>'drawRect' the two shape elements will be different.
&nbsp;This means</font></tt>
<br><tt><font size=2>that the code needs to iterate over the shape element
to see if </font></tt>
<br><tt><font size=2>it matches the previous shape element (which it needed
to copy from</font></tt>
<br><tt><font size=2>the last call). &nbsp;Also care needs to be taken
that 'other methods'</font></tt>
<br><tt><font size=2>like transform calls haven't intervened to make it
impossible to</font></tt>
<br><tt><font size=2>collapse the two elements.</font></tt>
<br>
<br><tt><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; I've actually
thought that walking the output tree might</font></tt>
<br><tt><font size=2>be easier since it's fairly simple to see if the two
adjacent</font></tt>
<br><tt><font size=2>elements match except for fill/stroke. &nbsp;This
could of course</font></tt>
<br><tt><font size=2>make the 'current element' a bit of a tricky concept.</font></tt>
<br><font size=2 face="sans-serif"><br>
</font>
--=_alternative 003839F385257722_=--
[prev in list] [next in list] [prev in thread] [next in thread] 

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