Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » initial layout & createFigure()
initial layout & createFigure() [message #65006] Mon, 17 February 2003 17:06 Go to next message
Eclipse UserFriend
Originally posted by: user.domain.invalid

My GEF Editor reads an xml file and attempts to represent it with
figures. Since node locations are not stored in the xml file, I need to
write code to handle an initial layout--otherwise all of the nodes just
stack up ontop of each other.

I attempted to use a class variable in my NodeEditPart to keep track of
instances so that I could stagger the display of newly created nodes.

protected IFigure createFigure() {

NodeFigure nf = new NodeFigure();
Point location = new Point(instanceNumber * 200 + 10, 20);
nf.setLocation(location);
Object obj = getModel();
if(obj instanceof Controller){
Controller c = (Controller) obj;
nf.setText(c.displayName());
}
return nf;
}

This proved to be a very bad idea :). What is the right way to handle this?

John-Mason Shackelford

Software Developer
Pearson Educational Measurement - eMeasurement Group

2510 North Dodge St.
Iowa City, IA 52245
ph. 319-354-9200x6214
john-mason.shackelford@pearson.com
http://etest.ncspearson.com
Re: initial layout & createFigure() [message #65072 is a reply to message #65006] Mon, 17 February 2003 18:29 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

<user@domain.invalid> wrote in message
news:3E5116AA.3080202@domain.invalid...
> My GEF Editor reads an xml file and attempts to represent it with
> figures. Since node locations are not stored in the xml file, I need to
> write code to handle an initial layout--otherwise all of the nodes just
> stack up ontop of each other.

Can you detect the presence of an "un-annotated" (See you next post) model
and perform an initial intelligent layout? Probably try to do whatever the
user would do manually.

> I attempted to use a class variable in my NodeEditPart to keep track of
> instances so that I could stagger the display of newly created nodes.
>
> protected IFigure createFigure() {
>
> NodeFigure nf = new NodeFigure();
> Point location = new Point(instanceNumber * 200 + 10, 20);
> nf.setLocation(location);
> Object obj = getModel();
> if(obj instanceof Controller){
> Controller c = (Controller) obj;
> nf.setText(c.displayName());
> }
> return nf;
> }
>
> This proved to be a very bad idea :). What is the right way to handle
this?

You should be using an XYLayout. One way to handle this would be in the
code in the child EditPart that sets the constraint in the XYLayout
associated with the child. If the child *model* has no stored constraint,
then generate one based on the child's index in the parent. Such as new
Rectangle (index*avgWidth, 20, avgWidth, avgHeight).
>
> John-Mason Shackelford
>
> Software Developer
> Pearson Educational Measurement - eMeasurement Group
>
> 2510 North Dodge St.
> Iowa City, IA 52245
> ph. 319-354-9200x6214
> john-mason.shackelford@pearson.com
> http://etest.ncspearson.com
>
Previous Topic:Need help fixing "class must implement abstract method" error !!
Next Topic:Difference between version 2.02 and 2.1
Goto Forum:
  


Current Time: Fri Jan 03 05:21:03 GMT 2025

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

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

Back to the top