Last change
on this file since 25 was
5,
checked in by zeiss, 14 years ago
|
|
-
Property svn:mime-type set to
text/plain
|
File size:
1.2 KB
|
Line | |
---|
1 | package de.ugoe.cs.swe.bnftools.ui.views.syntaxdiagram;
|
---|
2 | import org.eclipse.draw2d.AbstractConnectionAnchor;
|
---|
3 | import org.eclipse.draw2d.IFigure;
|
---|
4 | import org.eclipse.draw2d.geometry.Point;
|
---|
5 | import org.eclipse.draw2d.geometry.PrecisionPoint;
|
---|
6 | import org.eclipse.draw2d.geometry.Rectangle;
|
---|
7 |
|
---|
8 | class SideAnchor extends AbstractConnectionAnchor {
|
---|
9 |
|
---|
10 | public static int LEFT_SIDE = 1;
|
---|
11 | public static int RIGHT_SIDE = 2;
|
---|
12 | private int side = LEFT_SIDE;
|
---|
13 | private SideAnchor heightRef = null;
|
---|
14 |
|
---|
15 | public SideAnchor(IFigure owner, int side) {
|
---|
16 | super(owner);
|
---|
17 | this.side = side;
|
---|
18 | }
|
---|
19 |
|
---|
20 | public SideAnchor(IFigure owner, SideAnchor heightRef, int side) {
|
---|
21 | super(owner);
|
---|
22 | this.side = side;
|
---|
23 | this.heightRef = heightRef;
|
---|
24 | }
|
---|
25 |
|
---|
26 | public Point getLocation(Point loc) {
|
---|
27 | Rectangle r = getOwner().getBounds();
|
---|
28 | int x,y;
|
---|
29 |
|
---|
30 | if (side == SideAnchor.LEFT_SIDE) {
|
---|
31 | x = r.x ;
|
---|
32 |
|
---|
33 | } else {
|
---|
34 | x = r.x + r.width;
|
---|
35 | }
|
---|
36 | if (heightRef == null) {
|
---|
37 | y = r.y + r.height/2 ;
|
---|
38 | } else {
|
---|
39 | Rectangle heightBounds = heightRef.getOwner().getBounds();
|
---|
40 | y = heightBounds.y + heightBounds.height/2;
|
---|
41 | }
|
---|
42 |
|
---|
43 | Point p = new PrecisionPoint(x, y);
|
---|
44 | getOwner().translateToAbsolute(p);
|
---|
45 |
|
---|
46 | return p;
|
---|
47 | }
|
---|
48 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.