source: default/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/views/syntaxdiagram/NonTerminalFigure.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.0 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.RectangleFigure;
8import org.eclipse.draw2d.StackLayout;
9import org.eclipse.swt.SWT;
10import org.eclipse.swt.graphics.Color;
11
12public class NonTerminalFigure extends SyntaxDiagramFigure {
13        private String nonterminalString;
14
15        public NonTerminalFigure(String nonterminalString) {
16                super();
17                this.nonterminalString = nonterminalString;
18
19                SyntaxDiagramFigure innerFigure = new SyntaxDiagramFigure();
20                setBorder(new LineMarginBorder(0, 0, 0));
21                innerFigure.setLayoutManager(new StackLayout());
22
23            FlowLayout layout = new FlowLayout();
24            layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
25            setLayoutManager(layout);   
26
27                RectangleFigure rectangle = new RectangleFigure();
28                rectangle.setAntialias(SWT.ON);
29                rectangle.setBackgroundColor(new Color(null, 220, 220, 220));
30                rectangle.setForegroundColor(new Color(null, 170, 170, 170));
31                innerFigure.add(rectangle);
32               
33                Label nonterminalStringLabel = new Label(this.nonterminalString);
34                nonterminalStringLabel.setForegroundColor(new Color(null, 200, 0, 0));
35                nonterminalStringLabel.setTextAlignment(PositionConstants.CENTER);
36                nonterminalStringLabel.setBorder(new MarginBorder(3,8,3,8));
37                innerFigure.add(nonterminalStringLabel);
38               
39                PathFigure leftPath = new PathFigure();
40                leftPath.setSourceAnchor(this.getLeftAnchor());
41                leftPath.setTargetAnchor(innerFigure.getLeftAnchor());
42
43                PathFigure rightPath = new PathFigure();
44                rightPath.setTargetDecoration(null);
45                rightPath.setSourceAnchor(innerFigure.getRightAnchor());
46                rightPath.setTargetAnchor(this.getRightAnchor());
47               
48                add(leftPath);
49                add(rightPath);
50               
51                add(innerFigure);
52        }
53
54        public String getTerminalString() {
55                return nonterminalString;
56        }
57
58        public void setTerminalString(String terminalString) {
59                this.nonterminalString = terminalString;
60        }
61
62}
Note: See TracBrowser for help on using the repository browser.