org.jfree.chart.JFreeChart.createBufferedImage()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(200)

本文整理了Java中org.jfree.chart.JFreeChart.createBufferedImage()方法的一些代码示例,展示了JFreeChart.createBufferedImage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JFreeChart.createBufferedImage()方法的具体详情如下:
包路径:org.jfree.chart.JFreeChart
类名称:JFreeChart
方法名:createBufferedImage

JFreeChart.createBufferedImage介绍

[英]Creates and returns a buffered image into which the chart has been drawn.
[中]创建并返回已绘制图表的缓冲图像。

代码示例

代码示例来源:origin: kiegroup/optaplanner

public static void writeChartToImageFile(JFreeChart chart, File chartFile) {
  BufferedImage chartImage = chart.createBufferedImage(1024, 768);
  try (OutputStream out = new FileOutputStream(chartFile)) {
    ImageIO.write(chartImage, "png", out);
  } catch (IOException e) {
    throw new IllegalArgumentException("Failed writing chartFile (" + chartFile + ").", e);
  }
}

代码示例来源:origin: kiegroup/optaplanner

private File writeChartToImageFile(JFreeChart chart, String fileNameBase) {
  BufferedImage chartImage = chart.createBufferedImage(1024, 768);
  File summaryChartFile = new File(summaryDirectory, fileNameBase + ".png");
  try (OutputStream out = new FileOutputStream(summaryChartFile)) {
    ImageIO.write(chartImage, "png", out);
  } catch (IOException e) {
    throw new IllegalArgumentException("Failed writing summaryChartFile (" + summaryChartFile + ").", e);
  }
  return summaryChartFile;
}

代码示例来源:origin: jenkinsci/jenkins

private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) {
  String w = req.getParameter("width");
  if(w==null)     w=String.valueOf(defaultW);
  String h = req.getParameter("height");
  if(h==null)     h=String.valueOf(defaultH);
  Color graphBg = stringToColor(req.getParameter("graphBg"));
  Color plotBg = stringToColor(req.getParameter("plotBg"));
  if (graph==null)    graph = createGraph();
  graph.setBackgroundPaint(graphBg);
  Plot p = graph.getPlot();
  p.setBackgroundPaint(plotBg);
  return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info);
}

代码示例来源:origin: pentaho/pentaho-kettle

renderer.setSeriesShape( 0, new Ellipse2D.Double( -3.0, -3.0, 6.0, 6.0 ) );
BufferedImage bufferedImage = chart.createBufferedImage( bounds.width, bounds.height );
ImageData imageData = ImageUtil.convertToSWT( bufferedImage );

代码示例来源:origin: pentaho/pentaho-kettle

renderer.setSeriesShape( 0, new Ellipse2D.Double( -3.0, -3.0, 6.0, 6.0 ) );
BufferedImage bufferedImage = chart.createBufferedImage( bounds.width, bounds.height );
ImageData imageData = ImageUtil.convertToSWT( bufferedImage );

代码示例来源:origin: graphhopper/jsprit

private BufferedImage plot(VehicleRoutingProblem vrp, final Collection<VehicleRoute> routes, String pngFile, String title) {
  log.info("plot to {}", pngFile);
  XYSeriesCollection problem;
  XYSeriesCollection solution = null;
  final XYSeriesCollection shipments;
  try {
    retrieveActivities(vrp);
    problem = new XYSeriesCollection(activities);
    shipments = makeShipmentSeries(vrp.getJobs().values());
    if (routes != null) solution = makeSolutionSeries(vrp, routes);
  } catch (NoLocationFoundException e) {
    log.warn("cannot plot vrp, since coord is missing");
    return null;
  }
  final XYPlot plot = createPlot(problem, shipments, solution);
  JFreeChart chart = new JFreeChart(title, plot);
  LegendTitle legend = createLegend(routes, shipments, plot);
  chart.removeLegend();
  chart.addLegend(legend);
  save(chart, pngFile);
  return chart.createBufferedImage(1024, 1024);
}

代码示例来源:origin: com.atlassian.jira/jira-api

private BufferedImage createChartImageInline(final JFreeChart chart, final int width, final int height, final ChartRenderingInfo renderingInfo)
    throws IOException
{
  return chart.createBufferedImage(width, height, renderingInfo);
}

代码示例来源:origin: jfree/jfreechart

/**
 * Creates and returns a buffered image into which the chart has been drawn.
 *
 * @param width  the width.
 * @param height  the height.
 *
 * @return A buffered image.
 */
public BufferedImage createBufferedImage(int width, int height) {
  return createBufferedImage(width, height, null);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-chart

/**
 * Creates and returns a buffered image into which the chart has been drawn.
 *
 * @param width  the width.
 * @param height  the height.
 *
 * @return A buffered image.
 */
public BufferedImage createBufferedImage(int width, int height) {
  return createBufferedImage(width, height, null);
}

代码示例来源:origin: psi-probe/psi-probe

.write(ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, height)));

代码示例来源:origin: org.jvnet.its/issuetracker-stats

public void write(JFreeChart chart, File target) throws IOException {
    BufferedImage image = chart.createBufferedImage(640,480);
    FileOutputStream fos = new FileOutputStream(target);
    ImageIO.write(image, "PNG", fos);
    fos.close();
  }
}

代码示例来源:origin: mikaelhg/openblocks

/**
 * Updates the graph image displayed of this.  Image includes graph data, axis, and legend.
 */
public void updateImage() {
  if (!lock) {
    ImageIcon icon = new ImageIcon(chart.createBufferedImage(150, 100, 150.0, 100.0, null));
    this.setIcon(icon);
  }
}

代码示例来源:origin: org.hudsonci.plugins/jfreechart-plugin

@Override
public BufferedImage render(int width, int height) {
  createChart();
  return jFreeChart.createBufferedImage(width, height, info);
}

代码示例来源:origin: de.tudarmstadt.ukp.inception.app/inception-imls-core

public static BufferedImage plotToImage(List<ExtendedResult> results, int width, int height)
{
  return plotChart(results).createBufferedImage(width, height);
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) {
  String w = req.getParameter("width");
  if(w==null)     w=String.valueOf(defaultW);
  String h = req.getParameter("height");
  if(h==null)     h=String.valueOf(defaultH);
  if (graph==null)    graph = createGraph();
  return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info);
}

代码示例来源:origin: zolyfarkas/spf4j

private String generateHeatChart(final TSTable info, final TimeSeries data,
    final int width, final int height) throws IOException {
 JFreeChart chart = TimeSeriesDatabase.createHeatJFreeChart(data, info);
 BufferedImage img = chart.createBufferedImage(width, height);
 File dbFile = new File(this.getDBFilePath());
 File graphicFile = File.createTempFile(dbFile.getName() + '_' + fixName(info.getTableName()), ".dist.png",
     dbFile.getParentFile());
 ImageIO.write(img, "png", graphicFile);
 return graphicFile.getAbsolutePath();
}

代码示例来源:origin: com.atlassian.confluence.extra.chart/chart-plugin

BufferedImage getChartImage(Map<String, String> parameters, String chartDataHtml)
    throws ParseException, MacroExecutionException {
  return getChart(parameters, chartDataHtml).createBufferedImage(
        getIntegerParameter(parameters, "width", DEFAULT_WIDTH, 0),
        getIntegerParameter(parameters, "height", DEFAULT_HEIGHT, 0)
  );
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) {
  String w = req.getParameter("width");
  if(w==null)     w=String.valueOf(defaultW);
  String h = req.getParameter("height");
  if(h==null)     h=String.valueOf(defaultH);
  Color graphBg = stringToColor(req.getParameter("graphBg"));
  Color plotBg = stringToColor(req.getParameter("plotBg"));
  if (graph==null)    graph = createGraph();
  graph.setBackgroundPaint(graphBg);
  Plot p = graph.getPlot();
  p.setBackgroundPaint(plotBg);
  return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info);
}

代码示例来源:origin: mikaelhg/openblocks

public CLineGraph(String title, int seriesNum, Color background) {
  super("", SwingConstants.CENTER);
  this.chartData = new LineData(title, true, 0.0, 30.0, 0.0, 100.0, seriesNum);
  this.chart = chartData.makeChart();
  this.background = background == null ? DEFAULT_BACKGROUND : background;
  this.chart.setBackgroundPaint(this.background);
  this.chart.setBorderPaint(null);
  ImageIcon icon = new ImageIcon(chart.createBufferedImage(150, 100));
  this.setLayout(null);
  this.setIcon(icon);
  this.setBounds(0, 0, 170, 130);
}

代码示例来源:origin: org.codehaus.sonar/sonar-deprecated

/**
 * Generates a JFreeChart chart using a set of parameters
 * 
 * @param params the chart parameters
 * @return the generated chart
 */
@Override
public BufferedImage generateImage(ChartParameters params) {
 JFreeChart chart = new JFreeChart(null, TextTitle.DEFAULT_FONT, getPlot(params), hasLegend());
 improveChart(chart, params);
 return chart.createBufferedImage(params.getWidth(), params.getHeight());
}

相关文章