> Correct if you insist on using the SVGGraphics2D for this you
> must call getRoot after every drawing operation.
OK, let's say this isn't the case. In doing more reading, it seems like
using the SVGGraphics2D is a bit too complicated for what I'm trying to
achieve initially. I've been playing with my Shape2D -> SVG element
application and it looks like it may be the way to go.
> IIRC it would return an SVG element that wraps all of them:
> <svg>
>> <defs id="genericDefs" />
>> <g>
>> <g fill="rgb(255,102,102)" stroke="rgb(255,102,102)">
>> <ellipse rx="69" fill="none" ry="47.5" cx="174" cy="196.5" />
>> </g>
>> </g>
> </svg>
It does. I don't think I need the <g> elements at all for basic shapes
which has got me going away from SVGGraphics2D.
> This is up to you , for simple paint's the 'defs' serves no
purpose.
> 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>
The SVG specification seems to have examples like this in section 9 on
shapes.
> 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.
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?
Michael Bishop
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]