Safiye Celik wrote:
> Hi,
> How do you create DoubleWalk1.jpg tree? I wanna display my tree as
> yours which is more understandable for a human, but I cannot get such
> a tree. I use JTree component constructed from a DefaultTreeModel
> component, and the tree I get is as in the attachment, which is in
> expandable folder format and not readable enough. And I could not find
> any component in Java to display a tree as yours. I would be glad if
> you share your way. Thanks.
Search the past posting for how to generate a dot (www.graphviz.org)
specification from the AST and then run dot:
// Use the ANLTR built in dot generator
//
DOTTreeGenerator gen = new DOTTreeGenerator();
// Which we can cause to generate the DOT specification
// with the input file name suffixed with .dot. You
can then use
// the graphviz tools or zgrviewer (Java) to view
the grahpical
// version of the dot file.
//
source = source.substring(0, source.length()-3);
String outputName = source + "dot";
System.out.println(" Producing AST dot (graphviz)
file");
// It produces a jguru string template.
//
StringTemplate st = gen.toDOT(t, new
CommonTreeAdaptor(), _treeST, _edgeST);
// Create the output file and write the dot spec to it
//
FileWriter outputStream = new FileWriter(outputName);
outputStream.write(st.toString());
outputStream.close();
// Invoke dot to generate a .png file
//
System.out.println(" Producing png graphic for
tree");
pStart = System.currentTimeMillis();
Process proc = Runtime.getRuntime().exec("dot -Tpng
-o" + source + "png " + outputName);
proc.waitFor();
stop = System.currentTimeMillis();
System.out.println(" PNG graphic produced in "
+ (stop - pStart) + "ms.");
Jim
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---