Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » SnapTo : How to find nearest snap to point
SnapTo : How to find nearest snap to point [message #227685] Sun, 10 December 2006 12:32 Go to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hello all,

I am having a snapto issue which I was hoping that someone here could help
me with.
The attached file should show the problem easier than any textual
description.
Basically I have drawn a grid like layout on the Freeform layer for a fixed
layout diagram.
Blocks are created on the diagram and will fit into one of the holders you
see.
I am using snapto so that the blocks can only be placed in the holders.
However when trying to use the holder rectangle to help me with snapto I am
having a problem.
The code below is basically saying that if the top left hand corner of the
block I am moving
is in one of my holder rectangles then snap it so its fits in holder.

The problem is that, as you can see from the image attached, that it is
possible that the top left hand
corner does not fit in any of my holder rectangles as the space between them
is sufficient for this to happen.
So what I need to do I guess is find the nearest one.
I was thinking that I was probably not the first person to have this issue
and was hoping someone could help me out ?

Thanks a lot.
for(int i =0; i < blockPositionRecs.length && !finished; i++)

{

if(blockPositionRecs[i].contains(baseRect.x, baseRect.y))

{

match = blockPositionRecs[i];

finished = true;

System.out.println("\n\nMatch found - " + match);

}

}


Re: SnapTo : How to find nearest snap to point [message #227888 is a reply to message #227685] Tue, 12 December 2006 18:49 Go to previous message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

I also have another question.
I have been trying to fix the problem described below by having each place
holder rectangle increase in size so that even if the top right of the
rectangle I am moving does not touch any of my place holder rectangles then
it has to touch the extended ones as they fill all the available space.

Anyway I was debugging what I am trying to do and I found that the
SnapToHelper is not always called when I thought it would be.
More particularly if I move my rectangle by a very small amount then the
SnapToHelper isn't called at all.
Anyone know why this happens or more particularly how I can change the
precision to a smaller amount ?

Thanks.



"Alan" <awm_abu@yahoo.com> wrote in message
news:elgunq$be5$1@utils.eclipse.org...
> Hello all,
>
> I am having a snapto issue which I was hoping that someone here could help
> me with.
> The attached file should show the problem easier than any textual
> description.
> Basically I have drawn a grid like layout on the Freeform layer for a
> fixed layout diagram.
> Blocks are created on the diagram and will fit into one of the holders you
> see.
> I am using snapto so that the blocks can only be placed in the holders.
> However when trying to use the holder rectangle to help me with snapto I
> am having a problem.
> The code below is basically saying that if the top left hand corner of the
> block I am moving
> is in one of my holder rectangles then snap it so its fits in holder.
>
> The problem is that, as you can see from the image attached, that it is
> possible that the top left hand
> corner does not fit in any of my holder rectangles as the space between
> them is sufficient for this to happen.
> So what I need to do I guess is find the nearest one.
> I was thinking that I was probably not the first person to have this issue
> and was hoping someone could help me out ?
>
> Thanks a lot.
> for(int i =0; i < blockPositionRecs.length && !finished; i++)
>
> {
>
> if(blockPositionRecs[i].contains(baseRect.x, baseRect.y))
>
> {
>
> match = blockPositionRecs[i];
>
> finished = true;
>
> System.out.println("\n\nMatch found - " + match);
>
> }
>
> }
>
>
>
Previous Topic:Java "OutofMemory" problem
Next Topic:Centered, fixed-sized diagram with correctly positioned grid and rulers
Goto Forum:
  


Current Time: Thu Apr 25 12:04:34 GMT 2024

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

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

Back to the top