1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 private List<Fig> figs = new LinkedList<Fig>();
37 private List<String> privateAttributes = new LinkedList<String>();
38 private int nextFigNumber = 0;
39
40 public FigGroup(String name, String description, String href, Fill fill,
41 FillColor fillColor, Stroke stroke, StrokeColor strokeColor) {
42 super(name, fill, fillColor, stroke, strokeColor);
43 this.description = description;
44 this.href = href;
45 }
46
47 public Element getXML(Document doc) {
48 Element group = createElement(doc, "group");
49 group.setAttribute("description", getDescription());
50 group.setAttribute("href", getHREF());
51
52 group.appendChild(getPrivateAttributesElement(doc));
53
54 for (Fig fig : figs) {
55 group.appendChild(fig.getXML(doc));
56 }
57 return group;
58 }
59
60 private Element getPrivateAttributesElement(Document doc) {
61 Element priv = doc.createElement("private");
62 for (String privateAttribute : privateAttributes) {
63 Text textNode = doc.createTextNode(privateAttribute);
64 priv.appendChild(textNode);
65 }
66 return priv;
67 }
68
69 public void addPrivateAttribute(String attribute, String value) {
70 privateAttributes.add(attribute + "=\"" + value + "\"");
71 }
72
73 public void addFig(Fig fig) {
74 figs.add(fig);
75 }
76
77
78
79
80
81 public String getDescription() {
82 return description;
83 }
84
85 public String getHREF() {
86 return href;
87 }
88
89 protected String getNextFigName() {
90 return getName() + "." + nextFigNumber++;
91 }
92
93 }