xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bishop, Michael W. CONTR J9C880" <Michael.Bis...@je.jfcom.mil>
Subject RE: Basic SVG management in Batik with white-boarding.
Date Thu, 15 Sep 2005 15:30:54 GMT
OK, making some progress here and creating shapes the way I want to.
I'm a little hung up on color.  I see the SVGColor class has a toSVG()
method that will take a java.awt.Color (which is what I start with), but
return a SVGPaintDescriptor.  How do I translate this information to:

<rect stroke="..." .../>

Is this as simple as calling getAttributeMap(null) and iterating through
the returned Map and appending attributes to the shape?

Michael Bishop

-----Original Message-----
From: Thomas DeWeese [mailto:Thomas.DeWeese@Kodak.com] 
Sent: Tuesday, September 13, 2005 4:20 PM
To: batik-users@xmlgraphics.apache.org
Subject: Re: Basic SVG management in Batik with white-boarding.

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

---------------------------------------------------------------------
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