Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Location Translation
Location Translation [message #143314] Mon, 19 July 2004 14:31 Go to next message
Larry Waldman is currently offline Larry WaldmanFriend
Messages: 9
Registered: July 2009
Junior Member
I know there must be a way to do this, but as yet, I have been unable to
find how. Perhaps someone can help:

I have the coordinates of the mouse cursor in the ViewPort, and, in short,
what I am trying to do is figure out the proximity of the cursor to
components (any object) in the viewport.

I can adjust the cursor location based on the zoom scale, and then compare
to the figure's center location -- however, this does not take into
account the state of the scrollbars.

I'm thinking there MUST be a simple way to either translate objects'
coordinates to viewport coordinates or vice-versa, and translate the
cursor's coordinates to absolute coordinates which can be compared with
figures' coordinates.

Can anyone help?

Thanks!

LFW
Re: Location Translation [message #143374 is a reply to message #143314] Mon, 19 July 2004 17:23 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
Does converting both coordinates to absolute (via
Figure#translateToAbsolute()) not work? If you do this, you shouldn't have
to adjust for the zoom scale.

"Larry Waldman" <lfw@andrew.cmu.edu> wrote in message
news:cdglv4$tif$1@eclipse.org...
> I know there must be a way to do this, but as yet, I have been unable to
> find how. Perhaps someone can help:
>
> I have the coordinates of the mouse cursor in the ViewPort, and, in short,
> what I am trying to do is figure out the proximity of the cursor to
> components (any object) in the viewport.
>
> I can adjust the cursor location based on the zoom scale, and then compare
> to the figure's center location -- however, this does not take into
> account the state of the scrollbars.
>
> I'm thinking there MUST be a simple way to either translate objects'
> coordinates to viewport coordinates or vice-versa, and translate the
> cursor's coordinates to absolute coordinates which can be compared with
> figures' coordinates.
>
> Can anyone help?
>
> Thanks!
>
> LFW
>
Re: Location Translation [message #143584 is a reply to message #143374] Tue, 20 July 2004 19:36 Go to previous message
Larry Waldman is currently offline Larry WaldmanFriend
Messages: 9
Registered: July 2009
Junior Member
Thanks...that gave me the solution to the problem. I converted all
coordinates to absolute, and then, once my comparison was done, converted
back to relative to the viewport.

I'm just curious, does anyone else believe that this is an extremely long
winded way to do something simple? Seems like there should be a way to
simply do a one way conversion that adjusts for scroll and zoom. Just my
thoughts.

LFW

Pratik Shah wrote:

> Does converting both coordinates to absolute (via
> Figure#translateToAbsolute()) not work? If you do this, you shouldn't have
> to adjust for the zoom scale.

> "Larry Waldman" <lfw@andrew.cmu.edu> wrote in message
> news:cdglv4$tif$1@eclipse.org...
> > I know there must be a way to do this, but as yet, I have been unable to
> > find how. Perhaps someone can help:
> >
> > I have the coordinates of the mouse cursor in the ViewPort, and, in short,
> > what I am trying to do is figure out the proximity of the cursor to
> > components (any object) in the viewport.
> >
> > I can adjust the cursor location based on the zoom scale, and then compare
> > to the figure's center location -- however, this does not take into
> > account the state of the scrollbars.
> >
> > I'm thinking there MUST be a simple way to either translate objects'
> > coordinates to viewport coordinates or vice-versa, and translate the
> > cursor's coordinates to absolute coordinates which can be compared with
> > figures' coordinates.
> >
> > Can anyone help?
> >
> > Thanks!
> >
> > LFW
> >
Previous Topic:Properties view changes and EditPart
Next Topic:CreationToolEntry and SimpleFactory
Goto Forum:
  


Current Time: Fri Dec 27 02:34:05 GMT 2024

Powered by FUDForum. Page generated in 0.03847 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top