Coverage Report - th.co.edge.jseq.argouml.pgml.FigPath
 
Classes in this File Line Coverage Branch Coverage Complexity
FigPath
72%
21/29
50%
2/4
0
 
 1  
 /*
 2  
  * Copyright (c) 2003-2008, by Henrik Arro and Contributors
 3  
  *
 4  
  * This file is part of JSeq, a tool to automatically create
 5  
  * sequence diagrams by tracing program execution.
 6  
  *
 7  
  * See <http://jseq.sourceforge.net> for more information.
 8  
  *
 9  
  * JSeq is free software: you can redistribute it and/or modify
 10  
  * it under the terms of the GNU Lesser General Public License as
 11  
  * published by the Free Software Foundation, either version 3 of
 12  
  * the License, or (at your option) any later version.
 13  
  *
 14  
  * JSeq is distributed in the hope that it will be useful,
 15  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 17  
  * GNU Lesser General Public License for more details.
 18  
  *
 19  
  * You should have received a copy of the GNU Lesser General Public License
 20  
  * along with JSeq. If not, see <http://www.gnu.org/licenses/>.
 21  
  */
 22  
 
 23  
 package th.co.edge.jseq.argouml.pgml;
 24  
 
 25  
 import java.awt.Point;
 26  
 import java.util.LinkedList;
 27  
 import java.util.List;
 28  
 
 29  
 import org.w3c.dom.Document;
 30  
 import org.w3c.dom.Element;
 31  
 
 32  
 public class FigPath extends Fig {
 33  
     private String description;
 34  15
     private List<Point> points = new LinkedList<Point>();
 35  
 
 36  
     public FigPath(String name, String description, int x1, int y1, int x2,
 37  
             int y2, Fill fill) {
 38  15
         super(name, fill, FillColor.WHITE, Stroke.ON, StrokeColor.BLACK);
 39  15
         this.description = description;
 40  15
         this.points.add(new Point(x1, y1));
 41  15
         this.points.add(new Point(x2, y2));
 42  15
     }
 43  
 
 44  
     public FigPath(String name, String description, List<Point> points,
 45  
             Fill fill) {
 46  0
         super(name, fill, FillColor.WHITE, Stroke.ON, StrokeColor.BLACK);
 47  0
         this.description = description;
 48  0
         if (points.size() < 2) {
 49  0
             String message = "Number of points must be at least 2: " + points;
 50  0
             throw new IllegalArgumentException(message);
 51  
         }
 52  0
         this.points.addAll(points);
 53  0
     }
 54  
 
 55  
     public Element getXML(Document doc) {
 56  15
         Element lineElement = createElement(doc, "path");
 57  15
         lineElement.setAttribute("description", getDescription());
 58  
 
 59  15
         Point point = (Point) points.get(0);
 60  
 
 61  15
         Element moveTo = doc.createElement("moveto");
 62  15
         moveTo.setAttribute("x", Integer.toString(point.x));
 63  15
         moveTo.setAttribute("y", Integer.toString(point.y));
 64  15
         lineElement.appendChild(moveTo);
 65  
 
 66  30
         for (int i = 1; i < points.size(); i++) {
 67  15
             point = (Point) points.get(i);
 68  15
             Element lineTo = doc.createElement("lineto");
 69  15
             lineTo.setAttribute("x", Integer.toString(point.x));
 70  15
             lineTo.setAttribute("y", Integer.toString(point.y));
 71  15
             lineElement.appendChild(lineTo);
 72  
         }
 73  
 
 74  15
         return lineElement;
 75  
     }
 76  
 
 77  
     public String getDescription() {
 78  15
         return description;
 79  
     }
 80  
 
 81  
     public List<Point> getPoints() {
 82  0
         return points;
 83  
     }
 84  
 }