Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Intersects
Intersects [message #179043] Mon, 25 April 2005 15:26 Go to next message
Eclipse UserFriend
Originally posted by: james.willans.xactium.com

After almost two years of using GEF, I have to say that sometimes the
coordinate system still confuses me. In this instance I want to simply
test to see whether two figures intersect (one is some text on a
connection edge, the other is a node - although this detail is probably
not relevant).

So given those two figures:

IFigure text;
IFigure node;

My understanding is that text.getBounds().intersect(node.getBounds()) is
not guaranteed to work since each figure return the bounds according to
its coordinate system. However I thought that ensuring both bounds were
absolute:

Rectangle textRect = text.getBounds().getCopy();
text.translateToAbsolute(textRect);

Rectangle nodeRect = node.getBounds().getCopy();
node.translateToAbsolute(nodeRect);

would guarantee that both rectangles are in the same coordinate system,
and I could susbsequently test for:

textRect.getBounds().intersects(nodeRect);

However, this doesn't seem to work. Any ideas?

Thanks.

James
Re: Intersects [message #179149 is a reply to message #179043] Mon, 25 April 2005 17:09 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Your assumptions sound correct. It should work.

"James Willans" <james.willans@xactium.com> wrote in message
news:10ff81388d9b5a5c4c495f5326d84e10$1@www.eclipse.org...
> After almost two years of using GEF, I have to say that sometimes the
> coordinate system still confuses me. In this instance I want to simply
> test to see whether two figures intersect (one is some text on a
> connection edge, the other is a node - although this detail is probably
> not relevant).
>
> So given those two figures:
>
> IFigure text;
> IFigure node;
>
> My understanding is that text.getBounds().intersect(node.getBounds()) is
> not guaranteed to work since each figure return the bounds according to
> its coordinate system. However I thought that ensuring both bounds were
> absolute:
>
> Rectangle textRect = text.getBounds().getCopy();
> text.translateToAbsolute(textRect);
>
> Rectangle nodeRect = node.getBounds().getCopy();
> node.translateToAbsolute(nodeRect);
>
> would guarantee that both rectangles are in the same coordinate system,
> and I could susbsequently test for:
>
> textRect.getBounds().intersects(nodeRect);
>
> However, this doesn't seem to work. Any ideas?
>
> Thanks.
>
> James
>
>
>
>
Re: Intersects [message #179205 is a reply to message #179043] Mon, 25 April 2005 21:36 Go to previous message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
"James Willans" <james.willans@xactium.com> wrote in message
news:10ff81388d9b5a5c4c495f5326d84e10$1@www.eclipse.org...
> After almost two years of using GEF, I have to say that sometimes the
> coordinate system still confuses me. In this instance I want to simply
> test to see whether two figures intersect (one is some text on a
> connection edge, the other is a node - although this detail is probably
> not relevant).
>
> So given those two figures:
>
> IFigure text;
> IFigure node;
>
> My understanding is that text.getBounds().intersect(node.getBounds()) is
> not guaranteed to work since each figure return the bounds according to
> its coordinate system. However I thought that ensuring both bounds were
> absolute:
>
> Rectangle textRect = text.getBounds().getCopy();
> text.translateToAbsolute(textRect);
>
> Rectangle nodeRect = node.getBounds().getCopy();
> node.translateToAbsolute(nodeRect);
>
> would guarantee that both rectangles are in the same coordinate system,
> and I could susbsequently test for:
>
> textRect.getBounds().intersects(nodeRect);

There is no getBounds() method on Rectangle, so you couldn't possibly be
doing exactly what you mention here. If you're invoking text.getBounds()
here, that obviously is your problem.

>
> However, this doesn't seem to work. Any ideas?
>
> Thanks.
>
> James
>
>
>
>
Previous Topic:calculate printer page size
Next Topic:Source and doc. plugins don't work in GEF 3.1M6?
Goto Forum:
  


Current Time: Sun Jan 29 20:15:56 GMT 2023

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

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

Back to the top