Well let me see if I can be clearer.  Maybe I'm doing this wrong.  In my
application, I have a glass pane attached to a JFrame (because you can't
attach a glass pane directly to a JSVGCanvas).  When I'm drawing shapes
to the canvas, I draw the "ghosted line" or "outline" as the user drags
the mouse, then render the shape to the JSVGCanvas when the user
releases the mouse.  Since the 0, 0 of the glass pane is the upper-left
corner of the application (JFrame), I have to translate by +x and +y
where +x is the x of the JSVGCanvas and +y is the y of the JSVGCanvas
plus the height of the JMenuBar.  Now when I draw to the JSVGCanvas, the
glass pane drawing "lines up" with the JSVGCanvas.  I've been doing
drawing operations like this for a couple months, but it's always felt
like a hack.

Yesterday's case was the reverse.  I wanted to click on a rendered SVG
element and draw its bounding box to the glass pane, taking the
above-mentioned offset AND the view box transform of the JSVGCanvas into
account.

Michael Bishop

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, November 29, 2005 6:32 AM
To: [email protected]
Subject: RE: Element -> Bounding Box?

Hi all,

Tonny Kohar <[EMAIL PROTECTED]> wrote on 11/28/2005 08:48:02 PM:

> On Mon, 2005-11-28 at 17:23 -0500, Bishop, Michael W. CONTR J9C880
> wrote:
> > I can get close; the JSVGCanvas isn't at 0, 0 screen coordinates.  I
> > have a JMenuBar on the top and a JToolBar on the left.  Before
drawing
> > anything to the glass pane, I set the translate values of the glass 
pane
> > accordingly. 
> 
> You need to get the coord of the component itself not the parent
> container eg: JFrame to get 0,0 coord.

   Why do you need the screen coords of anything?  getScreenCTM
will map things to the JSVGCanvas's coordinate system (0,0 should
be the upper left of the JSVGCanvas).  Since I use this to map
the clientX/Y into the SVG content all the time with the screen CTM
I'm fairly certain that it is correct.

> We got similar problem when develop our Sketsa SVG Editor, we solve
the
> problem by create using Java shape instead of SVG shape to mimic the
SVG
> shape to be edited. And manipulate those Java shape then regenerate
the
> SVG correspond node then replace or just replace the attribute of
> original SVG node with the generated one.
> 
> Regards
> Tonny Kohar
> -- 
> Sketsa 
> SVG Graphics Editor
> http://www.kiyut.com
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
[EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to