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

nameclass, %method, %block, %line, %
AbstractBorderFigure.java0%   (0/3)0%   (0/13)0%   (0/215)0%   (0/47)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractBorderFigure0%   (0/1)0%   (0/7)0%   (0/148)0%   (0/35)
<static initializer> 0%   (0/1)0%   (0/8)0%   (0/1)
AbstractBorderFigure (int, AbstractBorderFigure$POSITION_TYPE): void 0%   (0/1)0%   (0/11)0%   (0/4)
access$0 (AbstractBorderFigure): Point 0%   (0/1)0%   (0/3)0%   (0/1)
getBorderItemLocator (): IBorderItemLocator 0%   (0/1)0%   (0/23)0%   (0/7)
getConnectionAnchor (String): ConnectionAnchor 0%   (0/1)0%   (0/31)0%   (0/7)
getStemPosition (): Point 0%   (0/1)0%   (0/61)0%   (0/12)
paintFigure (Graphics): void 0%   (0/1)0%   (0/11)0%   (0/3)
     
class AbstractBorderFigure$POSITION_TYPE0%   (0/1)0%   (0/4)0%   (0/50)0%   (0/6)
<static initializer> 0%   (0/1)0%   (0/24)0%   (0/5)
AbstractBorderFigure$POSITION_TYPE (String, int): void 0%   (0/1)0%   (0/5)0%   (0/1)
valueOf (String): AbstractBorderFigure$POSITION_TYPE 0%   (0/1)0%   (0/5)0%   (0/1)
values (): AbstractBorderFigure$POSITION_TYPE [] 0%   (0/1)0%   (0/16)0%   (0/1)
     
class AbstractBorderFigure$StemAnchor0%   (0/1)0%   (0/2)0%   (0/17)0%   (0/6)
AbstractBorderFigure$StemAnchor (AbstractBorderFigure, 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;
10import org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator;
11import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
12 
13/**
14 * Baseclass for both --( and --() type UML style border figures
15 * 
16 * @author Philipp Meier
17 */
18abstract public class AbstractBorderFigure extends DefaultSizeNodeFigure {
19 
20        /**
21         * position type of the figure. internal or external.
22         * internal means the figure is connected towards the outside
23         * external means the figure is connected towards the inside
24         */
25        public static enum POSITION_TYPE {
26                /** conntected towards the outside */
27                POS_INTERNAL ,
28                
29                /** connected towards the inside */
30                POS_EXTERNAL 
31        }
32        
33        private POSITION_TYPE myPosType;
34        
35        /**
36         * reference to the anchor to be used.
37         */
38        private ConnectionAnchor myAnchor = null;
39        
40        /**
41         * @param size width and hight of the figure in logical units (LP)
42         */
43        public AbstractBorderFigure(int logicalSize, POSITION_TYPE posType) {
44                super(logicalSize, logicalSize);
45                myPosType = posType;
46        }
47        
48        
49        /* (non-Javadoc)
50         * @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#paintFigure(org.eclipse.draw2d.Graphics)
51         */
52        @Override
53        protected void paintFigure(Graphics graphics) {
54                // 
55                super.paintFigure(graphics);
56                //Next line needed for better display of Ports on Mac OS
57                graphics.setLineWidthFloat(new Float(1.01));
58        }
59 
60 
61 
62        /**
63         * Helper function to get the parent's border item locator
64         * 
65         * @return the parent's border item locator
66         */
67        protected IBorderItemLocator getBorderItemLocator() {
68                IFigure parentFigure = this.getParent().getParent();
69                if (parentFigure != null && parentFigure.getLayoutManager() != null) {
70                        Object constraint = parentFigure.getLayoutManager().getConstraint(
71                                this.getParent());
72                        if (constraint instanceof IBorderItemLocator) {
73                                return (IBorderItemLocator) constraint;
74                        }
75                }
76                return null;
77        }
78        
79        /**
80         * factory method for the anchor to be used when figure is
81         * in an internal position
82         * 
83         * @return a reference to the new anchor. must not be null
84         */
85        abstract protected ConnectionAnchor createAnchorInternal();
86        
87        /**
88         * factory method for the anchor to be used when figure is
89         * in an external position
90         * 
91         * @return a reference to the new anchor. must not be null
92         */
93        abstract protected ConnectionAnchor createAnchorExternal();
94        
95        public ConnectionAnchor getConnectionAnchor(String terminal) {
96                if (myAnchor == null) {
97                        if (myPosType == POSITION_TYPE.POS_INTERNAL) {
98                                myAnchor = createAnchorInternal();
99                        }
100                        
101                        if (myPosType == POSITION_TYPE.POS_EXTERNAL) {
102                                myAnchor = createAnchorExternal();
103                        }
104                }
105                assert(myAnchor != null);
106                
107                return myAnchor;
108        }                
109        
110        /**
111         * @return the end position of the -- part of the figure
112         * relative to the position of the figure
113         */
114        private Point getStemPosition() {
115                int side = (getBorderItemLocator() == null ? PositionConstants.WEST : getBorderItemLocator().getCurrentSideOfParent());
116                
117                Rectangle rect = getBounds();
118                Point result = null;
119                
120                switch(side){
121                case PositionConstants.EAST:
122                        result = new Point(rect.getLeft().x, rect.getCenter().y);
123                        break;
124                case PositionConstants.WEST:
125                        result = new Point(rect.getRight().x, rect.getCenter().y);
126                        break;
127                case PositionConstants.NORTH:
128                        result = new Point(rect.getCenter().x, rect.getBottom().y);
129                        break;
130                case PositionConstants.SOUTH:
131                        result = new Point(rect.getCenter().x, rect.getTop().y);
132                        break;
133                }
134                return result;
135        }        
136        
137        /**
138         * places the anchor point at the -- part of the figure. 
139         * this class is to be used by subclasses
140         */
141        protected class StemAnchor extends AbstractConnectionAnchor {
142 
143                public StemAnchor(IFigure owner) {
144                        super(owner);
145                }
146                
147                public Point getLocation(Point reference) {
148                        Point p = getStemPosition();
149                        getOwner().translateToAbsolute(p);
150                        return p;
151                }
152        }
153 
154}

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