Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Wrong positioning of figures if editor is scrolled
Wrong positioning of figures if editor is scrolled [message #179252] Tue, 26 April 2005 10:06 Go to next message
Roger Villars is currently offline Roger VillarsFriend
Messages: 57
Registered: July 2009
Member
Hi!



I have a problem with the positioning of figures when they are created with
the palette.



If my editor pane is bigger than the viewable region and is scrolled, then
my figures aren't placed at the right position (the position of the mouse
cursor). They are shifted by the amount by which the editor is scrolled (see
picture).



I think there's a problem with absolute and relative coordinates. Any
suggestions what I'm doing wrong?



Roger


  • Attachment: Shift.JPG
    (Size: 74.85KB, Downloaded 105 times)
Re: Wrong positioning of figures if editor is scrolled [message #179302 is a reply to message #179252] Tue, 26 April 2005 14:26 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Normally XYLayoutEditPolicy will convert the absolute location of the
request ot a relative constraint. Perhaps you've overridden a method and
gotten rid of the conversion?

"Roger Villars" <roger.villars@mimacom.ch> wrote in message
news:d4l3v9$3rt$1@news.eclipse.org...
> Hi!
>
>
>
> I have a problem with the positioning of figures when they are created
> with the palette.
>
>
>
> If my editor pane is bigger than the viewable region and is scrolled, then
> my figures aren't placed at the right position (the position of the mouse
> cursor). They are shifted by the amount by which the editor is scrolled
> (see picture).
>
>
>
> I think there's a problem with absolute and relative coordinates. Any
> suggestions what I'm doing wrong?
>
>
>
> Roger
>
>
>
Re: Wrong positioning of figures if editor is scrolled [message #179332 is a reply to message #179302] Tue, 26 April 2005 15:38 Go to previous messageGo to next message
Roger Villars is currently offline Roger VillarsFriend
Messages: 57
Registered: July 2009
Member
Ahh, I found the problem. getCreateCommand(final CreateRequest request) in
my subclass of
XYLayoutEditPolicy was:

protected Command getCreateCommand(final CreateRequest request)
{
if (request.getNewObjectType() == State.class)
return new StateCreateCommand(workflow,
(State)request.getNewObject(),request.getLocation().x,
request.getLocation().y);
else if (request.getNewObjectType() == Transition.class)
return new TransitionCreateCommand(workflow,
(Transition)request.getNewObject(), request.getLocation().x,
request.getLocation().y);
else return null;
}

It took x and y directly from the request without converting them to
relative coordinates.
Now it does it like this:

protected Command getCreateCommand(final CreateRequest request)
{
Rectangle constraint = (Rectangle)getConstraintFor(request);

if (request.getNewObjectType() == State.class)
return new StateCreateCommand(workflow,
(State)request.getNewObject(),constraint.x, constraint.y);
else if (request.getNewObjectType() == Transition.class)
return new TransitionCreateCommand(workflow,
(Transition)request.getNewObject(), constraint.x, constraint.y);
else return null;
}

This works better. Thank you very much Randy!

"Randy Hudson" <none@us.ibm.com> schrieb im Newsbeitrag
news:d4lj8m$q0n$1@news.eclipse.org...
> Normally XYLayoutEditPolicy will convert the absolute location of the
> request ot a relative constraint. Perhaps you've overridden a method and
> gotten rid of the conversion?
>
> "Roger Villars" <roger.villars@mimacom.ch> wrote in message
> news:d4l3v9$3rt$1@news.eclipse.org...
>> Hi!
>>
>>
>>
>> I have a problem with the positioning of figures when they are created
>> with the palette.
>>
>>
>>
>> If my editor pane is bigger than the viewable region and is scrolled,
>> then my figures aren't placed at the right position (the position of the
>> mouse cursor). They are shifted by the amount by which the editor is
>> scrolled (see picture).
>>
>>
>>
>> I think there's a problem with absolute and relative coordinates. Any
>> suggestions what I'm doing wrong?
>>
>>
>>
>> Roger
>>
>>
>>
>
>
Connections too - Wrong positioning of figures if editor is scrolled [message #179975 is a reply to message #179332] Mon, 02 May 2005 13:10 Go to previous message
Eclipse UserFriend
Originally posted by: binti.ksu.edu

Hey Roger and others,

Unless I read your mail, I never knew this problem was in my tool too. But
Thanks, I found it and solved it too.

But still the connections have the same problem. I have my own anchor class
which returns a location where the connection needs to be created, it takes
this position from the request (Create Request) and reconnect request when I
try moving it. The code for this is in NodeEditPoliciy for the nodepart. I
do not have a getConstraintFor() method there.

Could anybody tell me how do I handle this here?

Thanks,
Binti.

"Roger Villars" <roger.villars@mimacom.ch> wrote in message
news:d4lne7$180$1@news.eclipse.org...
> Ahh, I found the problem. getCreateCommand(final CreateRequest request) in
> my subclass of
> XYLayoutEditPolicy was:
>
> protected Command getCreateCommand(final CreateRequest request)
> {
> if (request.getNewObjectType() == State.class)
> return new StateCreateCommand(workflow,
> (State)request.getNewObject(),request.getLocation().x,
> request.getLocation().y);
> else if (request.getNewObjectType() == Transition.class)
> return new TransitionCreateCommand(workflow,
> (Transition)request.getNewObject(), request.getLocation().x,
> request.getLocation().y);
> else return null;
> }
>
> It took x and y directly from the request without converting them to
> relative coordinates.
> Now it does it like this:
>
> protected Command getCreateCommand(final CreateRequest request)
> {
> Rectangle constraint = (Rectangle)getConstraintFor(request);
>
> if (request.getNewObjectType() == State.class)
> return new StateCreateCommand(workflow,
> (State)request.getNewObject(),constraint.x, constraint.y);
> else if (request.getNewObjectType() == Transition.class)
> return new TransitionCreateCommand(workflow,
> (Transition)request.getNewObject(), constraint.x, constraint.y);
> else return null;
> }
>
> This works better. Thank you very much Randy!
>
> "Randy Hudson" <none@us.ibm.com> schrieb im Newsbeitrag
> news:d4lj8m$q0n$1@news.eclipse.org...
>> Normally XYLayoutEditPolicy will convert the absolute location of the
>> request ot a relative constraint. Perhaps you've overridden a method and
>> gotten rid of the conversion?
>>
>> "Roger Villars" <roger.villars@mimacom.ch> wrote in message
>> news:d4l3v9$3rt$1@news.eclipse.org...
>>> Hi!
>>>
>>>
>>>
>>> I have a problem with the positioning of figures when they are created
>>> with the palette.
>>>
>>>
>>>
>>> If my editor pane is bigger than the viewable region and is scrolled,
>>> then my figures aren't placed at the right position (the position of the
>>> mouse cursor). They are shifted by the amount by which the editor is
>>> scrolled (see picture).
>>>
>>>
>>>
>>> I think there's a problem with absolute and relative coordinates. Any
>>> suggestions what I'm doing wrong?
>>>
>>>
>>>
>>> Roger
>>>
>>>
>>>
>>
>>
>
>
Previous Topic:Popup Menu
Next Topic:FlowLayoutEditPolicy & children
Goto Forum:
  


Current Time: Fri Apr 26 03:22:27 GMT 2024

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

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

Back to the top