Search in sources :

Example 1 with BufferedImage

use of com.google.code.appengine.awt.image.BufferedImage in project activityinfo by bedatadriven.

the class ChartRendererJC method renderImage.

public BufferedImage renderImage(PivotChartReportElement element, boolean includeTitle, int width, int height, int dpi) {
    try {
        Chart chart = createChart(element, includeTitle, width, height, dpi);
        BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
        chart.setGraphics2D(bufferedImage.createGraphics());
        chart.render();
        return bufferedImage;
    } catch (IOException e) {
        throw new ReportModelException(e, element);
    } catch (ChartDataException e) {
        throw new ReportModelException(e, element);
    } catch (PropertyException e) {
        throw new ReportModelException(e, element);
    }
}
Also used : ReportModelException(org.activityinfo.legacy.shared.exception.ReportModelException) ChartDataException(org.krysalis.jcharts.chartData.ChartDataException) IOException(java.io.IOException) AxisChart(org.krysalis.jcharts.axisChart.AxisChart) Chart(org.krysalis.jcharts.Chart) BufferedImage(com.google.code.appengine.awt.image.BufferedImage)

Example 2 with BufferedImage

use of com.google.code.appengine.awt.image.BufferedImage in project activityinfo by bedatadriven.

the class ChartRendererJC method render.

public void render(PivotChartReportElement element, OutputStream os) throws IOException {
    BufferedImage image = renderImage(element, true, 640, 480, 96);
    ImageIO.write(image, "PNG", os);
}
Also used : BufferedImage(com.google.code.appengine.awt.image.BufferedImage)

Example 3 with BufferedImage

use of com.google.code.appengine.awt.image.BufferedImage in project activityinfo by bedatadriven.

the class ImageMapRenderer method render.

public void render(MapReportElement element, OutputStream os) throws IOException {
    BufferedImage image = new BufferedImage(element.getWidth(), element.getHeight(), ColorSpace.TYPE_RGB);
    Graphics2D g2d = image.createGraphics();
    render(element, g2d);
    ImageIO.write(image, "PNG", os);
}
Also used : BufferedImage(com.google.code.appengine.awt.image.BufferedImage)

Example 4 with BufferedImage

use of com.google.code.appengine.awt.image.BufferedImage in project activityinfo by bedatadriven.

the class ImageMapRenderer method getIconImage.

private BufferedImage getIconImage(String name) {
    BufferedImage image = iconImages.get(name);
    if (image == null) {
        try {
            image = ImageIO.read(getImageFile(name));
            iconImages.put(name, image);
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "Exception reading icon '" + name + "'", e);
        }
    }
    return image;
}
Also used : IOException(java.io.IOException) BufferedImage(com.google.code.appengine.awt.image.BufferedImage)

Example 5 with BufferedImage

use of com.google.code.appengine.awt.image.BufferedImage in project activityinfo by bedatadriven.

the class GcsBlobFieldStorageServiceTest method thumbnail.

@Test
public void thumbnail() throws IOException {
    int width = 30;
    int height = 20;
    Response response = blobService.getThumbnail(user, blobId, resourceId, width, height);
    assertEquals(response.getStatus(), 200);
    Object entity = response.getEntity();
    String directory = "target/blob-test/thumbnail";
    createDirectory(directory);
    File imageFile = new File(directory + File.separator + FILE_NAME);
    BufferedImage bufferedImage = ImageIO.read(new ByteArrayInputStream((byte[]) entity));
    ImageIO.write(bufferedImage, MimeTypeUtil.fileExtension(FILE_NAME), imageFile);
    System.out.println(imageFile.getAbsolutePath());
    assertEquals(bufferedImage.getWidth(), width);
// we don't check height because image scales depending on width
// assertEquals(bufferedImage.getHeight(), height);
}
Also used : Response(javax.ws.rs.core.Response) ByteArrayInputStream(java.io.ByteArrayInputStream) File(java.io.File) BufferedImage(com.google.code.appengine.awt.image.BufferedImage) Test(org.junit.Test)

Aggregations

BufferedImage (com.google.code.appengine.awt.image.BufferedImage)8 File (java.io.File)3 Color (com.google.code.appengine.awt.Color)2 Graphics2D (com.google.code.appengine.awt.Graphics2D)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IOException (java.io.IOException)2 Response (javax.ws.rs.core.Response)2 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 SliceValue (org.activityinfo.legacy.shared.reports.content.PieMapMarker.SliceValue)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 ServletException (javax.servlet.ServletException)1 ReportModelException (org.activityinfo.legacy.shared.exception.ReportModelException)1 Chart (org.krysalis.jcharts.Chart)1 AxisChart (org.krysalis.jcharts.axisChart.AxisChart)1 ChartDataException (org.krysalis.jcharts.chartData.ChartDataException)1