1 | package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
|
---|
2 |
|
---|
3 | import org.eclipse.draw2d.FlowLayout;
|
---|
4 | import org.eclipse.draw2d.Label;
|
---|
5 | import org.eclipse.draw2d.MarginBorder;
|
---|
6 | import org.eclipse.draw2d.PositionConstants;
|
---|
7 | import org.eclipse.draw2d.RoundedRectangle;
|
---|
8 | import org.eclipse.draw2d.StackLayout;
|
---|
9 | import org.eclipse.draw2d.geometry.Dimension;
|
---|
10 | import org.eclipse.swt.SWT;
|
---|
11 | import org.eclipse.swt.graphics.Color;
|
---|
12 |
|
---|
13 | public class TerminalFigure extends SyntaxDiagramFigure {
|
---|
14 | private String terminalString;
|
---|
15 |
|
---|
16 | public TerminalFigure(String terminalString) {
|
---|
17 | super();
|
---|
18 | this.terminalString = terminalString;
|
---|
19 |
|
---|
20 | SyntaxDiagramFigure innerFigure = new SyntaxDiagramFigure();
|
---|
21 | setBorder(new LineMarginBorder(0, 0, 0));
|
---|
22 | innerFigure.setLayoutManager(new StackLayout());
|
---|
23 |
|
---|
24 | FlowLayout layout = new FlowLayout();
|
---|
25 | layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
|
---|
26 | setLayoutManager(layout);
|
---|
27 |
|
---|
28 | RoundedRectangle rectangle = new RoundedRectangle();
|
---|
29 | rectangle.setAntialias(SWT.ON);
|
---|
30 | rectangle.setCornerDimensions(new Dimension(16,16));
|
---|
31 | rectangle.setBackgroundColor(new Color(null, 250, 210, 210));
|
---|
32 | rectangle.setForegroundColor(new Color(null, 250, 180, 180));
|
---|
33 | innerFigure.add(rectangle);
|
---|
34 |
|
---|
35 | Label terminalStringLabel = new Label(this.terminalString);
|
---|
36 | terminalStringLabel.setForegroundColor(new Color(null, 0, 0, 200));
|
---|
37 | terminalStringLabel.setTextAlignment(PositionConstants.CENTER);
|
---|
38 | terminalStringLabel.setBorder(new MarginBorder(3,8,3,8));
|
---|
39 | innerFigure.add(terminalStringLabel);
|
---|
40 |
|
---|
41 | PathFigure leftPath = new PathFigure();
|
---|
42 | leftPath.setSourceAnchor(this.getLeftAnchor());
|
---|
43 | leftPath.setTargetAnchor(innerFigure.getLeftAnchor());
|
---|
44 |
|
---|
45 | PathFigure rightPath = new PathFigure();
|
---|
46 | rightPath.setTargetDecoration(null);
|
---|
47 | rightPath.setSourceAnchor(innerFigure.getRightAnchor());
|
---|
48 | rightPath.setTargetAnchor(this.getRightAnchor());
|
---|
49 |
|
---|
50 | add(leftPath);
|
---|
51 | add(rightPath);
|
---|
52 |
|
---|
53 | add(innerFigure);
|
---|
54 | }
|
---|
55 |
|
---|
56 | public String getTerminalString() {
|
---|
57 | return terminalString;
|
---|
58 | }
|
---|
59 |
|
---|
60 | public void setTerminalString(String terminalString) {
|
---|
61 | this.terminalString = terminalString;
|
---|
62 | }
|
---|
63 |
|
---|
64 | }
|
---|