Skip to main content



      Home
Home » Eclipse Projects » GEF » Scrolling - translating feedback
Scrolling - translating feedback [message #94434] Tue, 16 September 2003 10:01 Go to next message
Eclipse UserFriend
I've finally got paletteTools to work by writing Commands and getCommand()
[thanks Randy :) - although, I couldn't see the point of the factory]

Now, when I use CreateTool to drag out a new node, if the the viewport
isn't in the default position i.e. i've scrolled somewhere, then the
although the feedback was in the right place, the node would appear in the
wrong place. After looking in this newsgroup's archives I used
translateToRelative as below:

MyXYLayoutEditPolicy:
...
protected Command getCreateCommand(CreateRequest request) {
Command com= new net.eads.eclipse.EDIS.commands.CreateCommand();
Point tempLoc=request.getLocation();
// GefEditor.getViewModel().getOwner().getFigure().translateToA bsolute(tempLoc);
GefEditor.getViewModel().getOwner().getFigure().translateToR elative(tempLoc);
((CreateCommand)com).setLocation(tempLoc);
((CreateCommand)com).setSize(request.getSize());
return com;
}
...

This puts the actual node in the right place, but the feedback is still
offset.
I thought the request generated the feedback, since I'm not altering the
request, how can this happen?
I tried translateToAbsolute aswell but that put that offset the feedback
and DOUBLY offset the node....

The request is generated automatically by CreateTool and there is no other
mention of translateTo.... anyhwere else in my code.

Thanks for your help
Chris Heald
Re: Scrolling - translating feedback [message #94477 is a reply to message #94434] Tue, 16 September 2003 10:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Please see how LogicXYLayoutEditPolicy does exactly this. The problem with
feedback is that you have modified the request's actual Location.
request.getLocation() returns the Point by reference. Then you call
translate, which monkeys with the values. The feedback code ends up doing a
second translate.

"Chris Heald" <chris.heald@m.eads.net> wrote in message
news:bk752t$hs3$1@eclipse.org...
> I've finally got paletteTools to work by writing Commands and getCommand()
> [thanks Randy :) - although, I couldn't see the point of the factory]
>
> Now, when I use CreateTool to drag out a new node, if the the viewport
> isn't in the default position i.e. i've scrolled somewhere, then the
> although the feedback was in the right place, the node would appear in the
> wrong place. After looking in this newsgroup's archives I used
> translateToRelative as below:
>
> MyXYLayoutEditPolicy:
> ..
> protected Command getCreateCommand(CreateRequest request) {
> Command com= new net.eads.eclipse.EDIS.commands.CreateCommand();
> Point tempLoc=request.getLocation();
> //
GefEditor.getViewModel().getOwner().getFigure().translateToA bsolute(tempLoc)
;
>
GefEditor.getViewModel().getOwner().getFigure().translateToR elative(tempLoc)
;
> ((CreateCommand)com).setLocation(tempLoc);
> ((CreateCommand)com).setSize(request.getSize());
> return com;
> }
> ..
>
> This puts the actual node in the right place, but the feedback is still
> offset.
> I thought the request generated the feedback, since I'm not altering the
> request, how can this happen?
> I tried translateToAbsolute aswell but that put that offset the feedback
> and DOUBLY offset the node....
>
> The request is generated automatically by CreateTool and there is no other
> mention of translateTo.... anyhwere else in my code.
>
> Thanks for your help
> Chris Heald
>
Re: Scrolling - translating feedback [message #94535 is a reply to message #94477] Tue, 16 September 2003 10:39 Go to previous message
Eclipse UserFriend
Thanks very much - I've just used getCopy() on the request's location. I
should have realised it was passed by reference...
The example is quite a lot more complicated but essentially does the same
thing, right?
It also opens a whole new bag of worms/questions...! But, I'll try and
work them out for myself.
Thanks again for yr help.
Randy Hudson wrote:

> Please see how LogicXYLayoutEditPolicy does exactly this. The problem with
> feedback is that you have modified the request's actual Location.
> request.getLocation() returns the Point by reference. Then you call
> translate, which monkeys with the values. The feedback code ends up doing a
> second translate.

> "Chris Heald" <chris.heald@m.eads.net> wrote in message
> news:bk752t$hs3$1@eclipse.org...
> > I've finally got paletteTools to work by writing Commands and getCommand()
> > [thanks Randy :) - although, I couldn't see the point of the factory]
> >
> > Now, when I use CreateTool to drag out a new node, if the the viewport
> > isn't in the default position i.e. i've scrolled somewhere, then the
> > although the feedback was in the right place, the node would appear in the
> > wrong place. After looking in this newsgroup's archives I used
> > translateToRelative as below:
> >
> > MyXYLayoutEditPolicy:
> > ..
> > protected Command getCreateCommand(CreateRequest request) {
> > Command com= new net.eads.eclipse.EDIS.commands.CreateCommand();
> > Point tempLoc=request.getLocation();
> > //
> GefEditor.getViewModel().getOwner().getFigure().translateToA bsolute(tempLoc)
> ;
> >
> GefEditor.getViewModel().getOwner().getFigure().translateToR elative(tempLoc)
> ;
> > ((CreateCommand)com).setLocation(tempLoc);
> > ((CreateCommand)com).setSize(request.getSize());
> > return com;
> > }
> > ..
> >
> > This puts the actual node in the right place, but the feedback is still
> > offset.
> > I thought the request generated the feedback, since I'm not altering the
> > request, how can this happen?
> > I tried translateToAbsolute aswell but that put that offset the feedback
> > and DOUBLY offset the node....
> >
> > The request is generated automatically by CreateTool and there is no other
> > mention of translateTo.... anyhwere else in my code.
> >
> > Thanks for your help
> > Chris Heald
> >
Previous Topic:Contributors welcome
Next Topic:Connection routing over swimlanes
Goto Forum:
  


Current Time: Tue Jun 10 19:30:39 EDT 2025

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

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

Back to the top