<commit_before>package charts.graphics;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;

import org.apache.commons.lang3.StringUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisSpace;
import org.jfree.chart.axis.AxisState;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DrawingSupplier;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.AbstractRenderer;
import org.jfree.chart.renderer.category.StatisticalLineAndShapeRenderer;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.text.TextBlock;
import org.jfree.text.TextUtilities;
import org.jfree.ui.RectangleEdge;

import boxrenderer.Align;
import boxrenderer.Box;
import boxrenderer.TableBox;
import boxrenderer.TableCellBox;
import boxrenderer.TableRowBox;
import boxrenderer.TextBox;
import charts.ChartType;
import charts.Drawable;
import charts.Region;

public class CoralCover {

    private static final String COVER = "Cover (%)";
    private static final String JUVENILE = "Juveniles/m\u00b2";

    public static Drawable createChart(final DefaultStatisticalCategoryDataset dataset,
            ChartType type, Region region, Dimension dimension) {
        String title = String.format("%s (mean)", type.getLabel());
        String rangeAxisLabel = (type == ChartType.CORAL_JUV)?JUVENILE:COVER;
        JFreeChart chart;
        if(region == Region.GBR) {
            chart = createChart(rearrange(dataset), title, rangeAxisLabel);
            CategoryPlot plot = (CategoryPlot)chart.getPlot();
            CategoryAxis cAxis = getSubCategoryAxis(dataset);
            cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
            cAxis.setLabel("Region");
            cAxis.setLabelFont(plot.getRangeAxis().getLabelFont());
            cAxis.setTickLabelFont(plot.getRangeAxis().getTickLabelFont());
            cAxis.setTickMarksVisible(false);
            plot.setDomainAxis(cAxis);
        } else {
            title = String.format(title + " in the %s region", region.getProperName());
            chart = createChart(dataset, title, rangeAxisLabel);
            CategoryPlot plot = (CategoryPlot)chart.getPlot();
            plot.getDomainAxis().setLabel("Year");
        }
        return new JFreeChartDrawable(chart, dimension);
    }

    private static JFreeChart createChart(final DefaultStatisticalCategoryDataset dataset, String title,
            String rangeAxisLabel) {
        JFreeChart chart = ChartFactory.createLineChart(
                title,  // title
                "",             // x-axis label
                rangeAxisLabel,   // y-axis label
                dataset,            // data
                PlotOrientation.VERTICAL,
                false,               // create legend?
                false,               // generate tooltips?
                false               // generate URLs?
            );
        chart.setBackgroundPaint(Color.white);
        StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer();
        renderer.setErrorIndicatorPaint(ErrorIndicator.ERROR_INDICATOR_COLOR);
        CategoryPlot plot = (CategoryPlot)chart.getPlot();
        plot.setRenderer(renderer);
        plot.setRangeGridlinePaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.lightGray);
        plot.setRangeGridlineStroke(new BasicStroke(1.0f));
        plot.setDomainGridlinesVisible(false);
        plot.setBackgroundPaint(Color.white);
        renderer.setDrawOutlines(true);
        renderer.setUseOutlinePaint(true);
        renderer.setUseFillPaint(false);
        plot.setDrawingSupplier(new DrawingSupplier() {
            @Override
            public Paint getNextPaint() {
                return new Color(187, 34, 51);
            }

            @Override
            public Paint getNextOutlinePaint() {
                return Color.black;
            }

            @Override
            public Paint getNextFillPaint() {
                return null;
            }

            @Override
            public Stroke getNextStroke() {
                return new BasicStroke(1.0f);
            }

            @Override
            public Stroke getNextOutlineStroke() {
                return new BasicStroke(1.0f);
            }

            @Override
            public Shape getNextShape() {
                return AbstractRenderer.DEFAULT_SHAPE;
            }});
        renderer.setBaseOutlinePaint(Color.black);
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setTickMarksVisible(false);
        rangeAxis.setTickUnit(new NumberTickUnit(
            (Math.round(Math.floor(getMax(dataset)))/20)+1, new DecimalFormat("0")));<commit_msg>fix y-axis to 0-10 for juvenile density graph<commit_after>package charts.graphics;

import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Paint;
import java.awt.Shape;
import java.awt.Stroke;
import java.awt.geom.Rectangle2D;
import java.text.DecimalFormat;

import org.apache.commons.lang3.StringUtils;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.AxisSpace;
import org.jfree.chart.axis.AxisState;
import org.jfree.chart.axis.CategoryAxis;
import org.jfree.chart.axis.CategoryLabelPositions;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.DrawingSupplier;
import org.jfree.chart.plot.Plot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.AbstractRenderer;
import org.jfree.chart.renderer.category.StatisticalLineAndShapeRenderer;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.text.TextBlock;
import org.jfree.text.TextUtilities;
import org.jfree.ui.RectangleEdge;

import boxrenderer.Align;
import boxrenderer.Box;
import boxrenderer.TableBox;
import boxrenderer.TableCellBox;
import boxrenderer.TableRowBox;
import boxrenderer.TextBox;
import charts.ChartType;
import charts.Drawable;
import charts.Region;

public class CoralCover {

    private static final String COVER = "Cover (%)";
    private static final String JUVENILE = "Juveniles/m\u00b2";

    public static Drawable createChart(final DefaultStatisticalCategoryDataset dataset,
            ChartType type, Region region, Dimension dimension) {
        String title = String.format("%s (mean)", type.getLabel());
        String rangeAxisLabel = (type == ChartType.CORAL_JUV)?JUVENILE:COVER;
        JFreeChart chart;
        if(region == Region.GBR) {
            chart = createChart(rearrange(dataset), title, rangeAxisLabel, type);
            CategoryPlot plot = (CategoryPlot)chart.getPlot();
            CategoryAxis cAxis = getSubCategoryAxis(dataset);
            cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
            cAxis.setLabel("Region");
            cAxis.setLabelFont(plot.getRangeAxis().getLabelFont());
            cAxis.setTickLabelFont(plot.getRangeAxis().getTickLabelFont());
            cAxis.setTickMarksVisible(false);
            plot.setDomainAxis(cAxis);
        } else {
            title = String.format(title + " in the %s region", region.getProperName());
            chart = createChart(dataset, title, rangeAxisLabel, type);
            CategoryPlot plot = (CategoryPlot)chart.getPlot();
            plot.getDomainAxis().setLabel("Year");
        }
        return new JFreeChartDrawable(chart, dimension);
    }

    private static JFreeChart createChart(final DefaultStatisticalCategoryDataset dataset, String title,
            String rangeAxisLabel, ChartType type) {
        JFreeChart chart = ChartFactory.createLineChart(
                title,  // title
                "",             // x-axis label
                rangeAxisLabel,   // y-axis label
                dataset,            // data
                PlotOrientation.VERTICAL,
                false,               // create legend?
                false,               // generate tooltips?
                false               // generate URLs?
            );
        chart.setBackgroundPaint(Color.white);
        StatisticalLineAndShapeRenderer renderer = new StatisticalLineAndShapeRenderer();
        renderer.setErrorIndicatorPaint(ErrorIndicator.ERROR_INDICATOR_COLOR);
        CategoryPlot plot = (CategoryPlot)chart.getPlot();
        plot.setRenderer(renderer);
        plot.setRangeGridlinePaint(Color.lightGray);
        plot.setDomainGridlinePaint(Color.lightGray);
        plot.setRangeGridlineStroke(new BasicStroke(1.0f));
        plot.setDomainGridlinesVisible(false);
        plot.setBackgroundPaint(Color.white);
        renderer.setDrawOutlines(true);
        renderer.setUseOutlinePaint(true);
        renderer.setUseFillPaint(false);
        plot.setDrawingSupplier(new DrawingSupplier() {
            @Override
            public Paint getNextPaint() {
                return new Color(187, 34, 51);
            }

            @Override
            public Paint getNextOutlinePaint() {
                return Color.black;
            }

            @Override
            public Paint getNextFillPaint() {
                return null;
            }

            @Override
            public Stroke getNextStroke() {
                return new BasicStroke(1.0f);
            }

            @Override
            public Stroke getNextOutlineStroke() {
                return new BasicStroke(1.0f);
            }

            @Override
            public Shape getNextShape() {
                return AbstractRenderer.DEFAULT_SHAPE;
            }});
        renderer.setBaseOutlinePaint(Color.black);
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setTickMarksVisible(false);
        if(type == ChartType.CORAL_JUV) {
          rangeAxis.setRange(0, 10.0);
          rangeAxis.setTickUnit(new NumberTickUnit(1, new DecimalFormat("0")));
        } else {
          rangeAxis.setTickUnit(new NumberTickUnit(
              (Math.round(Math.floor(getMax(dataset)))/20)+1, new DecimalFormat("0")));
        }
{'fraction_non_alphanumeric': 0.09517125210555867, 'fraction_numerical': 0.00552124274752012, 'mean_word_length': 2.6227118644067797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '7040064', 'n_tokens_mistral': 3000, 'n_tokens_neox': 2895, 'n_words': 539}