Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  * [The "BSD license"]
  * Copyright (c) 2011, abego Software GmbH, Germany (
  * All rights reserved.
  * Redistribution and use in source and binary forms, with or without 
  * modification, are permitted provided that the following conditions are met:
  * 1. Redistributions of source code must retain the above copyright notice, 
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice, 
 *    this list of conditions and the following disclaimer in the documentation 
 *    and/or other materials provided with the distribution.
 * 3. Neither the name of the abego Software GmbH nor the names of its 
 *    contributors may be used to endorse or promote products derived from this 
 *    software without specific prior written permission.
package org.abego.treelayout.demo.svg;
Demonstrates how to use the org.abego.treelayout.TreeLayout to create a tree diagram with SVG (Scalable Vector Graphic)

The rendered SVG looks like this:

Link: The SVG file (only viewable in SVG aware browsers)

Udo Borkowski (

public class SVGDemo {

Returns an SVG text displaying a tree with nodes placed according to a layout created by org.abego.treelayout.TreeLayout.
	public static void main(String[] args) {
		// get the sample tree
		TreeForTreeLayout<TextInBoxtree = SampleTreeFactory
		// setup the tree layout configuration
		double gapBetweenLevels = 50;
		double gapBetweenNodes = 10;
		// create the NodeExtentProvider for TextInBox nodes
		// create the layout
		TreeLayout<TextInBoxtreeLayout = new TreeLayout<TextInBox>(tree,
		// Generate the SVG and write it to System.out
		SVGForTextInBoxTree generator = new SVGForTextInBoxTree(treeLayout);
New to GrepCode? Check out our FAQ X