org.jfree.chart.encoders.ImageFormat Java Examples

The following examples show how to use org.jfree.chart.encoders.ImageFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartExportUtil.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public static void writeChartToJPEG(JFreeChart chart, ChartRenderingInfo info, int width,
    int height, File fileName, int resolution) throws IOException {
  // Background color
  Paint saved = chart.getBackgroundPaint();
  if (((Color) saved).getAlpha() == 0) {
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBackgroundImageAlpha(255);
    if (chart.getLegend() != null)
      chart.getLegend().setBackgroundPaint(Color.WHITE);
    // legends and stuff
    for (int i = 0; i < chart.getSubtitleCount(); i++)
      if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
        ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(Color.WHITE);

    // apply bg
    chart.getPlot().setBackgroundPaint(Color.WHITE);
  }
  //
  if (resolution == 72)
    writeChartToJPEG(chart, width, height, fileName);
  else {
    OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName));
    try {
      BufferedImage image = paintScaledChartToBufferedImage(chart, info, out, width, height,
          resolution, BufferedImage.TYPE_INT_RGB);
      EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, 1.f);
    } finally {
      out.close();
    }
  }
}
 
Example #2
Source File: ChartExportUtil.java    From old-mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public static void writeChartToJPEG(JFreeChart chart, ChartRenderingInfo info, int width,
    int height, File fileName, int resolution) throws IOException {
  // Background color
  Paint saved = chart.getBackgroundPaint();
  if (((Color) saved).getAlpha() == 0) {
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBackgroundImageAlpha(255);
    if (chart.getLegend() != null)
      chart.getLegend().setBackgroundPaint(Color.WHITE);
    // legends and stuff
    for (int i = 0; i < chart.getSubtitleCount(); i++)
      if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
        ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(Color.WHITE);

    // apply bg
    chart.getPlot().setBackgroundPaint(Color.WHITE);
  }
  //
  if (resolution == 72)
    writeChartToJPEG(chart, width, height, fileName);
  else {
    OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName));
    try {
      BufferedImage image = paintScaledChartToBufferedImage(chart, info, out, width, height,
          resolution, BufferedImage.TYPE_INT_RGB);
      EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, 1.f);
    } finally {
      out.close();
    }
  }
}
 
Example #3
Source File: ChartExportUtil.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public static void writeChartToJPEG(JFreeChart chart, ChartRenderingInfo info, int width,
    int height, File fileName, int resolution) throws IOException {
  // Background color
  Paint saved = chart.getBackgroundPaint();
  if (((Color) saved).getAlpha() == 0) {
    chart.setBackgroundPaint(Color.WHITE);
    chart.setBackgroundImageAlpha(255);
    if (chart.getLegend() != null)
      chart.getLegend().setBackgroundPaint(Color.WHITE);
    // legends and stuff
    for (int i = 0; i < chart.getSubtitleCount(); i++)
      if (PaintScaleLegend.class.isAssignableFrom(chart.getSubtitle(i).getClass()))
        ((PaintScaleLegend) chart.getSubtitle(i)).setBackgroundPaint(Color.WHITE);

    // apply bg
    chart.getPlot().setBackgroundPaint(Color.WHITE);
  }
  //
  if (resolution == 72)
    writeChartToJPEG(chart, width, height, fileName);
  else {
    OutputStream out = new BufferedOutputStream(new FileOutputStream(fileName));
    try {
      BufferedImage image = paintScaledChartToBufferedImage(chart, info, out, width, height,
          resolution, BufferedImage.TYPE_INT_RGB);
      EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, 1.f);
    } finally {
      out.close();
    }
  }
}
 
Example #4
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encodes a {@link BufferedImage} to PNG format.
 *
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the PNG compression level (0-9).
 *
 * @return The byte array in PNG format.
 * 
 * @throws IOException if there is an I/O problem.
 */
public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha, 
                                 int compression) 
        throws IOException {
    return EncoderUtil.encode(image, ImageFormat.PNG, compression, 
            encodeAlpha);
}
 
Example #5
Source File: ChartUtilities.java    From SIMVA-SoS with Apache License 2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #6
Source File: ChartUtilities.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #7
Source File: ChartUtilities.java    From ECG-Viewer with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression)
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
            compression, encodeAlpha);
}
 
Example #8
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in PNG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
        int width, int height,  ChartRenderingInfo info)
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage bufferedImage
            = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
}
 
Example #9
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info)
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #10
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info)
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #11
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression)
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
            compression, encodeAlpha);
}
 
Example #12
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Encodes a {@link BufferedImage} to PNG format.
 *
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the PNG compression level (0-9).
 *
 * @return The byte array in PNG format.
 *
 * @throws IOException if there is an I/O problem.
 */
public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha,
                                 int compression)
        throws IOException {
    return EncoderUtil.encode(image, ImageFormat.PNG, compression,
            encodeAlpha);
}
 
Example #13
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in PNG format.  This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
        int width, int height,  ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage bufferedImage 
            = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
}
 
Example #14
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #15
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #16
Source File: ChartUtilities.java    From astor with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression) 
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out, 
            compression, encodeAlpha);
}
 
Example #17
Source File: ChartUtilities.java    From openstock with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #18
Source File: ChartUtilities.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in PNG format.  This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
        int width, int height,  ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage bufferedImage 
            = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
}
 
Example #19
Source File: ChartUtilities.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #20
Source File: ChartUtilities.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows 
 * you to pass in a {@link ChartRenderingInfo} object, to collect 
 * information about the chart dimensions/entities.  You will need this 
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info) 
        throws IOException {

    if (chart == null) {
        throw new IllegalArgumentException("Null 'chart' argument.");
    }
    BufferedImage image = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #21
Source File: ChartUtilities.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression) 
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out, 
            compression, encodeAlpha);
}
 
Example #22
Source File: ChartUtilities.java    From opensim-gui with Apache License 2.0 3 votes vote down vote up
/**
 * Encodes a {@link BufferedImage} to PNG format.
 *
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the PNG compression level (0-9).
 *
 * @return The byte array in PNG format.
 * 
 * @throws IOException if there is an I/O problem.
 */
public static byte[] encodeAsPNG(BufferedImage image, boolean encodeAlpha, 
                                 int compression) 
        throws IOException {
    return EncoderUtil.encode(image, ImageFormat.PNG, compression, 
            encodeAlpha);
}
 
Example #23
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in PNG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
        int width, int height,  ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage bufferedImage
            = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
}
 
Example #24
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #25
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #26
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression)
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
            compression, encodeAlpha);
}
 
Example #27
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in PNG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsPNG(OutputStream out, JFreeChart chart,
        int width, int height,  ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage bufferedImage
            = chart.createBufferedImage(width, height, info);
    EncoderUtil.writeBufferedImage(bufferedImage, ImageFormat.PNG, out);
}
 
Example #28
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format. This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, JFreeChart chart,
        int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out);

}
 
Example #29
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a chart to an output stream in JPEG format.  This method allows
 * you to pass in a {@link ChartRenderingInfo} object, to collect
 * information about the chart dimensions/entities.  You will need this
 * info if you want to create an HTML image map.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param quality  the output quality (0.0f to 1.0f).
 * @param chart  the chart (<code>null</code> not permitted).
 * @param width  the image width.
 * @param height  the image height.
 * @param info  the chart rendering info (<code>null</code> permitted).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeChartAsJPEG(OutputStream out, float quality,
        JFreeChart chart, int width, int height, ChartRenderingInfo info)
        throws IOException {

    ParamChecks.nullNotPermitted(out, "out");
    ParamChecks.nullNotPermitted(chart, "chart");
    BufferedImage image = chart.createBufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB, info);
    EncoderUtil.writeBufferedImage(image, ImageFormat.JPEG, out, quality);

}
 
Example #30
Source File: ChartUtilities.java    From buffer_bci with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Writes a {@link BufferedImage} to an output stream in PNG format.
 *
 * @param out  the output stream (<code>null</code> not permitted).
 * @param image  the image (<code>null</code> not permitted).
 * @param encodeAlpha  encode alpha?
 * @param compression  the compression level (0-9).
 *
 * @throws IOException if there are any I/O errors.
 */
public static void writeBufferedImageAsPNG(OutputStream out,
        BufferedImage image, boolean encodeAlpha, int compression)
        throws IOException {

    EncoderUtil.writeBufferedImage(image, ImageFormat.PNG, out,
            compression, encodeAlpha);
}