<commit_before>package com.xhub.pdflego.formatter;

import com.xhub.pdflego.bloc.PLImageBlock;
import com.xhub.pdflego.core.Component;
import com.xhub.pdflego.formatter.pdf.ImageRenderStrategy;
import de.erichseifert.gral.graphics.DrawingContext;
import de.erichseifert.gral.io.plots.DrawableWriter;
import de.erichseifert.gral.io.plots.DrawableWriterFactory;
import de.erichseifert.gral.plots.AbstractPlot;
import com.itextpdf.layout.Canvas;
import org.apache.log4j.Logger;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Created by amine
 */
public class PlotRenderHelper<T extends Component> {
    private Logger logger = Logger.getLogger(PlotRenderHelper.class);
    public void drawPlot(AbstractPlot plot, T component, Canvas componentCanvas){
        int width = component.getWidth();
        int height = component.getHeight();
        BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = (Graphics2D) bImage.getGraphics();
        DrawingContext context = new DrawingContext(g2d);
        plot.draw(context);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        DrawableWriter wr = DrawableWriterFactory.getInstance().get("image/jpeg");
        try {
            wr.write(plot, stream, width, height);
            stream.flush();
            PLImageBlock image = PLImageBlock.create(component);
            image.setImage(stream.toByteArray());
            ImageRenderStrategy imageRenderer = new ImageRenderStrategy();
            imageRenderer.render(componentCanvas, image);
            stream.close();
        } catch (IOException e) {
            logger.error("could not write the plot to " + stream, e);
        }
    }
}
<commit_msg>switched to png, highter quality, and making use of transparancy<commit_after>package com.xhub.pdflego.formatter;

import com.xhub.pdflego.bloc.PLImageBlock;
import com.xhub.pdflego.core.Component;
import com.xhub.pdflego.formatter.pdf.ImageRenderStrategy;
import de.erichseifert.gral.graphics.DrawingContext;
import de.erichseifert.gral.io.plots.DrawableWriter;
import de.erichseifert.gral.io.plots.DrawableWriterFactory;
import de.erichseifert.gral.plots.AbstractPlot;
import com.itextpdf.layout.Canvas;
import org.apache.log4j.Logger;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

/**
 * Created by amine
 */
public class PlotRenderHelper<T extends Component> {
    private Logger logger = Logger.getLogger(PlotRenderHelper.class);
    public void drawPlot(AbstractPlot plot, T component, Canvas componentCanvas){
        int width = component.getWidth();
        int height = component.getHeight();
        BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        Graphics2D g2d = (Graphics2D) bImage.getGraphics();
        DrawingContext context = new DrawingContext(g2d);
        plot.draw(context);
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        DrawableWriter wr = DrawableWriterFactory.getInstance().get("image/png");
        try {
            wr.write(plot, stream, width, height);
            stream.flush();
            PLImageBlock image = PLImageBlock.create(component);
            image.setImage(stream.toByteArray());
            ImageRenderStrategy imageRenderer = new ImageRenderStrategy();
            imageRenderer.render(componentCanvas, image);
            stream.close();
        } catch (IOException e) {
            logger.error("could not write the plot to " + stream, e);
        }
    }
}

{'fraction_non_alphanumeric': 0.10185185185185185, 'fraction_numerical': 0.0027233115468409588, 'mean_word_length': 3.59125, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '373535', 'n_tokens_mistral': 1062, 'n_tokens_neox': 1039, 'n_words': 217}