Resizing Figures children [message #167967] |
Sun, 13 January 2008 18:17 |
Eclipse User |
|
|
|
Originally posted by: surayya.daimi.au.dk
I have RcetEditPart with correspondent complex figure RectFigure
RectFigure extends NodeFigure{
public RectFigure() {
XYLayout xy_layout = new XYLayout();
panel_left = new NodeFigure();
panel_right = new NodeFigure();
TwoBorderedFigure double_border = new TwoBorderedFigure();
******* double_border.setSize(200,70);
createContents();
xy_layout.setConstraint(double_border,new Rectangle(0,0,-1,-1));
xy_layout.setConstraint(panel_left, new Rectangle(10,30,-1,-1));
xy_layout.setConstraint(panel_right,new Rectangle(100, 30, -1 ,-1));
this.setLayoutManager(xy_layout);
this.add(double_border);
this.add(panel_left);
this.add(panel_right);
}
}
And TwoBorderedFigure is just this:
public void paint(Graphics graphics) {
// TODO Auto-generated method stub
Rectangle r = getBounds().getCopy();
graphics.drawRoundRectangle(new Rectangle r.x+10,r.y+10,r.width-20,
r.height-20), 7,7);
graphics.drawRoundRectangle(new Rectangle (r.x+14,r.y+14,r.width-28,
r.height-28), 7,7);
super.paint(graphics);
}
My goal is to place panel left_panel(all Xes labels layout out as
toolbarlayout) and right_panel(all Ys labels layed out as toolbar layout)
on the doubled lines produced by TwoBorderedFigure as on the drwaing:
-------------
-------------
|| ||
XXXXXX YYYYYY
|| ||
XXXXXX YYYYYY
|| ||
XXXXXX YYYYYY
|| ||
-------------
-------------
This figure is layed out using XYLayout
Problem is that i don't want to statically assign the size of the border
to this:
double_border.setSize(200,70);
I want that panels lay presizely on lines and labels can have different
length so static size for border figure will destroy the design
I would like to know the bounds of the parent figure but this is always a
rectangle of 0000 zeros when asked inside the RectFigure
How can i first get the size of the figure that is not null. I guess i
should do it from its editpart asking the model but because i am working
with gmf (autogenerated code)and not gef i don't know how to get the size
of the figure and on creation of the figure set the
double_border.setSize(200,70); to a dynamic value of the figure.
Hope you understand what i mean
I really spent lots of time finding out how this can be fixed to layout
labels on top of border lines
Any help will be appreciated
Regards Surayya
|
|
|
|
Powered by
FUDForum. Page generated in 0.03441 seconds