当前位置: 首页>>代码示例>>Java>>正文


Java ChartUtilities.writeChartAsPNG方法代码示例

本文整理汇总了Java中org.jfree.chart.ChartUtilities.writeChartAsPNG方法的典型用法代码示例。如果您正苦于以下问题:Java ChartUtilities.writeChartAsPNG方法的具体用法?Java ChartUtilities.writeChartAsPNG怎么用?Java ChartUtilities.writeChartAsPNG使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jfree.chart.ChartUtilities的用法示例。


在下文中一共展示了ChartUtilities.writeChartAsPNG方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    String resultFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-rezultati.txt");
    String definitionFile = req.getServletContext().getRealPath(
            "/WEB-INF/glasanje-definicija.txt");

    List<Band> results = ServerUtilty
            .getResults(definitionFile, resultFile);

    JFreeChart chart = ServerUtilty.getChart(results);
    ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chart, 700, 400);
    resp.getOutputStream().flush();
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:20,代码来源:GlasanjeGrafikaServlet.java

示例2: generatePieChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * Controller that handles the chart generation for a question statistics
 * @param surveyDefinitionId
 * @param pageOrder
 * @param questionOrder
 * @param recordCount
 * @param response
 */
@Secured({"ROLE_ADMIN","ROLE_SURVEY_ADMIN"})
@RequestMapping(value="/chart/{surveyDefinitionId}/{questionId}")
public void generatePieChart(@PathVariable("surveyDefinitionId")  Long surveyDefinitionId,
							 @PathVariable("questionId")  Long questionId, 
							 HttpServletResponse response) {
	try {
		response.setContentType("image/png");
		long recordCount  = surveyService.surveyStatistic_get(surveyDefinitionId).getSubmittedCount();
		PieDataset pieDataSet= createDataset(questionId,recordCount);
		JFreeChart chart = createChart(pieDataSet, "");
		ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, 340 ,200);
		response.getOutputStream().close();
	} catch (Exception e) {
		log.error(e.getMessage(),e);
		throw (new RuntimeException(e));
	}
}
 
开发者ID:JD-Software,项目名称:JDeSurvey,代码行数:26,代码来源:StatisticsController.java

示例3: write

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * @param out
 * @return extension png or jpg for usage as file name extension.
 */
public String write(final OutputStream out)
{
  final JFreeChart chart = getJFreeChart();
  final int width = getWidth();
  final int height = getHeight();
  String extension = null;
  try {
    if (getImageType() == JFreeChartImageType.PNG) {
      extension = "png";
      ChartUtilities.writeChartAsPNG(out, chart, width, height);
    } else {
      extension = "jpg";
      ChartUtilities.writeChartAsJPEG(out, chart, width, height);
    }
  } catch (final IOException ex) {
    log.error("Exception encountered " + ex, ex);
  }
  return extension;
}
 
开发者ID:micromata,项目名称:projectforge-webapp,代码行数:24,代码来源:ExportJFreeChart.java

示例4: execute

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public String execute() throws Exception{
    response.setContentType("image/png");
    OutputStream out = response.getOutputStream();
    Convention c = (Convention)sessionData.get("conference");
    
    // Create a simple Bar chart
    //DefaultValueDataset dataset = new org.jfree.data.general.DefaultValueDataset();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    if (c.conCap > 0) {
    	dataset.setValue(c.conCap,"Value","Event Cap");
    }
    dataset.setValue(c.numSubscribed,"Value","Subscribed");
    dataset.setValue(c.numRegistered,"Value","Registered");
    dataset.setValue(c.numBadged,"Value","Badged");
    dataset.setValue(c.numCheckedin,"Value","Checkedin");
    JFreeChart chart = ChartFactory.createBarChart(null,
    		null,null,dataset,PlotOrientation.HORIZONTAL,false,false,false);
    
    ChartUtilities.writeChartAsPNG(out, chart, 750, 125);

    return null;

}
 
开发者ID:shevett,项目名称:congo,代码行数:24,代码来源:Statistics.java

示例5: doGet

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    List<PollOption> results = null;
    try {
        Long pollId = (Long) req.getSession().getAttribute("pollID");
        results = DAOProvider.getDao().getPollOptions(pollId);
    } catch (Exception ex) {
        results = new ArrayList<>();
    }

    JFreeChart chart = DBUtility.getChart(results);
    ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chart, 700, 400);
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:19,代码来源:GlasanjeGrafikaServlet.java

示例6: createChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * Creates a chart for recent time to fix.
 *
 */
public void createChart(final SortedMap time, final String valueKey, final Color lineColor, final OutputStream out) throws IOException {

  final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  addTimeToDataSet(dataset, time, valueKey);

  // create the chart object

  // This generates a stacked bar - more suitable

  final JFreeChart chart = ChartFactory.createLineChart(null,
    "Recent builds", "Time", dataset,
    PlotOrientation.VERTICAL,
    true, false, false);
  chart.setBackgroundPaint(Color.white);

  // change the auto tick unit selection to integer units only

  final CategoryPlot plot = chart.getCategoryPlot();
  final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
  rangeAxis.setStandardTickUnits(StatisticsUtils.createWordedTimeTickUnits());

  // rotate X dates

  final CategoryAxis domainAxis = plot.getDomainAxis();
  domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

  // set bar colors

  final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
  line.setSeriesPaint(0, lineColor);
  line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);

  // write to reposnce

  final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
  ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:42,代码来源:BuildTimeChartGenerator.java

示例7: handleRequest

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String type = request.getParameter("type");
    CategoryDataset dataset = createDataset(type);
    JFreeChart chart = createChart(dataset, request);

    int imageHeight = Math.max(IMAGE_MIN_HEIGHT, 15 * dataset.getColumnCount());

    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, IMAGE_WIDTH, imageHeight);
    return null;
}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:12,代码来源:UserChartController.java

示例8: doGet

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    JFreeChart chart = getChart();
    ChartUtilities.writeChartAsPNG(resp.getOutputStream(), chart, 700, 400);
}
 
开发者ID:fgulan,项目名称:java-course,代码行数:10,代码来源:ReportImageServlet.java

示例9: createChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public void createChart(final SortedMap stats, final OutputStream out) throws IOException {

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry)iter.next();
      final Integer buildNumber = (Integer)entry.getKey();
      final Integer violations = (Integer)entry.getValue();
      dataset.addValue(violations, categoryDescription, buildNumber);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createLineChart(null,
      "Recent builds", valueAxisLabel, dataset,
      PlotOrientation.VERTICAL,
      true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // rotate X dates
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // set bar colors

    final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
    line.setSeriesPaint(0, Color.RED);
    line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:39,代码来源:CodeAnalysisChartGenerator.java

示例10: createTestsResultsChartHelper

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
/**
   *
   */
  private static void createTestsResultsChartHelper(final String categoryLabel, final DefaultCategoryDataset dataset, final OutputStream out, final CategoryLabelPositions categoryLabelPosition) throws IOException {
    final JFreeChart chart = ChartFactory.createStackedAreaChart(null,
            categoryLabel, "Tests", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final LogarithmicAxis logarithmicAxis = new LogarithmicAxis("Tests");
    logarithmicAxis.setStrictValuesFlag(false);
    logarithmicAxis.setAutoRangeIncludesZero(true);
    logarithmicAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setRangeAxis(logarithmicAxis);
//    final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();

    // rotate X dates
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(categoryLabelPosition);

    // set area colors

    final StackedAreaRenderer area = (StackedAreaRenderer) plot.getRenderer();
    area.setSeriesPaint(0, Color.RED); // first area
    area.setSeriesPaint(1, Color.PINK); // second area
    area.setSeriesPaint(2, Color.GREEN); // thirs area
    //plot.setRenderer(area);

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:36,代码来源:StatisticsUtils.java

示例11: createHourlyBreakageDistributionChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void createHourlyBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry) iter.next();
      final Integer hour = (Integer) entry.getKey();
      final BuildStatistics bst = (BuildStatistics) entry.getValue();
      dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", hour);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createStackedBarChart(null,
            categoryLabel, "Builds", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // set bar colors
    final BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemMargin(0); // reduce the width between the bars.
    bar.setSeriesPaint(0, Color.RED); // first bar

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:34,代码来源:StatisticsUtils.java

示例12: createRecentBuildTimesChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void createRecentBuildTimesChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {

    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry) iter.next();
      final Integer buildNumber = (Integer) entry.getKey();
      final Integer timeInSeconds = (Integer) entry.getValue();
      dataset.addValue(timeInSeconds, "Build time", buildNumber);
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createLineChart(null,
            categoryLabel, "Build time", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setStandardTickUnits(createWordedTimeTickUnits());

    // rotate X dates
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // set bar colors

    final LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
    line.setSeriesPaint(0, Color.BLUE);
    line.setStroke(DEFAULT_LINE_STROKE);

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:StatisticsUtils.java

示例13: createDayOfWeekBreakageDistributionChart

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public static void createDayOfWeekBreakageDistributionChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {


    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
      final Map.Entry entry = (Map.Entry) iter.next();
      final Integer dayOfWeek = (Integer) entry.getKey();
      final BuildStatistics bst = (BuildStatistics) entry.getValue();
      dataset.addValue(new Integer(bst.getFailedBuilds()), "Failed builds", new ComparableDayOfWeek(dayOfWeek));
    }

    // create the chart object

    // This generates a stacked bar - more suitable
    final JFreeChart chart = ChartFactory.createStackedBarChart(null,
            categoryLabel, "Builds", dataset,
            PlotOrientation.VERTICAL,
            true, false, false);
    chart.setBackgroundPaint(Color.white);

    // change the auto tick unit selection to integer units only
    final CategoryPlot plot = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // set bar colors
    final BarRenderer bar = (BarRenderer) plot.getRenderer();
    bar.setItemMargin(0); // reduce the width between the bars.
    bar.setSeriesPaint(0, Color.RED); // first bar

    // write to reposnce
    final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
  }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:35,代码来源:StatisticsUtils.java

示例14: toByteArray

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public byte[] toByteArray() {

        final ByteArrayOutputStream tmpStream = new ByteArrayOutputStream();

        try {
            ChartUtilities.writeChartAsPNG(tmpStream, myDelegate, myWidth, myHeight);
        } catch (final IOException anException) {
            // TODO Something!!
        }

        return tmpStream.toByteArray();
    }
 
开发者ID:optimatika,项目名称:ojAlgo-extensions,代码行数:13,代码来源:JFreeChartAdaptor.java

示例15: handleRequest

import org.jfree.chart.ChartUtilities; //导入方法依赖的package包/类
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String type = request.getParameter("type");
    CategoryDataset dataset = createDataset(type);
    JFreeChart chart = createChart(dataset, request);

    int imageHeight = Math.max(IMAGE_MIN_HEIGHT, 15 * dataset.getColumnCount());

    ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, IMAGE_WIDTH, imageHeight);
    return null;
}
 
开发者ID:sindremehus,项目名称:subsonic,代码行数:11,代码来源:UserChartController.java


注:本文中的org.jfree.chart.ChartUtilities.writeChartAsPNG方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。