private static StringBuffer dotOutput(IDFAState state) { StringBuffer result = new StringBuffer(); result.append("\""); result.append(state.getName()); result.append("\""); return result; }
private static StringBuffer dotOutput(TypeStateProperty property) { StringBuffer result = new StringBuffer("digraph \"TypeStateProeprty:" + property.getTypesAsString() + "\" {\n"); result.append("rankdir=LR;center=true;fontsize=12;node [fontsize=12];edge [fontsize=12]; \n"); // create title result.append("__node [label=\"" + property.getTypesAsString() + "\" shape=\"box\"]\n"); // create nodes for states for (Iterator<IDFAState> it = property.statesIterator(); it.hasNext(); ) { IDFAState state = it.next(); result.append(dotOutput(state)); if (state.isAccepting()) { result.append(" [color=green]\n"); } else { result.append("\n"); } } // mark initial state IDFAState initial = property.initial(); result.append("init [shape=\"plaintext\"]\n"); result.append("init ->"); result.append(dotOutput(initial)); result.append("\n"); // create edges for (Iterator<IDFAState> it = property.statesIterator(); it.hasNext(); ) { IDFAState state = it.next(); for (Iterator<IEvent> letterIt = property.alphabetIterator(); letterIt.hasNext(); ) { IEvent event = letterIt.next(); IDFAState target = property.successor(state, event); if (target != null) { result.append(dotOutput(state)); result.append(" -> "); result.append(dotOutput(target)); result.append(" [label=\"" + event.getName() + "\"]\n"); } } } // close digraph result.append("}"); return result; }