Coverage Report - th.co.edge.jseq.argouml.pgml.FigGroup
 
Classes in this File Line Coverage Branch Coverage Complexity
FigGroup
100%
27/27
100%
4/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.util.LinkedList;
 26  
 import java.util.List;
 27  
 
 28  
 import org.w3c.dom.Document;
 29  
 import org.w3c.dom.Element;
 30  
 import org.w3c.dom.Text;
 31  
 
 32  
 class FigGroup extends Fig {
 33  
     private String description;
 34  
     private String href;
 35  
 
 36  21
     private List<Fig> figs = new LinkedList<Fig>();
 37  21
     private List<String> privateAttributes = new LinkedList<String>();
 38  21
     private int nextFigNumber = 0;
 39  
 
 40  
     public FigGroup(String name, String description, String href, Fill fill,
 41  
             FillColor fillColor, Stroke stroke, StrokeColor strokeColor) {
 42  21
         super(name, fill, fillColor, stroke, strokeColor);
 43  21
         this.description = description;
 44  21
         this.href = href;
 45  21
     }
 46  
 
 47  
     public Element getXML(Document doc) {
 48  21
         Element group = createElement(doc, "group");
 49  21
         group.setAttribute("description", getDescription());
 50  21
         group.setAttribute("href", getHREF());
 51  
 
 52  21
         group.appendChild(getPrivateAttributesElement(doc));
 53  
 
 54  21
         for (Fig fig : figs) {
 55  64
             group.appendChild(fig.getXML(doc));
 56  
         }
 57  21
         return group;
 58  
     }
 59  
 
 60  
     private Element getPrivateAttributesElement(Document doc) {
 61  21
         Element priv = doc.createElement("private");
 62  21
         for (String privateAttribute : privateAttributes) {
 63  39
             Text textNode = doc.createTextNode(privateAttribute);
 64  39
             priv.appendChild(textNode);
 65  39
         }
 66  21
         return priv;
 67  
     }
 68  
 
 69  
     public void addPrivateAttribute(String attribute, String value) {
 70  39
         privateAttributes.add(attribute + "=\"" + value + "\"");
 71  39
     }
 72  
 
 73  
     public void addFig(Fig fig) {
 74  64
         figs.add(fig);
 75  64
     }
 76  
 
 77  
     //
 78  
     // Getters
 79  
     //
 80  
 
 81  
     public String getDescription() {
 82  21
         return description;
 83  
     }
 84  
 
 85  
     public String getHREF() {
 86  21
         return href;
 87  
     }
 88  
 
 89  
     protected String getNextFigName() {
 90  64
         return getName() + "." + nextFigNumber++;
 91  
     }
 92  
 
 93  
 }