[5] | 1 | package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
|
---|
| 2 |
|
---|
| 3 | import org.eclipse.draw2d.ColorConstants;
|
---|
| 4 | import org.eclipse.draw2d.ToolbarLayout;
|
---|
| 5 |
|
---|
| 6 | public 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 | }
|
---|