private <T extends ASTCssNode> List<T> filterSilent(List<T> nodes) { List<T> result = new ArrayList<T>(); for (T t : nodes) { if (!t.isSilent()) result.add(t); } return result; }
@Override public String toDOT() { String result = "digraph G {\n"; result += "graph [fontname=\"Helvetica\" fontsize=\"10\" nodesep=\"0.35\" ranksep=\"0.25 equally\"];\n"; result += "node [fontname=\"Helvetica\" fontsize=\"10\" fixedsize=\"true\" style=\"filled\" fillcolor=\"white\" penwidth=\"2\"];\n"; result += "edge [fontname=\"Helvetica\" fontsize=\"10\" arrowhead=\"normal\" color=\"black\"];\n"; result += "\n"; result += "node [shape=circle];\n"; for (P p : this.getPlaces()) { Integer n = this.marking.get(p); String label = ((n == 0) || (n == null)) ? p.getLabel() : p.getLabel() + "[" + n.toString() + "]"; result += String.format( "\tn%s[label=\"%s\" width=\".3\" height=\".3\"];\n", p.getId().replace("-", ""), label); } result += "\n"; result += "node [shape=box];\n"; for (T t : this.getTransitions()) { String fillColor = this.isEnabled(t) ? " fillcolor=\"#9ACD32\"" : ""; if (t.isSilent()) result += String.format( "\tn%s[label=\"\" width=\".3\"" + fillColor + " height=\".1\"];\n", t.getId().replace("-", "")); else result += String.format( "\tn%s[label=\"%s\" width=\".3\"" + fillColor + " height=\".3\"];\n", t.getId().replace("-", ""), t.getLabel()); } result += "\n"; for (F f : this.getFlow()) { result += String.format( "\tn%s->n%s;\n", f.getSource().getId().replace("-", ""), f.getTarget().getId().replace("-", "")); } result += "}\n"; return result; }