1 25 package org.snipsnap.graph; 26 27 import org.snipsnap.graph.builder.StringTreeBuilder; 28 import org.snipsnap.graph.builder.TreeBuilder; 29 import org.snipsnap.graph.context.GraphRendererContext; 30 import org.snipsnap.graph.renderer.HorizontalRenderer; 31 import org.snipsnap.graph.renderer.Renderer; 32 33 import javax.servlet.ServletOutputStream ; 34 import javax.servlet.http.HttpServletRequest ; 35 import javax.servlet.http.HttpServletResponse ; 36 import java.io.IOException ; 37 38 public class HorizontalContentRenderer implements ContentRenderer { 39 private Renderer renderer = new HorizontalRenderer();; 40 41 public String getName() { 42 return "horizontal"; 43 } 44 45 public Renderer getRenderer() { 46 return renderer; 47 } 48 49 public void render(HttpServletRequest request, HttpServletResponse response, String content) throws IOException { 50 response.setContentType("image/png"); 51 52 ServletOutputStream out = response.getOutputStream(); 53 54 TreeBuilder builder = new StringTreeBuilder(content); 55 renderer.render(builder.build(), out, new GraphRendererContext()); 56 } 57 } 58 | Popular Tags |