Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Custom layout at diagram creation
Custom layout at diagram creation [message #233632] Mon, 15 June 2009 09:24 Go to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Hi,

I wish to layout my nodes in a TopDown Layout, I create a diagram with
default model elements in createInitialModel() method and create
equivalent nodes with ViewService.createDiagram() and
ViewService.createNode(),
Then I initialize bounds of my nodes using the following code :

Iterator entityNodeIterator = diagram.getChildren().iterator();;
int xMargin = 10;
int yMargin = 10;
int yCurrent = yMargin;
while(entityNodeIterator.hasNext()){
Node entityNode = (Node) entityNodeIterator.next();
Bounds bounds = (Bounds) entityNode.getLayoutConstraint();
bounds.setX(xMargin);
bounds.setY(yCurrent);
yCurrent += bounds.getHeight()+yMargin;
entityNode.setLayoutConstraint(bounds);
}

but my problem is that bounds.getHeight() == -1,

How can I initialize my node size to correct value depending of their
content?

Thanks.
Re: Custom layout at diagram creation [message #233674 is a reply to message #233632] Mon, 15 June 2009 10:38 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Esteban,

If bounds.getHeight() == -1 then Figure.getPreferredSize() method will be
used to determine diagram node height (same with width).
You can either use same logic or set height/width by your own code.

-----------------
Alex Shatalin
Re: Custom layout at diagram creation [message #233722 is a reply to message #233674] Mon, 15 June 2009 14:35 Go to previous messageGo to next message
Esteban Dugueperoux is currently offline Esteban DugueperouxFriend
Messages: 472
Registered: July 2009
Senior Member
Alex Shatalin a écrit :
> Hello Esteban,
>
> If bounds.getHeight() == -1 then Figure.getPreferredSize() method will
> be used to determine diagram node height (same with width).
> You can either use same logic or set height/width by your own code.
>
> -----------------
> Alex Shatalin
>
>
Hi Alex,

How can I get node's figures from my node while edit parts exist only
after diagram opening?
Re: Custom layout at diagram creation [message #233737 is a reply to message #233722] Mon, 15 June 2009 14:46 Go to previous message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Esteban,

> How can I get node's figures from my node while edit parts exist only
> after diagram opening?
You have to .. open the diagram. ;-) Then you can execute custom layout code
using positions os actual figures.

-----------------
Alex Shatalin
Previous Topic:add .xpt template
Next Topic:shouldProceed Changing the Text of Message Dialog
Goto Forum:
  


Current Time: Fri Mar 05 08:10:48 GMT 2021

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

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

Back to the top