source: default/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/views/syntaxdiagram/SyntaxDiagram.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: 1.7 KB
Line 
1package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
2
3import org.eclipse.draw2d.ColorConstants;
4import org.eclipse.draw2d.ToolbarLayout;
5
6public class SyntaxDiagram extends SyntaxDiagramFigure {
7        private SyntaxDiagramFigure lastFigure = null;
8
9        public SyntaxDiagram() {
10                ToolbarLayout contentsLayout = new ToolbarLayout();
11                contentsLayout.setSpacing(20);
12                contentsLayout.setVertical(false);
13                contentsLayout.setStretchMinorAxis(false);
14                contentsLayout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
15//              setForegroundColor(ColorConstants.darkGreen);
16//              setBorder(new LineBorder());
17                setLayoutManager(contentsLayout);
18                setBackgroundColor(ColorConstants.white);
19                setOpaque(true);
20        }
21
22        public void addSyntaxFigure(SyntaxDiagramFigure f) {
23               
24                if (lastFigure != null) {
25                        PathFigure sequenceConnectionPath = new PathFigure();
26                        sequenceConnectionPath.setTargetDecoration(null);
27                        sequenceConnectionPath.setSourceAnchor(lastFigure.getRightAnchor());
28                        sequenceConnectionPath.setTargetAnchor(f.getLeftAnchor());
29                        add(sequenceConnectionPath);
30                } else {
31                        PathFigure sequenceConnectionPath = new PathFigure();
32                        sequenceConnectionPath.setTargetDecoration(null);
33                        sequenceConnectionPath.setSourceAnchor(getLeftAnchor());
34                        sequenceConnectionPath.setTargetAnchor(f.getLeftAnchor());
35                        add(sequenceConnectionPath);
36                }
37               
38                add(f);
39                lastFigure  = f;
40        }
41       
42        public void finish() {
43                if (lastFigure != null) {
44                        PathFigure sequenceConnectionPath = new PathFigure();
45                        sequenceConnectionPath.setSourceAnchor(lastFigure.getRightAnchor());
46                        sequenceConnectionPath.setTargetAnchor(getRightAnchor());
47                        add(sequenceConnectionPath);
48                }
49        }
50}
Note: See TracBrowser for help on using the repository browser.