01: /**
02: *
03: */package newprocess.diagram.cust.layouter;
04:
05: import org.eclipse.draw2d.Figure;
06: import org.eclipse.draw2d.IFigure;
07: import org.eclipse.draw2d.StackLayout;
08: import org.eclipse.draw2d.geometry.Rectangle;
09: import org.eclipse.gmf.runtime.diagram.ui.figures.BorderedNodeFigure;
10:
11: /**
12: * @author sh
13: *
14: */
15: public class ConditionStackLayout extends StackLayout {
16:
17: public void layout(IFigure figure) {
18: if (figure instanceof Figure) {
19: Figure fig = (Figure) figure;
20: if (fig.getChildren().isEmpty()) {
21: super .layout(figure);
22: return;
23: }
24:
25: Object fig2 = fig.getChildren().get(0);
26: if (fig2 instanceof BorderedNodeFigure) {
27: BorderedNodeFigure fig3 = (BorderedNodeFigure) fig2;
28: Rectangle condRect = fig.getClientArea();
29:
30: // regard the height of the port figure
31: int y = condRect.y + 5;
32: // lower the height because of the port on top and on bottom
33: int height = condRect.height - 10;
34:
35: Rectangle newRect = new Rectangle(condRect.x, y,
36: condRect.width, height);
37: fig3.setBounds(newRect);
38: } else
39: super.layout(figure);
40: } else
41: super.layout(figure);
42: }
43: }
|