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 [SourceFigure.java]

nameclass, %method, %block, %line, %
SourceFigure.java0%   (0/2)0%   (0/8)0%   (0/494)0%   (0/74)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SourceFigure0%   (0/1)0%   (0/6)0%   (0/477)0%   (0/68)
SourceFigure (int, AbstractBorderFigure$POSITION_TYPE): void 0%   (0/1)0%   (0/5)0%   (0/2)
access$0 (SourceFigure): 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)
getSourceCenter (): Point 0%   (0/1)0%   (0/81)0%   (0/12)
paintFigure (Graphics): void 0%   (0/1)0%   (0/376)0%   (0/51)
     
class SourceFigure$SourceAnchor0%   (0/1)0%   (0/2)0%   (0/17)0%   (0/6)
SourceFigure$SourceAnchor (SourceFigure, 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 event source -|> border figure
13 * which rotates depending on the side the figure
14 * is located in relation to it's parent.
15 * 
16 * @author Benjamin Klatt
17 */
18public class SourceFigure extends AbstractBorderFigure {
19        
20        /**
21         * @param size width and height of the figure in logical units (LP)
22         * @param posType position type of the figure
23         */
24        public SourceFigure(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:
42                // - a line from the center of the side of the bounding box touching the parent
43                //                 to the center of the bounding box. Result: "-"
44                // - a line between the centers of the orthogonal borders of the bounding box. Result: "-|"
45                // - a line from the center of the left orthogonal border to the center 
46                //                of the border not connected with the parent. Result: "-|\"
47                // - a line from the center of the left orthogonal border to the center 
48                //                of the border not connected with the parent. Result: "-|>"
49                switch(side){
50                case PositionConstants.EAST:
51                        graphics.drawLine(rect.getLeft().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
52                        graphics.drawLine(rect.getCenter().x,rect.getTop().y+rect.height/4,rect.getCenter().x,rect.getBottom().y-rect.height/4);
53                        graphics.drawLine(rect.getCenter().x,rect.getTop().y+rect.height/4,rect.getRight().x-rect.width/4,rect.getCenter().y);
54                        graphics.drawLine(rect.getCenter().x,rect.getBottom().y-rect.height/4,rect.getRight().x-rect.width/4,rect.getCenter().y);
55                        break;
56                case PositionConstants.WEST:
57                        graphics.drawLine(rect.getRight().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
58                        graphics.drawLine(rect.getCenter().x,rect.getTop().y+rect.height/4,rect.getCenter().x,rect.getBottom().y-rect.height/4);
59                        graphics.drawLine(rect.getCenter().x,rect.getTop().y+rect.height/4,rect.getLeft().x+rect.width/4,rect.getCenter().y);
60                        graphics.drawLine(rect.getCenter().x,rect.getBottom().y-rect.height/4,rect.getLeft().x+rect.width/4,rect.getCenter().y);
61                        break;
62                case PositionConstants.NORTH:
63                        graphics.drawLine(        rect.getCenter().x,
64                                                                rect.getBottom().y,
65                                                                rect.getCenter().x,
66                                                                rect.getCenter().y);
67                        
68                        graphics.drawLine(        rect.getLeft().x+rect.width/4, 
69                                                                rect.getCenter().y, 
70                                                                rect.getRight().x-rect.width/4, 
71                                                                rect.getCenter().y);
72                        
73                        graphics.drawLine(        rect.getRight().x-rect.width/4, 
74                                                                rect.getCenter().y,
75                                                                rect.getCenter().x,
76                                                                rect.getTop().y+rect.height/4);
77                        
78                        graphics.drawLine(        rect.getLeft().x+rect.width/4, 
79                                                                rect.getCenter().y,
80                                                                rect.getCenter().x,
81                                                                rect.getTop().y+rect.height/4);
82 
83                        break;
84                case PositionConstants.SOUTH:
85                        graphics.drawLine(        rect.getCenter().x,
86                                                                rect.getTop().y,
87                                                                rect.getCenter().x,
88                                                                rect.getCenter().y);
89 
90                        graphics.drawLine(        rect.getLeft().x+rect.width/4, 
91                                                                rect.getCenter().y, 
92                                                                rect.getRight().x-rect.width/4, 
93                                                                rect.getCenter().y);
94                        
95                        graphics.drawLine(        rect.getLeft().x+rect.width/4, 
96                                                                rect.getCenter().y,
97                                                                rect.getCenter().x,
98                                                                rect.getBottom().y-rect.height/4);
99                        
100                        graphics.drawLine(        rect.getRight().x-rect.width/4, 
101                                                                rect.getCenter().y,
102                                                                rect.getCenter().x,
103                                                                rect.getBottom().y-rect.height/4);
104                        break;
105                }
106        }
107        
108        /**
109         * Get the point representing the pike of the source figure.
110         * 
111         * @return The point representing the location of the pike 
112         */
113        private Point getSourceCenter() {
114                int side = (getBorderItemLocator() == null ? PositionConstants.WEST : getBorderItemLocator().getCurrentSideOfParent());
115                
116                Rectangle rect = getBounds();
117                Point result = null;
118                
119                switch(side){
120                case PositionConstants.EAST:
121                        result = new Point(rect.getRight().x-rect.width/4, rect.getCenter().y);
122                        break;
123                case PositionConstants.WEST:
124                        result = new Point(rect.getLeft().x+rect.width/4, rect.getCenter().y);
125                        break;
126                case PositionConstants.NORTH:
127                        result = new Point(rect.getCenter().x, rect.getTop().y+rect.height/4);
128                        break;
129                case PositionConstants.SOUTH:
130                        result = new Point(rect.getCenter().x, rect.getBottom().y-rect.height/4);
131                        break;
132                }
133                return result;
134        }        
135        
136        /**
137         * places the anchor point at the center of the ( part of the figure
138         */
139        private class SourceAnchor extends AbstractConnectionAnchor {
140 
141                public SourceAnchor(IFigure owner) {
142                        super(owner);
143                }
144                
145                public Point getLocation(Point reference) {
146                        Point p = getSourceCenter();
147                        getOwner().translateToAbsolute(p);
148                        return p;
149                }
150        }
151 
152        protected ConnectionAnchor createAnchorInternal() {
153                return new SourceAnchor(this);
154        }
155        
156        protected ConnectionAnchor createAnchorExternal() {
157                return new StemAnchor(this);
158        }
159}

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