nl.dvberkel.tree.TreeTransformer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tree.svg Show documentation
Show all versions of tree.svg Show documentation
Code to generate SVG from trees
The newest version!
package nl.dvberkel.tree;
public class TreeTransformer {
private final Configuration configuration;
public TreeTransformer(Configuration configuration) {
this.configuration = configuration;
}
public SvgTree transform(Tree tree) {
if (tree == null) { throw new IllegalArgumentException("tree should not be null"); }
if (tree instanceof Node) {
Node node = (Node) tree;
return new SvgNode(configuration, transform(node.left()), transform(node.right()));
} else {
return new SvgLeaf(configuration);
}
}
}