01: package org.openwfe.gpe.figures;
02:
03: import org.eclipse.draw2d.Figure;
04: import org.eclipse.draw2d.IFigure;
05: import org.eclipse.draw2d.geometry.Dimension;
06: import org.eclipse.draw2d.geometry.Rectangle;
07:
08: import org.openwfe.gpe.parts.DummyLayout;
09:
10: public class SubgraphFigure extends Figure {
11:
12: IFigure contents;
13: IFigure footer;
14: IFigure header;
15:
16: public SubgraphFigure(IFigure header, IFigure footer) {
17: contents = new Figure();
18: contents.setLayoutManager(new DummyLayout());
19: add(contents);
20: add(this .header = header);
21: add(this .footer = footer);
22: }
23:
24: public IFigure getContents() {
25: return contents;
26: }
27:
28: public IFigure getFooter() {
29: return footer;
30: }
31:
32: public IFigure getHeader() {
33: return header;
34: }
35:
36: /**
37: * @see org.eclipse.draw2d.Figure#getPreferredSize(int, int)
38: */
39: public Dimension getPreferredSize(int wHint, int hHint) {
40: Dimension dim = new Dimension();
41: dim.width = getFooter().getPreferredSize().width;
42: dim.width += getInsets().getWidth();
43: dim.height = 25;
44: return dim;
45: }
46:
47: public void setBounds(Rectangle rect) {
48: super .setBounds(rect);
49: rect = Rectangle.SINGLETON;
50: getClientArea(rect);
51: contents.setBounds(rect);
52: Dimension size = footer.getPreferredSize();
53: footer.setLocation(rect.getBottomLeft().translate(0,
54: -size.height));
55: footer.setSize(size);
56:
57: size = header.getPreferredSize();
58: header.setSize(size);
59: header.setLocation(rect.getLocation());
60: }
61:
62: public void setSelected(boolean value) {
63: }
64:
65: }
|