>  Hmm, I would actually change:
> Node node = ((Node) event.getTarget()).getParentNode();

> to 

> Node node = DragStatus.getSelectedElement().getParentNode();

One word; bingo.  I guess if I dragged an element off the canvas, the
mouse got mismatched with the element.  Same if I dragged too fast and
had the mouse fly off the element temporarily.  This makes perfect sense
and works wonderfully.

I think you're also right about the reason for the jumping when I did it
the old way.  Even when I changed it to the way I'm doing it now, I had
to move a couple statements (where I record the "lastMoved" status
versus where I check it before applying additional transforms).  Now I
got smooth and accurate motion on the canvas.  Whew!  Thanks a lot for
the help, this has been my problem for a couple days now.

Michael Bishop

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 27, 2005 11:20 AM
To: [email protected]
Subject: RE: Weird problem using translations.

Hi Micheal,

"Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote on

10/27/2005 11:01:51 AM:

> OK, here's what I changed to in order to get the right coordinates in
> the MouseMove event:
> 
> DOMMouseEvent elementEvent = (DOMMouseEvent) event;
> int dragMoveX = elementEvent.getClientX();
> int dragMoveY = elementEvent.getClientY();
> SVGOMPoint point = new SVGOMPoint(dragMoveX, dragMoveY);
> Node node = ((Node) event.getTarget()).getParentNode();
> SVGMatrix matrix = ((SVGLocatable) node).getScreenCTM();
> matrix = matrix.inverse();
> 
> SVGOMPoint dragPoint = (SVGOMPoint) point.matrixTransform(matrix);
> Element targetElement = DragStatus.getSelectedElement();

  Hmm, I would actually change:
> Node node = ((Node) event.getTarget()).getParentNode();

to 

> Node node = DragStatus.getSelectedElement().getParentNode();

Otherwise the 'parent' might change between the drawn element group
(when cursor is over the moving element) and the background group
(when cursor is over the background rect) - right now they may be
the same but this will likely not hold true forever.

> I still have the mouse being able to get "out" of the element.  Again,
I
> still get motion on the element, but it becomes further and further
out
> of sync with the mouse.

   I don't like the 'iterative' update I much prefer getting 'total'
motion for start but this is likely not the main issue here.

> > Ahh, this is your bug, right now you are essentially killing every
> > other mouse move delta,
> 
> Are you saying I should be appending a new translate for each delta?

   No.

> I thought incrementing an existing translate would essentially end up
> being translated by deltaX, deltaY from mouse press to mouse release.

   The problem is that if you tried to compare your 'old' location with
your 'new' location you get garbage if the new location includes an
additional transform.  So the reason your element was flapping back and
forth was:
        1) translate(0,0) mouse loc 100,100 maps to 100,100
                original mouse loc recored at 100,100.
                mouse moves 10 pixels horizontally (mouse now at
110,100)
        2) translate(10, 0) mouse loc 110,100 maps to 100,100
              mouse moves 1 pixel horizontally (mouse now at 111,100)
                111,100 maps to 101,100 (due to translate change), delta
                from original location is 1 so translate is set to:
        3) translate(1, 0) mouse loc 111,100 maps to 110,100
              mouse moves 1 more pixel horizontally (mouse not aw
112,100)
                112,100 maps to 111,100 (translate is only 1 now), delta
                from original location is 111 so translate is set to:
        4) translate(11, 0)
                wash rinse repeat.

   I suspect something similar is happening when you calculate the
'deta' for a mouse move.  You record the 'old' mouse location (before
translate is updated) and you compare it with the new location 
(after translate is updated) and you effectively loose the amount you
added to the translate, at the last step, from the calculated delta,
so your shape 'lags' the pointer motion.

> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, October 27, 2005 10:49 AM
> To: [email protected]
> Cc: [email protected]
> Subject: RE: Weird problem using translations.
> 
> Hi Michael,
> 
> "Bishop, Michael W. CONTR J9C880" <[EMAIL PROTECTED]> wrote
on
> 
> 10/27/2005 09:22:39 AM:
> 
> >      Not quite what I'm doing.  After I calculate the deltas between
> > mouse moves, I add to the original translate values, I don't add new
> > translate attributes.
> >
> > I am not adding translate values, I'm adding TO the existing
translate
> > value.  I had originally set the translate based on the delta from
> where
> > the mouse was originally pressed to "now", but I got some really
weird
> > behavior where the element would "jump" back to its original
position
> > every other mouse event.
> 
>    Ahh, this is your bug, right now you are essentially killing every 
> other
> mouse move delta, going back to your earlier message I notice:
> 
> > > - I transform the coordinates in my MouseMove event by getting the
> > >   client X/Y from the DOMMouseEvent, creating an SVGOMPoint, and
> > >   inverting the matrix from the event.getTarget().getScreenCTM().
> 
>    This is the problem, the getScreenCTM for target will include the
> 'update' to the transform, which generally you don't want.  You
> probably want to do something like:
> 
>         Node n = event.getTarget().getParentNode();
>         SVGMatrix mat = ((SVGLocatable)n).getScreenCTM();
> 
>    I suspect this will fix all your problems (with either way of doing

> things).
> 
> 
> ---------------------------------------------------------------------
> 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]

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

Reply via email to