getCreateCommand called repeatedly [message #227706] |
Sun, 10 December 2006 18:28  |
Eclipse User |
|
|
|
Originally posted by: taylorpj.btopenworld.com
Hi there,
I am still getting to grips with GEF, and am currently trying to create
new elements in a simple diagram editor.
I am a bit confused by some of the GEF examples I have seen. It seems that
EditPolicy.getCreateCommand() is called every time a mouse move event
occurs, while adding a new element. The examples create a new command in
this method, so it seems to me that a lot of new objects are being created
unnecessarily. Have I misunderstood something?
For an example, see LogicXYLayoutEditPolicy in the Logic Editor example.
Thanks.
|
|
|
|
|
Re: getCreateCommand called repeatedly [message #227895 is a reply to message #227784] |
Tue, 12 December 2006 13:43   |
Eclipse User |
|
|
|
Originally posted by: none.unknown.com
No. They are used to find out if the object can be created at the current
mouse location. That's the price you pay for instant feedback. The memory
footprint is not affected though, since when a new command is gotten, the
previous one is thrown away.
"Paul Taylor" <taylorpj@btopenworld.com> wrote in message
news:915852.1165832012538.JavaMail.root@cp1.javalobby.org...
> Thanks for your reply. I understand that the model object is created only
> once, but I am concerned with the Command object that creates the model
> object. It seems to me that a Command object will be created for every
> mouse event that is processed, and that the final Command object will
> create the model object.
>
> Aren't all those other Command objects redundant?
>
>
> > The new model object is only created once. See
> > CreateRequest#getNewObject()
> > which is what the LXYLEP is using. You could defer
> > the creation of that one
> > object as well until the command is executed by using
> >
> > CreateRequest#getNewObjectType() instead of
> > getNewObject().
> >
> > "Paul Taylor" <taylorpj@btopenworld.com> wrote in
> > message
> > news:066f674bf0f77ca4f8e7e8d76adcc756$1@www.eclipse.or
> > g...
> > > Hi there,
> > >
> > > I am still getting to grips with GEF, and am
> > currently trying to create
> > > new elements in a simple diagram editor.
> > > I am a bit confused by some of the GEF examples I
> > have seen. It seems that
> > > EditPolicy.getCreateCommand() is called every time
> > a mouse move event
> > > occurs, while adding a new element. The examples
> > create a new command in
> > > this method, so it seems to me that a lot of new
> > objects are being created
> > > unnecessarily. Have I misunderstood something?
> > >
> > > For an example, see LogicXYLayoutEditPolicy in the
> > Logic Editor example.
> > >
> > > Thanks.
> > >
> >
|
|
|
Re: getCreateCommand called repeatedly [message #228239 is a reply to message #227784] |
Mon, 18 December 2006 11:15  |
Eclipse User |
|
|
|
Originally posted by: none.ibm.com
"Paul Taylor" <taylorpj@btopenworld.com> wrote in message
news:915852.1165832012538.JavaMail.root@cp1.javalobby.org...
> Thanks for your reply. I understand that the model object is created only
> once, but I am concerned with the Command object that creates the model
> object. It seems to me that a Command object will be created for every
> mouse event that is processed, and that the final Command object will
> create the model object.
So what? The MouseEvent itself is an object. The location of the mouse is an
object. Searching for the proper target creates objects. There are objects
getting created everywhere.
|
|
|
Powered by
FUDForum. Page generated in 0.03891 seconds