01: /*
02: * Created on 5 mai 2005
03: *
04: * @author Christelle
05: *
06: */
07: package org.openwfe.gpe.figures;
08:
09: import org.eclipse.draw2d.ColorConstants;
10: import org.eclipse.draw2d.Graphics;
11: import org.eclipse.draw2d.Label;
12: import org.eclipse.draw2d.MarginBorder;
13: import org.eclipse.draw2d.geometry.Rectangle;
14:
15: /**
16: * @author Christelle
17: *
18: * TODO To change the template for this generated type comment go to
19: * Window - Preferences - Java - Code Style - Code Templates
20: */
21: public class DefinedFigure extends SubgraphFigure {
22:
23: boolean selected;
24:
25: /**
26: * @param header
27: * @param footer
28: */
29: public DefinedFigure() {
30: super (new Label(""), new Label(""));
31: setBorder(new MarginBorder(3, 5, 3, 0));
32: setOpaque(true);
33: }
34:
35: protected void paintFigure(Graphics g) {
36: super .paintFigure(g);
37: Rectangle r = getBounds();
38: g.setBackgroundColor(ColorConstants.orange);
39: if (selected) {
40: g.setBackgroundColor(ColorConstants.menuBackgroundSelected);
41: g.setForegroundColor(ColorConstants.menuForegroundSelected);
42: }
43:
44: g.fillRectangle(r.x, r.y, 3, r.height);
45: g.fillRectangle(r.right() - 3, r.y, 3, r.height);
46: g.fillRectangle(r.x, r.bottom() - 18, r.width, 18);
47: g.fillRectangle(r.x, r.y, r.width, 18);
48: }
49:
50: public void setSelected(boolean selected) {
51: if (this.selected == selected)
52: return;
53: this.selected = selected;
54: if (!selected) {
55: getHeader().setForegroundColor(null);
56: getFooter().setForegroundColor(null);
57: } else {
58: getHeader().setForegroundColor(
59: ColorConstants.menuForegroundSelected);
60: getFooter().setForegroundColor(
61: ColorConstants.menuForegroundSelected);
62: }
63:
64: repaint();
65: }
66:
67: }
|