source: default/trunk/de.ugoe.cs.swe.bnftools.ebnf.ui/src/de/ugoe/cs/swe/bnftools/ui/views/syntaxdiagram/LineMarginBorder.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.3 KB
Line 
1package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
2
3import org.eclipse.draw2d.Graphics;
4import org.eclipse.draw2d.IFigure;
5import org.eclipse.draw2d.LineBorder;
6import org.eclipse.draw2d.geometry.Insets;
7
8public 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}
Note: See TracBrowser for help on using the repository browser.