View Javadoc

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  import org.w3c.dom.Text;
28  
29  import th.co.edge.jseq.util.XMLUtil;
30  
31  public class FigText extends Fig {
32      String text;
33      int x;
34      int y;
35      String font;
36      int textSize;
37  
38      public FigText(String name, String text, int x, int y, String font,
39              int textSize, Stroke stroke, StrokeColor strokeColor) {
40          super(name, Fill.OFF, FillColor.WHITE, stroke, strokeColor);
41          this.text = text;
42          this.x = x;
43          this.y = y;
44          this.font = font;
45          this.textSize = textSize;
46      }
47  
48      public Element getXML(Document doc) {
49          Element textElement = createElement(doc, "text");
50          textElement.setAttribute("x", Integer.toString(getX()));
51          textElement.setAttribute("y", Integer.toString(getY()));
52          textElement.setAttribute("font", getFont());
53          textElement.setAttribute("textsize", Integer.toString(getTextSize()));
54          Text textNode = doc.createTextNode(XMLUtil.makeXMLSafe(getText()));
55          textElement.appendChild(textNode);
56          return textElement;
57      }
58  
59      public String getText() {
60          return text;
61      }
62  
63      public int getX() {
64          return x;
65      }
66  
67      public int getY() {
68          return y;
69      }
70  
71      public String getFont() {
72          return font;
73      }
74  
75      public int getTextSize() {
76          return textSize;
77      }
78  }