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

nameclass, %method, %block, %line, %
InfrastructureRequiredRoleManualFigure.java0%   (0/2)0%   (0/8)0%   (0/669)0%   (0/49)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InfrastructureRequiredRoleManualFigure0%   (0/1)0%   (0/6)0%   (0/658)0%   (0/45)
InfrastructureRequiredRoleManualFigure (int, AbstractBorderFigure$POSITION_TY... 0%   (0/1)0%   (0/5)0%   (0/2)
access$0 (InfrastructureRequiredRoleManualFigure): Rectangle 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)
getTargetConnectionFigureBounds (): Rectangle 0%   (0/1)0%   (0/151)0%   (0/12)
paintFigure (Graphics): void 0%   (0/1)0%   (0/487)0%   (0/28)
     
class InfrastructureRequiredRoleManualFigure$RectangleAnchor0%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
InfrastructureRequiredRoleManualFigure$RectangleAnchor (InfrastructureRequire... 0%   (0/1)0%   (0/7)0%   (0/3)
getBox (): Rectangle 0%   (0/1)0%   (0/4)0%   (0/1)

1package de.uka.ipd.sdq.pcm.gmf.composite;
2 
3import org.eclipse.draw2d.ChopboxAnchor;
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.Rectangle;
9 
10/**
11 * Represents the border figure --[ for provided infrastructure roles. The figure is rotated depending on it's relative location with respect to it's parent.
12 * 
13 * @author groenda
14 */
15public class InfrastructureRequiredRoleManualFigure extends AbstractBorderFigure {
16        
17        /**
18         * @param size width and height of the figure in logical units (LP)
19         * @param posType position type of the figure
20         */
21        public InfrastructureRequiredRoleManualFigure(int logicalSize, POSITION_TYPE posType) {
22                super(logicalSize, posType);
23        }        
24        
25        protected void paintFigure(Graphics graphics) {
26                super.paintFigure(graphics);
27                
28                if (getBorderItemLocator() == null) {
29                        throw new IllegalStateException("border item locator null in InfrastructureProvidedRoleFigure.paintFigure");
30                }
31                
32                // determine the side the border item is located relative to it's parent
33                int side = (getBorderItemLocator() == null ? PositionConstants.EAST : getBorderItemLocator().getCurrentSideOfParent());
34                
35                Rectangle rect = new Rectangle();
36                graphics.getClip(rect);
37                
38                // shrink rect so the last pixel of the circle is not clipped by the bounding box
39                rect.shrink(1, 1);
40                
41                /* Figure:
42                 *   +-
43                 * --|
44                 *   +-
45                 */
46                switch(side){
47                case PositionConstants.EAST:
48                        // stem
49                        graphics.drawLine(rect.getLeft().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
50                        // |
51                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*1/8, rect.getCenter().x, rect.getTop().y+rect.height*7/8);
52                        // upper
53                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*1/8, rect.getCenter().x+rect.width*3/8, rect.getTop().y+rect.height*1/8);
54                        // lower
55                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*7/8, rect.getCenter().x+rect.width*3/8, rect.getTop().y+rect.height*7/8);
56                        break;
57                case PositionConstants.WEST:
58                        graphics.drawLine(rect.getRight().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
59                        // |
60                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*1/8, rect.getCenter().x, rect.getTop().y+rect.height*7/8);
61                        // upper
62                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*1/8, rect.getCenter().x-rect.width*3/8, rect.getTop().y+rect.height*1/8);
63                        // lower
64                        graphics.drawLine(rect.getCenter().x, rect.getTop().y+rect.height*7/8, rect.getCenter().x-rect.width*3/8, rect.getTop().y+rect.height*7/8);
65                        break;
66                case PositionConstants.NORTH:
67                        graphics.drawLine(rect.getCenter().x,rect.getBottom().y,rect.getCenter().x,rect.getCenter().y);
68                        // |
69                        graphics.drawLine(rect.getLeft().x+rect.width*1/8, rect.getCenter().y, rect.getRight().x-rect.width*1/8, rect.getCenter().y);
70                        // upper
71                        graphics.drawLine(rect.getLeft().x+rect.width*1/8, rect.getCenter().y, rect.getLeft().x+rect.width*1/8, rect.getCenter().y-rect.height*3/8);
72                        // lower
73                        graphics.drawLine(rect.getRight().x-rect.width*1/8, rect.getCenter().y, rect.getRight().x-rect.width*1/8, rect.getCenter().y-rect.height*3/8);
74                        break;
75                case PositionConstants.SOUTH:
76                        graphics.drawLine(rect.getCenter().x,rect.getTop().y,rect.getCenter().x,rect.getCenter().y);
77                        // |
78                        graphics.drawLine(rect.getLeft().x+rect.width*1/8, rect.getCenter().y, rect.getRight().x-rect.width*1/8, rect.getCenter().y);
79                        // upper
80                        graphics.drawLine(rect.getLeft().x+rect.width*1/8, rect.getCenter().y, rect.getLeft().x+rect.width*1/8, rect.getCenter().y+rect.height*3/8);
81                        // lower
82                        graphics.drawLine(rect.getRight().x-rect.width*1/8, rect.getCenter().y, rect.getRight().x-rect.width*1/8, rect.getCenter().y+rect.height*3/8);
83                        break;
84                }
85        }
86        
87        /**
88         * @return the rectangle surrounding the [ part of the figure
89         * relative to the position of the figure
90         */
91        private Rectangle getTargetConnectionFigureBounds() {
92                int side = (getBorderItemLocator() == null ? PositionConstants.EAST : getBorderItemLocator().getCurrentSideOfParent());
93        
94                Rectangle rect = getBounds();
95                Rectangle result = null;
96                
97                switch(side){
98                case PositionConstants.EAST:
99                        result = new Rectangle(rect.getCenter().x, rect.getTop().y+rect.height*1/8, rect.width*3/8, rect.height*6/8);
100                        break;
101                case PositionConstants.WEST:
102                        result = new Rectangle(rect.getLeft().x+rect.width*1/8, rect.getTop().y+rect.height*1/8, rect.width*3/8, rect.height*6/8);
103                        break;
104                case PositionConstants.NORTH:
105                        result = new Rectangle(rect.getCenter().x-rect.width*3/8, rect.getTop().y+rect.height*1/8, rect.width*6/8, rect.height*3/8);
106                        break;
107                case PositionConstants.SOUTH:
108                        result = new Rectangle(rect.getCenter().x-rect.width*3/8, rect.getCenter().y, rect.height*6/8, rect.height*3/8);
109                        break;
110                }
111                return result;
112        }
113        
114        /**Anchor providing a connection point to the rectangular connection part of {@link InfrastructureRequiredRoleManualFigure}.
115         * @author groenda
116         *
117         */
118        private class RectangleAnchor extends ChopboxAnchor {
119                public RectangleAnchor(IFigure owner) {
120                        super(owner);
121                }
122                
123                @Override
124                protected Rectangle getBox() {
125                        return getTargetConnectionFigureBounds();
126                }
127        }
128        
129        protected ConnectionAnchor createAnchorInternal() {
130                return new RectangleAnchor(this);
131        }
132        
133        protected ConnectionAnchor createAnchorExternal() {
134                return new StemAnchor(this);
135        }
136}

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