Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » SnapToHelper class and dragging groups of EditParts
SnapToHelper class and dragging groups of EditParts [message #175114] Sat, 02 April 2005 16:59 Go to next message
Eclipse UserFriend
Originally posted by: jgreen.upb.de

Hi,
I have a specific problem with the SnapToHelper class.

I have implemented a custom SnapTo-class which works fine when dragging
EditParts: I've overwritten the method snapRectangle(...) to calculate
the correction when certain points snap.

This works fine, when dragging single EditParts.

Now, when I drag a GROUP of EditParts I can read them as well from the
given GroupRequest, but:
1. The baseRect that I get (see method signature below) depends on the
EditPart in the selection that I actually click on for dragging.
(Example: Imagine having selected two aligned rectangles and dragging
the two, let's say, that the one rectangle is at (10,10) and the other
placed at (110,10). Depending on the rect I *click on* and drag, the
baseRect I get is at (10,10) or (110,10))
2. -> So I do not have any information about to which gragged EditPart
the baseRect corresponds. The GroupRequest doesn't supply this or any
other info.
3. -> So I cannot determine the correct "virtual" positions of my
snap-Points in the group of EditParts that I need for snapping while I'm
dragging them.

See the signature, of the method here:
----------
snapRectangle(Request request, int snapOrientation,
PrecisionRectangle baseRect, PrecisionRectangle result)
----------

I hope that I could explain my problem clearly.
Might one lack sufficient information in the SnapToHelper-concept to do
this? Or am I missing something?

Thanks for any help.

Joel
Re: SnapToHelper class and dragging groups of EditParts [message #175207 is a reply to message #175114] Mon, 04 April 2005 03:19 Go to previous messageGo to next message
Pratik Shah is currently offline Pratik ShahFriend
Messages: 1077
Registered: July 2009
Senior Member
"Joel Greenyer" <jgreen@upb.de> wrote in message
news:d2mj97$lkr$1@news.eclipse.org...
> Hi,
> I have a specific problem with the SnapToHelper class.
>
> I have implemented a custom SnapTo-class which works fine when dragging
> EditParts: I've overwritten the method snapRectangle(...) to calculate
> the correction when certain points snap.
>
> This works fine, when dragging single EditParts.
>
> Now, when I drag a GROUP of EditParts I can read them as well from the
> given GroupRequest, but:
> 1. The baseRect that I get (see method signature below) depends on the
> EditPart in the selection that I actually click on for dragging.
> (Example: Imagine having selected two aligned rectangles and dragging
> the two, let's say, that the one rectangle is at (10,10) and the other
> placed at (110,10). Depending on the rect I *click on* and drag, the
> baseRect I get is at (10,10) or (110,10))

You also get the rectangle that is the union of all selected rectangles.

> 2. -> So I do not have any information about to which gragged EditPart
> the baseRect corresponds. The GroupRequest doesn't supply this or any
> other info.
> 3. -> So I cannot determine the correct "virtual" positions of my
> snap-Points in the group of EditParts that I need for snapping while I'm
> dragging them.

"Virtual" positions? The rectangle you get already should have absolute
coordinates if that's what you mean.

>
> See the signature, of the method here:
> ----------
> snapRectangle(Request request, int snapOrientation,
> PrecisionRectangle baseRect, PrecisionRectangle result)
> ----------
>
> I hope that I could explain my problem clearly.
> Might one lack sufficient information in the SnapToHelper-concept to do
> this? Or am I missing something?
>
> Thanks for any help.
>
> Joel
Re: SnapToHelper class and dragging groups of EditParts [message #175286 is a reply to message #175207] Mon, 04 April 2005 10:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jgreen.upb.de

Pratik Shah wrote:
> "Joel Greenyer" <jgreen@upb.de> wrote in message
> news:d2mj97$lkr$1@news.eclipse.org...
>
>>Hi,
>>I have a specific problem with the SnapToHelper class.
>>
>>I have implemented a custom SnapTo-class which works fine when dragging
>>EditParts: I've overwritten the method snapRectangle(...) to calculate
>>the correction when certain points snap.
>>
>>This works fine, when dragging single EditParts.
>>
>>Now, when I drag a GROUP of EditParts I can read them as well from the
>>given GroupRequest, but:
>>1. The baseRect that I get (see method signature below) depends on the
>>EditPart in the selection that I actually click on for dragging.
>>(Example: Imagine having selected two aligned rectangles and dragging
>>the two, let's say, that the one rectangle is at (10,10) and the other
>>placed at (110,10). Depending on the rect I *click on* and drag, the
>>baseRect I get is at (10,10) or (110,10))
>
>
> You also get the rectangle that is the union of all selected rectangles.
Where? Which one? I just have the one baseRect PrecisionRectangle passed
to the method...
>
>
>>2. -> So I do not have any information about to which gragged EditPart
>>the baseRect corresponds. The GroupRequest doesn't supply this or any
>>other info.
>>3. -> So I cannot determine the correct "virtual" positions of my
>>snap-Points in the group of EditParts that I need for snapping while I'm
>>dragging them.
>
>
> "Virtual" positions? The rectangle you get already should have absolute
> coordinates if that's what you mean.
With "Virtual" positions I mean the positions of the snap points of the
EditParts when they are dragged. (Unlike in the SnapToGeometry, where
you have snapping rows and cols, I have certain snap points specifically
defined on the EditParts)
>
>
>>See the signature, of the method here:
>>----------
>>snapRectangle(Request request, int snapOrientation,
>> PrecisionRectangle baseRect, PrecisionRectangle result)
>>----------
>>
>>I hope that I could explain my problem clearly.
>>Might one lack sufficient information in the SnapToHelper-concept to do
>>this? Or am I missing something?
>>
>>Thanks for any help.
>>
>>Joel
>
>
>
Re: SnapToHelper class and dragging groups of EditParts [message #175327 is a reply to message #175114] Mon, 04 April 2005 14:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

> 3. -> So I cannot determine the correct "virtual" positions of my
> snap-Points in the group of EditParts that I need for snapping while I'm
> dragging them.

What are you trying to snap to? Are the snap locations a function of what
was clicked on?

There is a method which get's called containing two rectangles. You could
perhaps compare the rectangle to the bounds of the editparts in the group
request to identify which one was clicked on. Or, you could customize the
drag tracker to make the clicked-on part become the primary (lastd one I
think) selection prior to the drag beginning.
Re: SnapToHelper class and dragging groups of EditParts [message #175411 is a reply to message #175327] Mon, 04 April 2005 18:12 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jgreen.zitmail.uni-paderborn.de

This is a multi-part message in MIME format.
--------------020800030508060803060906
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Hi Randy,

Randy Hudson wrote:
>>3. -> So I cannot determine the correct "virtual" positions of my
>>snap-Points in the group of EditParts that I need for snapping while I'm
>>dragging them.
>
>
> What are you trying to snap to? Are the snap locations a function of what
> was clicked on?
>

I retrieve the snap points relatively to their EditPart's location.
To illustrate my problem I've attached this screenshot. You can see,
that the snapping works for the EditPart I've clicked on (I couldn't
screenshot the mouse, I clicked on this splitter-EditPart). (The red
rects and arrows are my snap-feedback.) But, I cannot correctly
determine the potential snap-points of the other EditParts in the group,
because I cannot correctly tell, which EditPart belongs to the
baseRect-parameter passed to the snapRectangle(..)-method (-> which one
was clicked on).

> There is a method which get's called containing two rectangles. You could
> perhaps compare the rectangle to the bounds of the editparts in the group
> request to identify which one was clicked on.

As you can see, there are many EditParts with a fixed, equal size.

> Or, you could customize the
> drag tracker to make the clicked-on part become the primary (lastd one I
> think) selection prior to the drag beginni ng.

Maybe I could overwrite the DragTracker like this...ok. Good idea. I'll see.

But couldn't this whole SnapToHelper-mechanism generally be modified in
a way that one gets passed this information. I did not get into the
internals too much, though.
Idea: Another useful thing would be an abstract SnapToPoint base class.

Thank you very much for your help.

Joel

>
>


--------------020800030508060803060906
Content-Type: image/gif;
name="group-snapping.gif"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="group-snapping.gif"

R0lGODlhHAHuALMAAB8fH8hkZF9fX76+vkBAQFJSUqGhob+/v15eXq2trbKy sgAAAODg4P//
/wAAAAAAACH5BAAAAAAALAAAAAAcAe4AAAT/sMlJq7046827/2AojmRpnmiq fkvrrqH7wqy8
0Hiu7+c9+TwMsDEMVoZFo3LJ7FFs0Kh0SkVWr9jps8ntejnIb9g7/prP3HJ6 S2aj33AdVGyj
y+L4/CqpX/f/gCB8gUaDhIeBhog5iouOcI2PKpGSlX6WcpiaaJSbIp2eoXui MKCkpySmqBmq
q65gryatsbRHtSOzt7W5tLy6r77Av8MdwUoCyMnKy8zNyAHQ0dLT08TWxkEC Ctvc3d7f4NvU
4+PWxNg82uHr7OIB4XzQ5sPoOurt+N/Q8Bfy87r1ctzLR1DBPnDxAvwDGGhg wXwHFQyYODHh
wlsBYTh8iC8ixYr9/xRe7AVoI0d2Hj9aHBkrowqTJ9elpLiSpSuXKWDGBDcT pAV/NlfhPKFz
p7532z4OqBn01NASRY1667k0ZFOheqJK5UaV6dVQT0do3eqOm1KvXzeFFTGW bFeraUWtBdHW
LdJvaONamuuh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uIZoqIUrCIfg1YbQRYd4OGxtGIJ5iEN2qIZ9eGZ7yIGBuF9tKIGFqD12 OIeJyGGH2Ihd
SIYByIeQSGh/SIiV+DfrF1r/AIiZODbfwRHtR4mf2DSh+P8Qo1iKGPhZb5OK quiArGg1nfiG
rzhKwHQtsxh0jChbt9h4teCJtUg0vQh+w4CIwch2LUaMv7CLx5gxw2h+xMCM x9hNSUUuuehw
0th0z9h74YeJzXg027h85gCMzRiO02cOxviNwihN1sh86vh+sWgzrviOaReP /3KNV0ePZXSK
BYGPEJeNWMWPBOGP+geQAyWQ+TCP+aiPibSJTKSQDImNixiRYCeJ/EeK32iR 9keOx3iJukiR
E0mL+hiSFBl0JFmSV+eR2EiRGhl/HBmMKnl1BtlOJ7mQDFmTKIlaJImFTFiF PcmTSxiUUPiT
VliURFmDdpiUSrmUTNmUTvmUUBkYlVI5lVRZlVZ5lViZlVq5lVzZlV6ZHxEA ADs=
--------------020800030508060803060906--
Re: SnapToHelper class and dragging groups of EditParts [message #175425 is a reply to message #175411] Mon, 04 April 2005 18:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

It looks like you want to override which source rectangles get used. The
snap helper is designed to handle any number of rectangles in decreasing
priority. So, you just need to provide those two highlighted rectangles in
your picture.

Do this by customizing the DragEditPartsTracker. Open a bugzilla if you
find that it is more difficult than it should be.
Re: SnapToHelper class and dragging groups of EditParts (Problem solved) [message #175991 is a reply to message #175114] Thu, 07 April 2005 10:09 Go to previous message
Eclipse UserFriend
Originally posted by: jgreen.upb.de

Hi,
I just want to add that I solved my problem by not only overwriting
----------
snapRectangle(Request request, int snapOrientation,
PrecisionRectangle baseRect, PrecisionRectangle result)
----------

but also

----------
public int snapRectangle(Request request, int snapOrientation,
PrecisionRectangle[] baseRects, PrecisionRectangle result) {
----------
which supplies me also with a "union" baseRect. This rectangle is a
union of the figure's bounds of the group of EdtiParts beeing dragged.

The first method is abstract in SnapToHelper, so I didn't bother with
overwriting other methods at first.

Thanks for the help and hints anyway!

Joel


Joel Greenyer wrote:
> Hi,
> I have a specific problem with the SnapToHelper class.
>
> I have implemented a custom SnapTo-class which works fine when dragging
> EditParts: I've overwritten the method snapRectangle(...) to calculate
> the correction when certain points snap.
>
> This works fine, when dragging single EditParts.
>
> Now, when I drag a GROUP of EditParts I can read them as well from the
> given GroupRequest, but:
> 1. The baseRect that I get (see method signature below) depends on the
> EditPart in the selection that I actually click on for dragging.
> (Example: Imagine having selected two aligned rectangles and dragging
> the two, let's say, that the one rectangle is at (10,10) and the other
> placed at (110,10). Depending on the rect I *click on* and drag, the
> baseRect I get is at (10,10) or (110,10))
> 2. -> So I do not have any information about to which gragged EditPart
> the baseRect corresponds. The GroupRequest doesn't supply this or any
> other info.
> 3. -> So I cannot determine the correct "virtual" positions of my
> snap-Points in the group of EditParts that I need for snapping while I'm
> dragging them.
>
> See the signature, of the method here:
> ----------
> snapRectangle(Request request, int snapOrientation,
> PrecisionRectangle baseRect, PrecisionRectangle result)
> ----------
>
> I hope that I could explain my problem clearly.
> Might one lack sufficient information in the SnapToHelper-concept to do
> this? Or am I missing something?
>
> Thanks for any help.
>
> Joel
Previous Topic:Moving bendpoints -- help!
Next Topic:What's the exact meaning of Primary Selection and Normal Selection?
Goto Forum:
  


Current Time: Sun Feb 05 15:03:44 GMT 2023

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

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

Back to the top