xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas DeWeese <Thomas.DeWe...@Kodak.com>
Subject Re: Basic SVG management in Batik with white-boarding.
Date Tue, 13 Sep 2005 20:19:32 GMT
Hi Michael,

Bishop, Michael W. CONTR J9C880 wrote:

> I don't think I need the <g> elements at all for basic shapes
> which has got me going away from SVGGraphics2D.

>>The outer 'g' is also mostly useless in the 'one draw operation at a
>>time' case, so you are left with just the inner 'g' that needs to be
>>kept.
> 
> Why?  Can't I have:
> 
> <svg>
>     <circle .../>
>     <rect .../>
> </svg>

    You can have this if you go with SVGShape, getting this from
the SVGGraphics2D would be difficult (you would have to move
the fill/stroke/etc attrs from the wrapping 'g' to the primitive).

>>    Yes, so you would want to do something like:
> 
>>    Element e = svgShape.toSVG(java2dShape);
>>    e.setAttributeNS(null, "fill", "red");
>>    root.appendChild(e).
> 
> Right, since this is a whiteboard application, I will need to
> communicate everything about the shape.  Color, fill color, size, shape,
> etc.  Again, according to the SVG specification, I can declare all this
> stuff.  So now I'm thinking:
> 
> - Create a root document.
> - Set extra attributes on the root <svg> element; canvas size, etc.
> - Translate mouse press/release to X/Y coordinates.
> - Translate X/Y coordinates to Shape.
> - Translate Shape2D to SVGShape.
> - Use SVGShape.toSVG() to create the SVG element.
> - Set extra attributes on the element; ID, fill color, color, etc.
> - Append the SVG fragment to the document.
> - At this point, ALWAYS_DYNAMIC should pick up the change and display it
> on the application.

    This all sounds good (just a friendly reminder to use the
UpdateManager thread to append the new shape to the document).

> The only question left in this line of thinking is the
> SVGGeneratorContext.  It's needed as a constructor argument for the
> SVGShape class.  I used to get it from SVGGraphics2D.  Where would I get
> one for now?

    It has a factory method that takes a Document.  This is generally
what the SVGGraphics2D uses in the default case:

     SVGGeneratorContext gc = SVGGeneratorContext.createDefault(doc);


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


Mime
View raw message