Clover coverage report - Maven Clover report
Coverage timestamp: Thu Oct 11 2007 08:41:48 CEST
file stats: LOC: 117   Methods: 7
NCLOC: 84   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
LinkItemFactory.java 100% 97.4% 85.7% 96.2%
coverage coverage
 1    /*
 2    * Copyright (C) 2007 Eric MIGNOT - mignots.eric@free.fr
 3    *
 4    * This library is free software; you can redistribute it and/or
 5    * modify it under the terms of the GNU Lesser General Public
 6    * License as published by the Free Software Foundation; either
 7    * version 2.1 of the License, or (at your option) any later version.
 8    *
 9    * This library is distributed in the hope that it will be useful,
 10    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12    * Lesser General Public License for more details.
 13    *
 14    * You should have received a copy of the GNU Lesser General Public
 15    * License along with this library; if not, write to the Free Software
 16    * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 17    */
 18    package org.ericmignot.modeler.gui.workarea;
 19   
 20    import java.awt.Point;
 21   
 22    import org.ericmignot.modeler.data.BusinessObject;
 23    import org.ericmignot.modeler.data.Link;
 24    import org.ericmignot.modeler.data.Model;
 25    import org.ericmignot.modeler.data.SimplePoint;
 26   
 27    public class LinkItemFactory implements ItemFactory
 28    {
 29    protected Model model;
 30    private BusinessObject initialLinkEnd;
 31   
 32    private ExtremityFactory extremityFactory;
 33   
 34  132 public LinkItemFactory()
 35    {
 36  132 this.extremityFactory = new ExtremityFactory();
 37    }
 38   
 39  0 public Model getModel()
 40    {
 41  0 return model;
 42    }
 43   
 44  112 public void setModel(Model model)
 45    {
 46  112 this.model = model;
 47    }
 48   
 49  69 public Item createModelerItems(BusinessObject businessObject, WorkArea workArea)
 50    {
 51  69 Link link = (Link) businessObject;
 52  69 this.initialLinkEnd = link.getLinkEnd();
 53   
 54  69 if (link.getPoints().length == 0)
 55    {
 56  68 LinkItem linkItem = (LinkItem) this.createLinkItem(link, workArea);
 57  68 linkItem.setExtremityStrategy(this.extremityFactory.buildExtremityStrategy(link));
 58  68 return linkItem;
 59    }
 60    else
 61    {
 62  1 Point[] points = link.getPoints();
 63  1 BusinessObject start = link.getLinkStart();
 64  1 BusinessObject end = null;
 65  1 for (int i=0; i < points.length; i++)
 66    {
 67  2 end = this.createPoint(points[i]);
 68  2 this.model.addBusinessObject(end);
 69  2 if (i==0)
 70    {
 71  1 link.setLinkEnd(end);
 72  1 LinkItem transitionItem = (LinkItem) this.createLinkItem(link, workArea);
 73  1 transitionItem.setExtremityStrategy(this.extremityFactory.buildExtremityStrategy(link));
 74  1 workArea.addItem(transitionItem);
 75    }
 76    else
 77    {
 78  1 Link innerLink = createLink(start, end);
 79  1 this.model.addBusinessObject(innerLink);
 80    }
 81  2 start = end;
 82    }
 83  1 end = this.initialLinkEnd;
 84  1 Link finalLink = createLink(start, end);
 85  1 this.model.addBusinessObject(finalLink);
 86  1 return null;
 87    }
 88    }
 89   
 90  2 protected BusinessObject createPoint(Point p)
 91    {
 92  2 SimplePoint simplePoint = new SimplePoint();
 93  2 simplePoint.setCenter(p);
 94  2 return simplePoint;
 95    }
 96   
 97  2 protected Link createLink(BusinessObject start, BusinessObject end)
 98    {
 99  2 Link link = new Link();
 100  2 link.setLinkStart(start);
 101  2 link.setLinkEnd(end);
 102  2 return link;
 103    }
 104   
 105  69 protected LinkItem createLinkItem(Link link, WorkArea workArea)
 106    {
 107  69 LinkItem linkItem = new LinkItem();
 108  69 linkItem.setBusinessObject(link);
 109  69 linkItem.setLinkStart(workArea.getItemByBusinessObject(link.getLinkStart()));
 110  69 linkItem.setLinkEnd(workArea.getItemByBusinessObject(link.getLinkEnd()));
 111  69 return linkItem;
 112    }
 113   
 114   
 115   
 116   
 117    }