本文整理汇总了Java中org.jfree.chart.servlet.ServletUtilities类的典型用法代码示例。如果您正苦于以下问题:Java ServletUtilities类的具体用法?Java ServletUtilities怎么用?Java ServletUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ServletUtilities类属于org.jfree.chart.servlet包,在下文中一共展示了ServletUtilities类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createAndSaveImage
import org.jfree.chart.servlet.ServletUtilities; //导入依赖的package包/类
protected String createAndSaveImage(DesignOptions options, JFreeChart chart, ChartRenderingInfo renderingInfo) throws GeneratorException {
int width = options.getWidth();
int height = options.getHeight();
BufferedImage image = chart.createBufferedImage(width, height, renderingInfo);
Graphics2D chartGraphics = image.createGraphics();
chartGraphics.setColor(Color.white);
chartGraphics.fillRect(0, 0, width, height);
chart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height));
try {
return ServletUtilities.saveChartAsPNG(chart, width, height, renderingInfo, null);
}
catch (IOException e) {
throw new GeneratorException("Could not save PNG!", e);
}
}
开发者ID:52North,项目名称:SensorWebClient,代码行数:17,代码来源:Generator.java
示例2: doGetChart
import org.jfree.chart.servlet.ServletUtilities; //导入依赖的package包/类
@GET
@Path("/charts")
@Produces("image/png")
@ApiOperation(value = "", notes = "")
@ApiResponses(value = {
@ApiResponse(code = 500, message = "Internal Server Error")
})
public Response doGetChart(@Context HttpSession session) throws IOException {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Linux", 29);
dataset.setValue("Mac", 20);
dataset.setValue("Windows", 51);
JFreeChart chart = ChartFactory.createPieChart3D("hello world", // chart title
dataset, // data
true, // include legend
true,
false);
PiePlot3D plot = (PiePlot3D) chart.getPlot();
plot.setStartAngle(290);
plot.setDirection(Rotation.CLOCKWISE);
plot.setForegroundAlpha(0.5f);
// Write the chart image to the temporary directory
ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
String filename = ServletUtilities.saveChartAsPNG(chart, 500, 300, info, session);
byte[] imageData = FileUtils.readFileToByteArray(new File("/tmp/" + filename));
//BufferedImage image = ...;
/*ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "png", baos);
byte[] imageData = baos.toByteArray();*/
// uncomment line below to send non-streamed
// return Response.ok(imageData).build();
// uncomment line below to send streamed
return Response.ok(new ByteArrayInputStream(imageData)).build();
}
开发者ID:nesl,项目名称:SensorSafe,代码行数:44,代码来源:DebugResource.java
注:本文中的org.jfree.chart.servlet.ServletUtilities类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论