1 34 35 36 package org.krysalis.jcharts.encoders; 37 38 39 import org.krysalis.jcharts.Chart; 40 import org.krysalis.jcharts.chartData.ChartDataException; 41 import org.krysalis.jcharts.properties.PropertyException; 42 43 import javax.servlet.http.HttpServletResponse ; 44 import java.io.IOException ; 45 46 47 52 public class ServletEncoderHelper 53 { 54 public static final String SVG_MIME_TYPE = "image/svg+xml"; 55 public static final String PNG_MIME_TYPE = "image/png"; 56 public static final String JPEG_MIME_TYPE = "image/jpeg"; 57 58 59 73 public static void encodeServlet( Chart chart, HttpServletResponse httpServletResponse ) throws ChartDataException, PropertyException, IOException 74 { 75 httpServletResponse.setContentType( SVG_MIME_TYPE ); 76 SVGEncoder.encode( chart, httpServletResponse.getOutputStream() ); 77 } 78 79 80 95 public static void encodeJPEG13( Chart chart, 96 float quality, 97 HttpServletResponse httpServletResponse ) throws ChartDataException, PropertyException, IOException 98 { 99 httpServletResponse.setContentType( JPEG_MIME_TYPE ); 100 JPEGEncoder13.encode( chart, quality, httpServletResponse.getOutputStream() ); 101 } 102 103 104 115 public static void encodeJPEG( Chart chart, 116 float quality, 117 HttpServletResponse httpServletResponse ) throws ChartDataException, PropertyException, IOException 118 { 119 httpServletResponse.setContentType( JPEG_MIME_TYPE ); 120 JPEGEncoder.encode( chart, quality, httpServletResponse.getOutputStream() ); 121 } 122 123 124 134 public static void encodePNG( Chart chart, HttpServletResponse httpServletResponse ) throws ChartDataException, PropertyException, IOException 135 { 136 httpServletResponse.setContentType( PNG_MIME_TYPE ); 137 PNGEncoder.encode( chart, httpServletResponse.getOutputStream() ); 138 } 139 140 141 } 142 | Popular Tags |