[5] | 1 | package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
|
---|
| 2 |
|
---|
| 3 | import org.eclipse.draw2d.Graphics;
|
---|
| 4 | import org.eclipse.draw2d.IFigure;
|
---|
| 5 | import org.eclipse.draw2d.LineBorder;
|
---|
| 6 | import org.eclipse.draw2d.geometry.Insets;
|
---|
| 7 |
|
---|
| 8 | public class LineMarginBorder extends LineBorder {
|
---|
| 9 | private Insets insets;
|
---|
| 10 | private int borderWidth;
|
---|
| 11 |
|
---|
| 12 | public LineMarginBorder(int horizontal, int vertical, int borderWidth) {
|
---|
| 13 | super(borderWidth);
|
---|
| 14 | insets = new Insets(vertical, horizontal, vertical, horizontal);
|
---|
| 15 | this.borderWidth = borderWidth;
|
---|
| 16 | }
|
---|
| 17 |
|
---|
| 18 | public LineMarginBorder(int top, int left, int bottom, int right,
|
---|
| 19 | int borderWidth) {
|
---|
| 20 | super(borderWidth);
|
---|
| 21 | insets = new Insets(top, left, bottom, right);
|
---|
| 22 | this.borderWidth = borderWidth;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public Insets getInsets(IFigure figure) {
|
---|
| 26 | return insets;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | public void paint(IFigure figure, Graphics graphics, Insets insets) {
|
---|
| 30 | if (borderWidth > 0) {
|
---|
| 31 | tempRect.setBounds(getPaintRectangle(figure, insets));
|
---|
| 32 | if (getWidth() % 2 == 1) {
|
---|
| 33 | tempRect.width--;
|
---|
| 34 | tempRect.height--;
|
---|
| 35 | }
|
---|
| 36 | tempRect.shrink(getWidth() / 2, getWidth() / 2);
|
---|
| 37 | graphics.setLineWidth(getWidth());
|
---|
| 38 | graphics.setLineStyle(getStyle());
|
---|
| 39 | if (getColor() != null)
|
---|
| 40 | graphics.setForegroundColor(getColor());
|
---|
| 41 | graphics.drawRectangle(tempRect);
|
---|
| 42 | }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | }
|
---|