EMMA Coverage Report (generated Sun Feb 05 10:43:15 CET 2012)
[all classes][de.uka.ipd.sdq.pcm.gmf.composite]

COVERAGE SUMMARY FOR SOURCE FILE [SocketFigure.java]

nameclass, %method, %block, %line, %
SocketFigure.java0%   (0/2)0%   (0/8)0%   (0/298)0%   (0/42)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SocketFigure0%   (0/1)0%   (0/6)0%   (0/281)0%   (0/36)
SocketFigure (int, AbstractBorderFigure$POSITION_TYPE): void 0%   (0/1)0%   (0/5)0%   (0/2)
access$0 (SocketFigure): Point 0%   (0/1)0%   (0/3)0%   (0/1)
createAnchorExternal (): ConnectionAnchor 0%   (0/1)0%   (0/6)0%   (0/1)
createAnchorInternal (): ConnectionAnchor 0%   (0/1)0%   (0/6)0%   (0/1)
getArcCenter (): Point 0%   (0/1)0%   (0/81)0%   (0/12)
paintFigure (Graphics): void 0%   (0/1)0%   (0/180)0%   (0/19)
     
class SocketFigure$SocketAnchor0%   (0/1)0%   (0/2)0%   (0/17)0%   (0/6)
SocketFigure$SocketAnchor (SocketFigure, IFigure): void 0%   (0/1)0%   (0/7)0%   (0/3)
getLocation (Point): Point 0%   (0/1)0%   (0/10)0%   (0/3)

1package de.uka.ipd.sdq.pcm.gmf.composite;
2 
3import org.eclipse.draw2d.AbstractConnectionAnchor;
4import org.eclipse.draw2d.ConnectionAnchor;
5import org.eclipse.draw2d.Graphics;
6import org.eclipse.draw2d.IFigure;
7import org.eclipse.draw2d.PositionConstants;
8import org.eclipse.draw2d.geometry.Point;
9import org.eclipse.draw2d.geometry.Rectangle;
10 
11/**
12 * Represents the UML style --( border figure
13 * which rotates depending on the side the figure
14 * is located in relation to it's parent.
15 * 
16 * @author Philipp Meier
17 */
18public class SocketFigure extends AbstractBorderFigure {
19        
20        /**
21         * @param size width and hight of the figure in logical units (LP)
22         * @param posType position type of the figure
23         */
24        public SocketFigure(int logicalSize, POSITION_TYPE posType) {
25                super(logicalSize, posType);
26        }
27                
28        protected void paintFigure(Graphics graphics) {
29                super.paintFigure(graphics);
30                
31                if (getBorderItemLocator() == null) {
32                        System.out.println("border item locator null in SocketFigure.paintFigure");
33                }
34                
35                // determine the side the border item is located relative to it's parent
36                int side = (getBorderItemLocator() == null ? PositionConstants.WEST : getBorderItemLocator().getCurrentSideOfParent());
37                
38                Rectangle rect = new Rectangle();
39                graphics.getClip(rect);
40        
41                // depending on the side draw a line from the center of the side of the bounding box touching the parent
42                // to the center of the bounding box and then draw a half circle in the remaining half of the bounding box
43                // so that the open side points away from the parent
44                switch(side){
45                case PositionConstants.EAST:
46                        graphics.drawLine(rect.getLeft().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
47                        graphics.drawArc(rect.getCenter().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2, 90, 180);
48                        break;
49                case PositionConstants.WEST:
50                        graphics.drawLine(rect.getRight().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
51                        graphics.drawArc(rect.getLeft().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2, -90, 180);
52                        break;
53                case PositionConstants.NORTH:
54                        graphics.drawLine(rect.getCenter().x,rect.getBottom().y,rect.getCenter().x,rect.getCenter().y);
55                        graphics.drawArc(rect.getCenter().x-rect.width/4, rect.getTop().y, rect.height/2, rect.height/2, 180, 180);
56                        break;
57                case PositionConstants.SOUTH:
58                        graphics.drawLine(rect.getCenter().x,rect.getTop().y,rect.getCenter().x,rect.getCenter().y);
59                        graphics.drawArc(rect.getCenter().x-rect.width/4, rect.getCenter().y, rect.height/2, rect.height/2, 0, 180);
60                        break;
61                }
62        }
63        
64        /**
65         * @return the center between the ( part of the figure
66         * relative to the position of the figure
67         */
68        private Point getArcCenter() {
69                int side = (getBorderItemLocator() == null ? PositionConstants.WEST : getBorderItemLocator().getCurrentSideOfParent());
70                
71                Rectangle rect = getBounds();
72                Point result = null;
73                
74                switch(side){
75                case PositionConstants.EAST:
76                        result = new Point(rect.getCenter().x+rect.height/4, rect.getCenter().y);
77                        break;
78                case PositionConstants.WEST:
79                        result = new Point(rect.getLeft().x+rect.height/4, rect.getCenter().y);
80                        break;
81                case PositionConstants.NORTH:
82                        result = new Point(rect.getCenter().x, rect.getTop().y+rect.height/4);
83                        break;
84                case PositionConstants.SOUTH:
85                        result = new Point(rect.getCenter().x, rect.getCenter().y+rect.height/4);
86                        break;
87                }
88                return result;
89        }        
90        
91        /**
92         * places the anchor point at the center of the ( part of the figure
93         */
94        private class SocketAnchor extends AbstractConnectionAnchor {
95 
96                public SocketAnchor(IFigure owner) {
97                        super(owner);
98                }
99                
100                public Point getLocation(Point reference) {
101                        Point p = getArcCenter();
102                        getOwner().translateToAbsolute(p);
103                        return p;
104                }
105        }
106 
107        protected ConnectionAnchor createAnchorInternal() {
108                return new SocketAnchor(this);
109        }
110        
111        protected ConnectionAnchor createAnchorExternal() {
112                return new StemAnchor(this);
113        }
114}

[all classes][de.uka.ipd.sdq.pcm.gmf.composite]
EMMA 2.0.9414 (unsupported private build) (C) Vladimir Roubtsov