Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zest's GraphNode#initFigure() and Graph#registerItem() called twice unnecessarily?
Zest's GraphNode#initFigure() and Graph#registerItem() called twice unnecessarily? [message #243395] Wed, 04 June 2008 18:43
Stefan Tucker is currently offline Stefan TuckerFriend
Messages: 4
Registered: July 2009
Junior Member
It looks to me as if GraphNode's constructor calls
GraphNode#initFigure() twice, which allocates the node's GraphLabel twice.

1. Instantiate GraphNode(g, 0, "z")

2. GraphNode's ctor calls initModel()

3. That calls graph.registerItem(this)

4. That calls item.getFigure()

5. this.nodeFigure is null, so it calls initFigure() which calls
createFigureForModel() and sets this.nodeFigure

6. It returns back up to the ctor, which promptly calls initFigure()
(again), even though this.nodeFigure is already not null.

7. Finally, GraphNode's ctor calls registerItem(this) again.
(initModel() called it already.)

These unnecessary allocations and calls probably affect performance and
make Zest less efficient than it could be.

I suspect either the ctor shouldn't call initFigure() itself or
initFigure() should only call createFigureForModel() if this.nodeFigure
is null.

P.S. Why does initFigure() set this.nodeFigure as well as return it so
that the caller can set this.nodeFigure (again)?
Previous Topic:fillPath() in ScaledGraphics
Next Topic:Copy GEF diagram as WMF?
Goto Forum:

Current Time: Mon May 30 14:36:46 GMT 2016

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

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