|
|
Re: Wrong positioning of figures if editor is scrolled [message #179332 is a reply to message #179302] |
Tue, 26 April 2005 11:38   |
Eclipse User |
|
|
|
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 09:10  |
Eclipse User |
|
|
|
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
>>>
>>>
>>>
>>
>>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.03020 seconds