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

nameclass, %method, %block, %line, %
InfrastructureProvidedRoleManualFigure.java0%   (0/2)0%   (0/8)0%   (0/323)0%   (0/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InfrastructureProvidedRoleManualFigure0%   (0/1)0%   (0/6)0%   (0/312)0%   (0/37)
InfrastructureProvidedRoleManualFigure (int, AbstractBorderFigure$POSITION_TY... 0%   (0/1)0%   (0/5)0%   (0/2)
access$0 (InfrastructureProvidedRoleManualFigure): 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/113)0%   (0/12)
paintFigure (Graphics): void 0%   (0/1)0%   (0/179)0%   (0/20)
     
class InfrastructureProvidedRoleManualFigure$RectangleAnchor0%   (0/1)0%   (0/2)0%   (0/11)0%   (0/4)
InfrastructureProvidedRoleManualFigure$RectangleAnchor (InfrastructureProvide... 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 InfrastructureProvidedRoleManualFigure 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 InfrastructureProvidedRoleManualFigure(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.WEST : 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                switch(side){
45                case PositionConstants.EAST:
46                        graphics.drawLine(rect.getLeft().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
47                        graphics.drawRectangle(rect.getCenter().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2);
48                        break;
49                case PositionConstants.WEST:
50                        graphics.drawLine(rect.getRight().x,rect.getCenter().y,rect.getCenter().x,rect.getCenter().y);
51                        graphics.drawRectangle(rect.getLeft().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2);
52                        break;
53                case PositionConstants.NORTH:
54                        graphics.drawLine(rect.getCenter().x,rect.getBottom().y,rect.getCenter().x,rect.getCenter().y);
55                        graphics.drawRectangle(rect.getCenter().x-rect.width/4, rect.getTop().y, rect.height/2, rect.height/2);
56                        break;
57                case PositionConstants.SOUTH:
58                        graphics.drawLine(rect.getCenter().x,rect.getTop().y,rect.getCenter().x,rect.getCenter().y);
59                        graphics.drawRectangle(rect.getCenter().x-rect.width/4, rect.getCenter().y, rect.height/2, rect.height/2);
60                        break;
61                }
62        }
63        
64        /**
65         * @return the rectangle surrounding the [] part of the figure
66         * relative to the position of the figure
67         */
68        private Rectangle getTargetConnectionFigureBounds() {
69                int side = (getBorderItemLocator() == null ? PositionConstants.WEST : getBorderItemLocator().getCurrentSideOfParent());
70        
71                Rectangle rect = getBounds();
72                Rectangle result = null;
73                
74                switch(side){
75                case PositionConstants.EAST:
76                        result = new Rectangle(rect.getCenter().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2);
77                        break;
78                case PositionConstants.WEST:
79                        result = new Rectangle(rect.getLeft().x, rect.getTop().y+rect.height/4, rect.height/2, rect.height/2);
80                        break;
81                case PositionConstants.NORTH:
82                        result = new Rectangle(rect.getCenter().x-rect.width/4, rect.getTop().y, rect.height/2, rect.height/2);
83                        break;
84                case PositionConstants.SOUTH:
85                        result = new Rectangle(rect.getCenter().x-rect.width/4, rect.getCenter().y, rect.height/2, rect.height/2);
86                        break;
87                }
88                return result;
89        }
90        
91        /**Anchor providing a connection point to the rectangular connection part of {@link InfrastructureProvidedRoleManualFigure}.
92         * @author groenda
93         *
94         */
95        private class RectangleAnchor extends ChopboxAnchor {
96                public RectangleAnchor(IFigure owner) {
97                        super(owner);
98                }
99                
100                @Override
101                protected Rectangle getBox() {
102                        return getTargetConnectionFigureBounds();
103                }
104        }
105        
106        protected ConnectionAnchor createAnchorInternal() {
107                return new RectangleAnchor(this);
108        }
109        
110        protected ConnectionAnchor createAnchorExternal() {
111                return new StemAnchor(this);
112        }
113}

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