01: package com.opensymphony.webwork.sitegraph.model;
02:
03: import java.io.IOException;
04:
05: /**
06: * User: plightbo
07: * Date: Jun 26, 2005
08: * Time: 4:49:14 PM
09: */
10: public abstract class SiteGraphNode implements Render, Comparable {
11: private String name;
12: private SubGraph parent;
13:
14: public SiteGraphNode(String name) {
15: this .name = name;
16: }
17:
18: public SubGraph getParent() {
19: return parent;
20: }
21:
22: public void setParent(SubGraph parent) {
23: this .parent = parent;
24: }
25:
26: public void render(IndentWriter writer) throws IOException {
27: writer.write(getFullName() + " [label=\"" + name
28: + "\",color=\"" + getColor() + "\"];");
29: }
30:
31: public String getFullName() {
32: String prefix = "";
33: if (parent != null) {
34: String parentPrefix = parent.getPrefix();
35: if (!parentPrefix.equals("")) {
36: prefix = parentPrefix + "_";
37: }
38: }
39: return prefix + cleanName();
40: }
41:
42: private String cleanName() {
43: return name.replaceAll("[\\.\\/\\-\\$\\{\\}]", "_");
44: }
45:
46: public abstract String getColor();
47:
48: public int compareTo(Object o) {
49: return name.compareTo(((SiteGraphNode) o).name);
50: }
51: }
|