| 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 | 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 | |
|
| 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 | |
} |