Home » Eclipse Projects » GEF » Absolute Position
Absolute Position [message #123446] |
Mon, 22 March 2004 03:45  |
Eclipse User |
|
|
|
Originally posted by: sellai.yahoo.com
Hi,
I have the following figure,
(0,0)
-------------------------------
(10, 10) |
--------------- |
| (10, 10) | |
| |-------| | |
| | B | | |
| |-------| | |
| A | |
-------------- |
|
canvas |
-------------------------------
The position of B relative to A is (10, 10), but it's (20,20) relative to
the canvas and (20, 20) is the position i need.
Rectangle bounds = BFigure.getBounds().copy();
I use BFigure.translateToAbsolute(bounds) to find this position, at first
it works. However, when the Figure A is dragged downwards until the
scrolling bar appears, the result is different. Apparently, the new
position returned is the position of the figure relative to the canvas
area within the scrolling pane. How do i get the absolute position
relative to the canvas starting at (0,0)?
|
|
|
Re: Absolute Position [message #123874 is a reply to message #123446] |
Tue, 23 March 2004 16:42   |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"June" <sellai@yahoo.com> wrote in message news:c3m92u$skk$1@eclipse.org...
> Hi,
> I have the following figure,
>
> (0,0)
> -------------------------------
> (10, 10) |
> --------------- |
> | (10, 10) | |
> | |-------| | |
> | | B | | |
> | |-------| | |
> | A | |
> -------------- |
> |
> canvas |
> -------------------------------
>
> The position of B relative to A is (10, 10), but it's (20,20) relative to
> the canvas and (20, 20) is the position i need.
>
> Rectangle bounds = BFigure.getBounds().copy();
> I use BFigure.translateToAbsolute(bounds) to find this position, at first
> it works. However, when the Figure A is dragged downwards until the
> scrolling bar appears, the result is different. Apparently, the new
> position returned is the position of the figure relative to the canvas
> area within the scrolling pane. How do i get the absolute position
> relative to the canvas starting at (0,0)?
Whose (0,0) are you talking about? The result you are getting should be
relative to the Canvas' 0,0. The canvas==SWT control. Are you talking
about A's parent figure?
>
|
|
|
Re: Absolute Position [message #123974 is a reply to message #123874] |
Wed, 24 March 2004 01:04   |
Eclipse User |
|
|
|
Originally posted by: sellai.yahoo.com
Randy Hudson wrote:
> "June" <sellai@yahoo.com> wrote in message news:c3m92u$skk$1@eclipse.org...
> > Hi,
> > I have the following figure,
> >
> > (0,0)
> > -------------------------------
> > (10, 10) |
> > --------------- |
> > | (10, 10) | |
> > | |-------| | |
> > | | B | | |
> > | |-------| | |
> > | A | |
> > -------------- |
> > |
> > canvas |
> > -------------------------------
> Whose (0,0) are you talking about? The result you are getting should be
> relative to the Canvas' 0,0. The canvas==SWT control. Are you talking
> about A's parent figure?
Yup, i'm talking about A's parent figure. It may be the viewport figure,
i'm not sure. However, translateToAbsolute seems to be only getting the
value relative to the client area that the user has scrolled to. My
problem only starts when the side's scrolling bar starts to appear....
Do i need to use a combination of other translate methods to find the
location of B? Thanks for your help!
Regards,
June
|
|
|
Re: Absolute Position [message #124494 is a reply to message #123974] |
Fri, 26 March 2004 10:25  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
"June" <sellai@yahoo.com> wrote in message news:c3r8e0$ooj$1@eclipse.org...
> Randy Hudson wrote:
>
> > "June" <sellai@yahoo.com> wrote in message
news:c3m92u$skk$1@eclipse.org...
> > > Hi,
> > > I have the following figure,
> > >
> > > (0,0)
> > > -------------------------------
> > > (10, 10) |
> > > --------------- |
> > > | (10, 10) | |
> > > | |-------| | |
> > > | | B | | |
> > > | |-------| | |
> > > | A | |
> > > -------------- |
> > > |
> > > canvas |
> > > -------------------------------
>
>
> > Whose (0,0) are you talking about? The result you are getting should be
> > relative to the Canvas' 0,0. The canvas==SWT control. Are you talking
> > about A's parent figure?
>
> Yup, i'm talking about A's parent figure. It may be the viewport figure,
> i'm not sure. However, translateToAbsolute seems to be only getting the
> value relative to the client area that the user has scrolled to. My
> problem only starts when the side's scrolling bar starts to appear....
>
So, once you have something relative to the canvas, make it relative to A's
parent by calling:
a.translateToRelative(rectangle).
In other words, you want B's coordinates to be in the same coordinate system
in which A resides (which is A's parent). So "relative" means relative to
A's bounds. Don't think too hard ;-)
> Do i need to use a combination of other translate methods to find the
> location of B? Thanks for your help!
>
> Regards,
> June
>
>
|
|
|
Goto Forum:
Current Time: Sat Jul 05 03:15:11 EDT 2025
Powered by FUDForum. Page generated in 0.04428 seconds
|