|getCreateCommand called repeatedly [message #227706]
||Sun, 10 December 2006 23:28
Originally posted by: taylorpj.btopenworld.com|
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.
|Re: getCreateCommand called repeatedly [message #227895 is a reply to message #227784]
||Tue, 12 December 2006 18:43
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" <email@example.com> wrote in message
> 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" <firstname.lastname@example.org> wrote in
> > message
> > news:email@example.com
> > 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.
> > >
Powered by FUDForum
. Page generated in 0.02705 seconds