Problem with draw2d layout [message #164248] |
Tue, 18 January 2005 09:12 |
Eclipse User |
|
|
|
Originally posted by: pengfai81.mail.yahoo.com
hi...all
I intend to create a custom layout which can display the figure based on
the calculation. Can anyone direct me?
I try to println the rect value. The location is generated but i wonder i
can't display the figure.
public void layout(IFigure parent)
{ Rectangle area = parent.getClientArea();
List children = parent.getChildren();
IFigure child;
for (int i=0;i<children.size();i++)
{ child = (IFigure)children.get(i);
Rectangle rect = new Rectangle();
rect.x = (int)(center.getBounds().x + radius*(Math.cos
(i*getAngle())));
rect.y = (int)(center.getBounds().y + radius*(Math.sin
(i*getAngle())));
}
child.setBounds(rect);
}
}
thanks in advance .....
|
|
|
|
|
Re: Problem with draw2d layout [message #164542 is a reply to message #164361] |
Wed, 19 January 2005 07:25 |
Eclipse User |
|
|
|
Originally posted by: pengfai81.mail.yahoo.com
node1 node1
| /
| /
| but /
center node3 ----center
/ \ \
/ \ \
/ \ \
node3 node2 node2
figure 1 figure 2
Hi...yes.
I have came up with the custom layout.
But the nodes are displayed like the figure2 diagram.
How i set the node1 location always on par with the central node?
I noticed that the last node alwyas will be the same location regardless
the number of the nodes i added in. Thinks it runs based on anti-clockwise.
public void layout(IFigure parent)
{ Rectangle area = parent.getClientArea();
List children = parent.getChildren();
IFigure child;
for (int i=0;i<children.size();i++)
{ child = (IFigure)children.get(i);
Rectangle rect = new Rectangle();
if (child.equals(center)){continue;}
rect.x = (int)(center.getBounds().x + radius*(Math.cos
(i*getAngle())));
rect.y = (int)(center.getBounds().y + radius*(Math.sin
(i*getAngle())));
}
area.x = rect.x;
area.y = rect.y;
child.setBounds(area);
}
}
Thanks .....
|
|
|
Powered by
FUDForum. Page generated in 0.03368 seconds