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

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

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

JFreeChart.draw介绍

[英]Draws the chart on a Java 2D graphics device (such as the screen or a printer).

This method is the focus of the entire JFreeChart library.
[中]在Java 2D图形设备(如屏幕或打印机)上绘制图表。
此方法是整个JFreeChart库的焦点。

代码示例

代码示例来源:origin: geotools/geotools

BufferedImage drawChart(JFreeChart chart, int w, int h) {
  BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR);
  Graphics2D gr = bi.createGraphics();
  try {
    chart.draw(gr, new Rectangle2D.Double(0, 0, w, h));
  } finally {
    gr.dispose();
  }
  return bi;
}

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

/**
 * Draws the chart on a Java 2D graphics device (such as the screen or a
 * printer).  This method is the focus of the entire JFreeChart library.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the chart should be drawn.
 * @param info  records info about the drawing (null means collect no info).
 */
public void draw(Graphics2D g2, Rectangle2D area, ChartRenderingInfo info) {
  draw(g2, area, null, info);
}

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

/**
 * Draws the chart on a Java 2D graphics device (such as the screen or a
 * printer).  This method is the focus of the entire JFreeChart library.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the chart should be drawn.
 * @param info  records info about the drawing (null means collect no info).
 */
public void draw(Graphics2D g2, Rectangle2D area, ChartRenderingInfo info) {
  draw(g2, area, null, info);
}

代码示例来源:origin: jasperreports/jasperreports

public void render(Graphics2D grx, Rectangle2D rectangle) 
{
  if (chart != null)
  {
    chart.draw(grx, rectangle);
  }
}

代码示例来源:origin: jasperreports/jasperreports

public void render(Graphics2D grx, Rectangle2D rectangle) 
{
  if (chart != null)
  {
    chart.draw(grx, rectangle);
  }
}

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

/**
 * Draws the chart on a Java 2D graphics device (such as the screen or a
 * printer).
 * <P>
 * This method is the focus of the entire JFreeChart library.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the chart should be drawn.
 */
public void draw(Graphics2D g2, Rectangle2D area) {
  draw(g2, area, null, null);
}

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

/**
 * Draws the chart on a Java 2D graphics device (such as the screen or a
 * printer).
 * <P>
 * This method is the focus of the entire JFreeChart library.
 *
 * @param g2  the graphics device.
 * @param area  the area within which the chart should be drawn.
 */
@Override
public void draw(Graphics2D g2, Rectangle2D area) {
  draw(g2, area, null, null);
}

代码示例来源:origin: danfickle/openhtmltopdf

@Override
  public void render(Graphics2D graphics2D) {
    chart1.draw(graphics2D, new Rectangle2D.Float((float) 0, (float) 0,
        (float) (width / dotsPerPixel), (float) (height / dotsPerPixel)), renderingInfo);
  }
});

代码示例来源:origin: danfickle/openhtmltopdf

@Override
  public void render(Graphics2D graphics2D) {
    chart1.draw(graphics2D, new Rectangle2D.Float((float) 0, (float) 0,
        (float) (width / dotsPerPixel), (float) (height / dotsPerPixel)), renderingInfo);
  }
});

代码示例来源:origin: org.geotools/gt-charts

BufferedImage drawChart(JFreeChart chart, int w, int h) {
  BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR);
  Graphics2D gr = bi.createGraphics();
  try {
    chart.draw(gr, new Rectangle2D.Double(0, 0, w, h));
  } finally {
    gr.dispose();
  }
  return bi;
}

代码示例来源:origin: lessthanoptimal/Java-Matrix-Benchmark

protected static BufferedImage draw(JFreeChart chart, int width, int height)
  {
    BufferedImage img =
        new BufferedImage(width , height,
            BufferedImage.TYPE_INT_RGB);
    Graphics2D g2 = img.createGraphics();

    chart.draw(g2, new Rectangle2D.Double(0, 0, width, height));

    g2.dispose();
    return img;
  }
}

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

/**
 * Creates and returns a buffered image into which the chart has been drawn.
 *
 * @param width  the width.
 * @param height  the height.
 * @param imageType  the image type.
 * @param info  carries back chart state information ({@code null}
 *              permitted).
 *
 * @return A buffered image.
 */
public BufferedImage createBufferedImage(int width, int height,
    int imageType, ChartRenderingInfo info) {
  BufferedImage image = new BufferedImage(width, height, imageType);
  Graphics2D g2 = image.createGraphics();
  draw(g2, new Rectangle2D.Double(0, 0, width, height), null, info);
  g2.dispose();
  return image;
}

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

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

代码示例来源:origin: org.n52.sensorweb/sensorwebclient-api

protected String createAndSaveImage(DesignOptions options, JFreeChart chart, ChartRenderingInfo renderingInfo) throws Exception {
  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 Exception("Could not save PNG!", e);
  }
}

代码示例来源:origin: org.openfuxml/ofx-wiki

private void saveEPS(JFreeChart chart)
{    
  File f = new File(config.getString("/ofx/dir[@type='image-eps']")+"/"+chartName+".eps");
  try
  {
    EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
    g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
    FileOutputStream out = new FileOutputStream(f);
    g2d.setupDocument(out, width, height);
    chart.draw(g2d, new Rectangle2D.Double(0,0,width, height));
    g2d.finish();
    out.close();
  }
  catch (FileNotFoundException e) {logger.error("",e);}
  catch (IOException e) {logger.error("",e);}
}

代码示例来源:origin: org.ujmp/ujmp-jfreechart

public synchronized void renderGraph(Graphics2D g2d) {
  Rectangle2D r = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
  try {
    redraw();
  } catch (Exception e) {
  }
  getChart().draw(g2d, r);
}

代码示例来源:origin: ujmp/universal-java-matrix-package

public synchronized void renderGraph(Graphics2D g2d) {
  Rectangle2D r = new Rectangle2D.Double(0, 0, getWidth(), getHeight());
  try {
    redraw();
  } catch (Exception e) {
  }
  getChart().draw(g2d, r);
}

代码示例来源:origin: org.n52.series-api/io

private BufferedImage createImage() {
  IoParameters parameters = getParameters();
  int width = parameters.getWidth();
  int height = parameters.getHeight();
  BufferedImage chartImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
  Graphics2D chartGraphics = chartImage.createGraphics();
  chartGraphics.fillRect(0, 0, width, height);
  chartGraphics.setColor(Color.WHITE);
  jFreeChart.setTextAntiAlias(true);
  jFreeChart.setAntiAlias(true);
  if (jFreeChart.getLegend() != null) {
    jFreeChart.getLegend()
         .setFrame(BlockBorder.NONE);
  }
  jFreeChart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height));
  return chartImage;
}

代码示例来源:origin: org.n52.sensorweb/timeseries-io

private BufferedImage drawChartToImage() {
  int width = getChartStyleDefinitions().getWidth();
  int height = getChartStyleDefinitions().getHeight();
  BufferedImage chartImage = new BufferedImage(width, height, TYPE_INT_RGB);
  Graphics2D chartGraphics = chartImage.createGraphics();
  chartGraphics.fillRect(0, 0, width, height);
  chartGraphics.setColor(WHITE);
  chart.setTextAntiAlias(true);
  chart.setAntiAlias(true);
  if (chart.getLegend() != null) {
    chart.getLegend()
       .setFrame(BlockBorder.NONE);
  }
  chart.draw(chartGraphics, new Rectangle2D.Float(0, 0, width, height));
  return chartImage;
}

代码示例来源:origin: org.aksw.beast/beast-viz-jfreechart

public static void saveChartAsPDF(OutputStream out, JFreeChart chart, int width, int height)
    throws DocumentException
{
  Rectangle pagesize = new Rectangle(width, height);
  Document document = new Document(pagesize, 50, 50, 50, 50);
  PdfWriter writer = PdfWriter.getInstance(document, out);
  document.open();
  PdfContentByte cb = writer.getDirectContent();
  PdfTemplate tp = cb.createTemplate(width, height);
  Graphics2D g2 = tp.createGraphics(width, height, new DefaultFontMapper());
  Rectangle2D r2D = new Rectangle2D.Double(0, 0, width, height);
  chart.draw(g2, r2D);
  g2.dispose();
  cb.addTemplate(tp, 0, 0);
  document.close();
}

相关文章