source: default/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/views/syntaxdiagram/TerminalFigure.java @ 5

Last change on this file since 5 was 5, checked in by zeiss, 14 years ago
  • Property svn:mime-type set to text/plain
File size: 2.1 KB
Line 
1package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
2
3import org.eclipse.draw2d.FlowLayout;
4import org.eclipse.draw2d.Label;
5import org.eclipse.draw2d.MarginBorder;
6import org.eclipse.draw2d.PositionConstants;
7import org.eclipse.draw2d.RoundedRectangle;
8import org.eclipse.draw2d.StackLayout;
9import org.eclipse.draw2d.geometry.Dimension;
10import org.eclipse.swt.SWT;
11import org.eclipse.swt.graphics.Color;
12
13public 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}
Note: See TracBrowser for help on using the repository browser.