class Sparkline {

    private double min;
    private double max;
    private SparklineParameters parameters;
    private TimelineChart chart;
    private BufferedImage image;

    public BufferedImage getImage(TimelineModel model, int width, int height) {
        double newMin = model.getCustomMin();
        double newMax = model.getCustomMax();
        TimelineChart newChart = model.getChart();
        if (chart == null || newMax != max || newMin != min || image.getWidth() != width || image.getHeight() != height
            || newChart != chart) {
            min = newMin;
            max = newMax;
            chart = newChart;

            if (chart != null) {
                double minX = chart.getMinX().doubleValue();
                double maxX = chart.getMaxX().doubleValue();
                int sparklineWidth = (int) (((maxX - minX) / (max - min)) * width);

                parameters = new SparklineParameters(sparklineWidth, height);
                parameters.setTransparentBackground(true);
                parameters.setDrawArea(true);

                image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
                int sparklineX = (int) ((minX - min) / (max - min) * width);
                BufferedImage sparklineImage = draw();
                Graphics g = image.getGraphics();
                g.drawImage(sparklineImage, sparklineX, 0, null);
                g.dispose();
            } else {
                return null;
            }
        }
        return image;
    }

    private BufferedImage draw() {<FILL_FUNCTION_BODY>}
}

        BufferedImage img =
            SparklineGraph.draw(chart.getX(), chart.getY(), chart.getMinY(), chart.getMaxY(), parameters);
        return img;
    
<no_super_class>