Coverage Report - th.co.edge.jseq.argouml.pgml.Fig
 
Classes in this File Line Coverage Branch Coverage Complexity
Fig
100%
19/19
N/A
1
 
 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 org.w3c.dom.Document;
 26  
 import org.w3c.dom.Element;
 27  
 
 28  
 import th.co.edge.jseq.util.XMLUtil;
 29  
 
 30  
 /**
 31  
  * A <code>Fig</code> represents a PGML figure of some kind.
 32  
  */
 33  
 public abstract class Fig {
 34  
     private String name;
 35  
     private Fill fill;
 36  
     private FillColor fillColor;
 37  
     private Stroke stroke;
 38  
     private StrokeColor strokeColor;
 39  
 
 40  
     /**
 41  
      * Creates a new <code>Fig</code>.
 42  
      * 
 43  
      * @param name
 44  
      *            the name of the new <code>Fig</object>
 45  
      * @param fill determines if the figure should be filled or not
 46  
      * 
 47  
      * @param fillColor if the figure should be filled, determines the color to use
 48  
      * @param stroke determines if the figure should be stroked or not
 49  
      * @param strokeColor if the figure should be stroked, determines the color to use
 50  
      */
 51  
     public Fig(String name, Fill fill, FillColor fillColor, Stroke stroke,
 52  85
             StrokeColor strokeColor) {
 53  85
         this.name = name;
 54  85
         this.fill = fill;
 55  85
         this.fillColor = fillColor;
 56  85
         this.stroke = stroke;
 57  85
         this.strokeColor = strokeColor;
 58  85
     }
 59  
 
 60  
     public abstract Element getXML(Document doc);
 61  
 
 62  
     protected Element createElement(Document doc, String tag) {
 63  85
         Element element = doc.createElement(tag);
 64  85
         element.setAttribute("name", XMLUtil.makeXMLSafe(getName()));
 65  85
         element.setAttribute("fill", getFill().getStringValue());
 66  85
         element.setAttribute("fillcolor", getFillColor().getStringValue());
 67  85
         element.setAttribute("stroke", getStroke().getStringValue());
 68  85
         element.setAttribute("strokecolor", getStrokeColor().getStringValue());
 69  85
         return element;
 70  
     }
 71  
 
 72  
     //
 73  
     // Getters
 74  
     //
 75  
 
 76  
     /**
 77  
      * Returns the name of this figure object.
 78  
      * 
 79  
      * @return the name of this figure object
 80  
      */
 81  
     public String getName() {
 82  167
         return name;
 83  
     }
 84  
 
 85  
     /**
 86  
      * Returns the stroke attribute of this figure object, that is, whether or
 87  
      * not this figure should be filled.
 88  
      * 
 89  
      * @return the stroke attribute of this figure object
 90  
      */
 91  
     public Fill getFill() {
 92  85
         return fill;
 93  
     }
 94  
 
 95  
     /**
 96  
      * Returns the fill color of this figure object, that is, if this figure
 97  
      * should be filled, the color to use.
 98  
      * 
 99  
      * @return the fill color of this figure object
 100  
      */
 101  
     public FillColor getFillColor() {
 102  85
         return fillColor;
 103  
     }
 104  
 
 105  
     /**
 106  
      * Returns the stroke attribute of this figure object, that is, whether or not 
 107  
      * 
 108  
      * @return
 109  
      */
 110  
     public Stroke getStroke() {
 111  85
         return stroke;
 112  
     }
 113  
 
 114  
     public StrokeColor getStrokeColor() {
 115  85
         return strokeColor;
 116  
     }
 117  
 }