Example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.xy XYLineAndShapeRenderer XYLineAndShapeRenderer.

Prototype

public XYLineAndShapeRenderer(boolean lines, boolean shapes) 

Source Link

Document

Creates a new renderer.

Usage

From source file:net.sourceforge.entrainer.jfreechart.UnitChart.java

private XYItemRenderer getRenderer() {
    return new XYLineAndShapeRenderer(true, true);
}

From source file:utils.ChartUtils.java

/**
 * Update XY chart//from w ww . j av a2  s  .  c o  m
 * 
 * @param plot ChartPanel Plot
 * @param sortedArray Sorted array of values
 */
public static void updateXYChart(ChartPanel plot, double[] sortedArray) {

    XYPlot xyplot = plot.getChart().getXYPlot();

    double min = sortedArray[0];
    double max = sortedArray[sortedArray.length - 1];

    double median = Utils.getMedian(sortedArray);

    double q1 = Utils.getQ1(sortedArray);
    double q3 = Utils.getQ3(sortedArray);

    XYTextAnnotation annotation;

    //min-lowlimit horizontal
    XYSeries serie15 = new XYSeries("15");
    serie15.add(min, 0.5);

    //max-toplimit horizontal
    XYSeries serie16 = new XYSeries("16");
    serie16.add(max, 0.5);

    //min vertical
    XYSeries serie1 = new XYSeries("0");
    serie1.add(min, 0.45);
    serie1.add(min, 0.55);

    annotation = new XYTextAnnotation("Min", min, 0.40);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //min-q1 horizontal
    XYSeries serie2 = new XYSeries("1");
    serie2.add(min, 0.5);
    serie2.add(q1, 0.5);

    //q1 vertical  
    XYSeries serie3 = new XYSeries("2");
    serie3.add(q1, 0.1);
    serie3.add(q1, 0.9);

    annotation = new XYTextAnnotation("Q1", q1, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    // median 
    XYSeries serie_mediana = new XYSeries("11");
    serie_mediana.add(median, 0.1);
    serie_mediana.add(median, 0.9);

    annotation = new XYTextAnnotation("Median", median, 0.04);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q1-q3 horizontal sup
    XYSeries serie4 = new XYSeries("3");
    serie4.add(q1, 0.9);
    serie4.add(q3, 0.9);

    //q1-q3 horizontal inf
    XYSeries serie5 = new XYSeries("4");
    serie5.add(q1, 0.1);
    serie5.add(q3, 0.1);

    //q3 vertical
    XYSeries serie6 = new XYSeries("5");
    serie6.add(q3, 0.1);
    serie6.add(q3, 0.9);

    annotation = new XYTextAnnotation("Q3", q3, 0.08);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    //q3-max horizontal
    XYSeries serie7 = new XYSeries("6");
    serie7.add(q3, 0.5);
    serie7.add(max, 0.5);

    //max vertical
    XYSeries serie8 = new XYSeries("7");
    serie8.add(max, 0.45);
    serie8.add(max, 0.55);

    annotation = new XYTextAnnotation("Max", max, 0.4);
    annotation.setFont(new Font("SansSerif", Font.PLAIN, 11));
    xyplot.addAnnotation(annotation);

    XYSeriesCollection xyseriescollection = new XYSeriesCollection();

    xyseriescollection.addSeries(serie1);
    xyseriescollection.addSeries(serie2);
    xyseriescollection.addSeries(serie3);
    xyseriescollection.addSeries(serie4);
    xyseriescollection.addSeries(serie5);
    xyseriescollection.addSeries(serie6);
    xyseriescollection.addSeries(serie7);
    xyseriescollection.addSeries(serie8);
    xyseriescollection.addSeries(serie15);
    xyseriescollection.addSeries(serie16);
    xyseriescollection.addSeries(serie_mediana);

    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);

    xyplot.getRenderer().setSeriesPaint(0, Color.black);
    xyplot.getRenderer().setSeriesPaint(1, Color.black);
    xyplot.getRenderer().setSeriesPaint(2, Color.black);
    xyplot.getRenderer().setSeriesPaint(3, Color.black);
    xyplot.getRenderer().setSeriesPaint(4, Color.black);
    xyplot.getRenderer().setSeriesPaint(5, Color.black);
    xyplot.getRenderer().setSeriesPaint(6, Color.black);
    xyplot.getRenderer().setSeriesPaint(7, Color.black);
    xyplot.getRenderer().setSeriesPaint(8, Color.black);
    xyplot.getRenderer().setSeriesPaint(9, Color.black);
    xyplot.getRenderer().setSeriesPaint(10, Color.black);
    xyplot.getRenderer().setSeriesPaint(11, Color.black);
    xyplot.getRenderer().setSeriesPaint(12, Color.black);
    xyplot.getRenderer().setSeriesPaint(13, Color.black);

    //add dataset
    xyplot.setDataset(xyseriescollection);

    // add a second dataset and renderer... 
    XYSeriesCollection anotherserie = new XYSeriesCollection();

    XYSeries serie_point = new XYSeries("21");

    double[] yValue = { 0.47, 0.49, 0.51, 0.53 };

    for (int i = 0, j = 0; i < sortedArray.length; i++, j++) {
        if (j % 4 == 0) {
            j = 0;
        }
        serie_point.add(sortedArray[i], yValue[j]);
    }

    anotherserie.addSeries(serie_point);

    XYLineAndShapeRenderer renderer1 = new XYLineAndShapeRenderer(false, true);
    renderer1.setSeriesPaint(0, Color.lightGray);

    xyplot.setDataset(1, anotherserie);
    xyplot.setRenderer(1, renderer1);
}

From source file:com.joey.software.plottingToolkit.PlotingToolkit.java

public static JFreeChart getPlot(int[] xData, int[] yData, String title, String xlabel, String ylabel) {

    XYSeriesCollection datCol = getCollection(xData, yData, "Data");

    // Create the chart

    JFreeChart chart = ChartFactory.createXYLineChart(title, // Title
            xlabel, // X-Axis label
            ylabel, // Y-Axis label
            new XYSeriesCollection(), // Dataset
            PlotOrientation.VERTICAL, true, // Show legend
            true, true);//from w  w  w  .  j a v  a2  s .c  o m

    // Add the series
    chart.getXYPlot().setDataset(0, datCol);

    // Set the rendering
    XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true);

    chart.getXYPlot().setRenderer(0, rend1);

    return chart;
}

From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java

/**
 * Creates a new <TT>XYListSeriesCollection</TT> instance with default
 *    parameters and given points <TT>data</TT>.
 *  If <TT>data</TT> is a <SPAN CLASS="MATH"><I>n</I></SPAN>-row matrix,
 *  then the first row <TT>data</TT><SPAN CLASS="MATH">[0]</SPAN> represents the
 *  <SPAN CLASS="MATH"><I>x</I></SPAN>-coordinate vector, and every other row <TT>data</TT>
 * <SPAN CLASS="MATH">[<I>i</I>], <I>i</I> = 1,&#8230;, <I>n</I> - 1</SPAN>, represents a <SPAN CLASS="MATH"><I>y</I></SPAN>-coordinate set of points.
 *   Therefore, if the points represents curves to be plotted,
 *    <TT>data</TT><SPAN CLASS="MATH">[<I>i</I>][&nbsp;]</SPAN>, 
 * <SPAN CLASS="MATH"><I>i</I> = 0,&#8230;, <I>n</I> - 1</SPAN>,  corresponds
 *    to <SPAN CLASS="MATH"><I>n</I> - 1</SPAN> curves, all with the same <SPAN CLASS="MATH"><I>x</I></SPAN>-coordinates.
 *    Only the first <TT>numPoints</TT> of <TT>data</TT> will be considered
 * for each of the set of points./* www .j  ava  2  s .c  om*/
 * 
 * @param data series of point sets.
 * 
 *    @param numPoints Number of points to plot
 * 
 * 
 */
public XYListSeriesCollection(double[][] data, int numPoints) {
    renderer = new XYLineAndShapeRenderer(true, false);
    // ((XYLineAndShapeRenderer)renderer).setShapesVisible(false);
    seriesCollection = new XYSeriesCollection();

    XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
    if (data.length < 2)
        throw new IllegalArgumentException("Unable to render the plot. data contains less than two rows");

    // n-1 curves: data[0] is x; data[i] is y for each curve
    for (int j = 1; j < data.length; j++) {
        XYSeries serie = new XYSeries(" ");
        for (int k = 0; k < numPoints; k++)
            serie.add(data[0][k], data[j][k]);
        tempSeriesCollection.addSeries(serie);
    }

    // set default colors
    for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++)
        renderer.setSeriesPaint(i, getDefaultColor(i));

    // set default plot style
    plotStyle = new String[tempSeriesCollection.getSeriesCount()];
    marksType = new String[tempSeriesCollection.getSeriesCount()];
    dashPattern = new String[tempSeriesCollection.getSeriesCount()];
    for (int i = 0; i < tempSeriesCollection.getSeriesCount(); i++) {
        marksType[i] = " ";
        plotStyle[i] = "smooth";
        dashPattern[i] = "solid";
    }
}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LinePlot.java

@Override
protected void update() {
    XYDataset dataset = null;/*from  www. j a v  a 2 s.c  o  m*/

    //generate the plot data
    if (controller.getShowIndividualTraces()) {
        dataset = new DefaultTableXYDataset();

        for (ResultKey key : frame.getSelectedResults()) {
            generateIndividualSeries(key, (DefaultTableXYDataset) dataset);
        }
    } else {
        dataset = new YIntervalSeriesCollection();

        for (ResultKey key : frame.getSelectedResults()) {
            generateQuantileSeries(key, (YIntervalSeriesCollection) dataset);
        }
    }

    //create the chart
    JFreeChart chart = ChartFactory.createXYLineChart(metric, localization.getString("text.NFE"),
            localization.getString("text.value"), dataset, PlotOrientation.VERTICAL, false, true, false);
    final XYPlot plot = chart.getXYPlot();

    //setup the series renderer
    if (controller.getShowIndividualTraces()) {
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(1f, 1, 1));
            renderer.setSeriesPaint(i, paint);
        }

        plot.setRenderer(renderer);
    } else {
        DeviationRenderer renderer = new DeviationRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(3f, 1, 1));
            renderer.setSeriesPaint(i, paint);
            renderer.setSeriesFillPaint(i, paint);
        }

        plot.setRenderer(renderer);
    }

    //create the legend
    final LegendItemCollection items = plot.getLegendItems();
    Iterator<?> iterator = items.iterator();
    Set<ResultKey> uniqueKeys = new HashSet<ResultKey>();

    while (iterator.hasNext()) {
        LegendItem item = (LegendItem) iterator.next();

        if (uniqueKeys.contains(item.getSeriesKey())) {
            iterator.remove();
        } else {
            uniqueKeys.add((ResultKey) item.getSeriesKey());
        }
    }

    LegendItemSource source = new LegendItemSource() {

        @Override
        public LegendItemCollection getLegendItems() {
            return items;
        }

    };

    LegendTitle legend = new LegendTitle(source);
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.WHITE);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addLegend(legend);

    //scale the axes
    final NumberAxis domainAxis = new NumberAxis();
    domainAxis.setAutoRange(true);
    plot.setDomainAxis(domainAxis);

    //add overlay
    if (controller.getShowLastTrace() && !controller.getShowIndividualTraces()
            && (controller.getLastAccumulator() != null)
            && controller.getLastAccumulator().keySet().contains(metric)) {
        DefaultTableXYDataset dataset2 = new DefaultTableXYDataset();
        XYSeries series = new XYSeries(localization.getString("text.last"), false, false);

        for (int i = 0; i < controller.getLastAccumulator().size(metric); i++) {
            series.add((Number) controller.getLastAccumulator().get("NFE", i),
                    (Number) controller.getLastAccumulator().get(metric, i));
        }

        dataset2.addSeries(series);

        XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
        renderer2.setSeriesStroke(0, new BasicStroke(1f, 1, 1));
        renderer2.setSeriesPaint(0, Color.BLACK);

        plot.setDataset(1, dataset2);
        plot.setRenderer(1, renderer2);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    //update the chart in the GUI
    removeAll();
    add(new ChartPanel(chart), BorderLayout.CENTER);
    revalidate();
    repaint();
}

From source file:edu.umn.ecology.populus.plot.BasicPlotCanvas.java

private void jbInit() throws Exception {
    /*//from ww w .j  a  v a 2  s.co m
    if( info != null ) {
       mainCaption = new HTMLLabel( info.getMainCaption() );
       xCaption = new HTMLLabel( info.getXCaptions()[0] );
       yCaption = new HTMLLabel( info.getYCaptions()[0] );
       yCaption.setDirection( HTMLLabel.DOWN_TO_UP );
    } else {
       mainCaption = new HTMLLabel( "Main Caption" );
       xCaption = new HTMLLabel( "X Caption" );
       yCaption = new HTMLLabel( "Y Caption" );
    }
     */
    //*
    if (info != null) {
        mainCaption = new HTMLMultiLabel(info.getMainCaption());
        xCaption = new HTMLMultiLabel(info.getXCaptions());
        yCaption = new HTMLMultiLabel(info.getYCaptions());
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    } else {
        mainCaption = new HTMLMultiLabel("Main Caption");
        xCaption = new HTMLMultiLabel("X Caption");
        yCaption = new HTMLMultiLabel("Y Caption");
        yCaption.setDirection(HTMLLabel.DOWN_TO_UP);
    }
    setLayout(borderLayout1);
    if (PopPreferencesStorage.isUseJFreeClass()) {
        NumberAxis yAxis = new NumberAxis(null);
        NumberAxis xAxis = new NumberAxis(null);
        xAxis.setAutoRangeIncludesZero(false);

        AbstractXYItemRenderer renderer = null;
        if (info.isBarChart) {
            renderer = new XYBarRenderer();
        } else {
            renderer = new XYLineAndShapeRenderer(true, false);
        }

        XYPlot plot = new XYPlot(null, xAxis, yAxis, renderer);
        plot.setOrientation(PlotOrientation.VERTICAL);

        JFreeChart jfchart = new JFreeChart(null, null, plot, false);
        jfchartpanel = new ChartPanel(jfchart);
        plot.setBackgroundPaint(ColorScheme.bG);

        info.styleJFree(jfchart);
        add(jfchartpanel, MacroLayout.CENTER);
    } else {
        chart = new JCChart(JCChart.PLOT);
        info.styleJC(chart);
        chart.setBackground(ColorScheme.bG);
        chart.setAllowUserChanges(true);
        chart.setTrigger(0, new EventTrigger(InputEvent.SHIFT_MASK, EventTrigger.CUSTOMIZE));
        chart.setTrigger(1, new EventTrigger(InputEvent.BUTTON1_MASK, EventTrigger.ZOOM));
        chart.setResetKey('r');
        chart.addMouseListener(new java.awt.event.MouseAdapter() {

            public void mouseClicked(java.awt.event.MouseEvent e) {
                if ((e.getModifiers() & InputEvent.META_MASK) != 0) {
                    info.setAxis(chart);
                    chart.reset();
                }
            }
        });
        chart.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
        chart.setWarningDialog(false);
        add(chart, MacroLayout.CENTER);
    }
    setBGColor();
    add(mainCaption, MacroLayout.NORTH);
    add(xCaption, MacroLayout.SOUTH);
    add(yCaption, MacroLayout.WEST);
}

From source file:net.sf.mzmine.chartbasics.HistogramChartFactory.java

/**
 * Adds a Gaussian curve to the plot/*from  w  w w .j a v  a 2 s.  c o  m*/
 * 
 * @param plot
 * @param fit double[] {normFactor, mean, sigma}
 * @param drawStart start of curve
 * @param drawEnd end of curve
 * @param gMin lower bound of Gaussian fit
 * @param gMax upper bound of Gaussian fit
 * @param sigDigits number of significant digits
 * @return
 */
public static double[] addGaussianFit(XYPlot plot, double[] fit, double drawStart, double drawEnd, double gMin,
        double gMax, int sigDigits, boolean annotations) {
    double gWidth = gMax - gMin;

    Gaussian g = new Gaussian(fit[0], fit[1], fit[2]);

    // create xy series for gaussian
    String mean = Precision.toString(fit[1], sigDigits, 7);
    String sigma = Precision.toString(fit[2], sigDigits, 7);
    String norm = Precision.toString(fit[0], sigDigits, 7);
    XYSeries gs = new XYSeries(
            "Gaussian: " + mean + " \u00B1 " + sigma + " [" + norm + "] (mean \u00B1 sigma [normalisation])");
    // add lower dp number out of gaussian fit range
    int steps = 100;
    if (gMin > drawStart) {
        for (int i = 0; i <= steps; i++) {
            double x = drawStart + ((gMin - drawStart) / steps) * i;
            double y = g.value(x);
            gs.add(x, y);
        }
    }
    // add high resolution in gaussian fit area
    steps = 1000;
    for (int i = 0; i <= steps; i++) {
        double x = gMin + (gWidth / steps) * i;
        double y = g.value(x);
        gs.add(x, y);
    }
    // add lower dp number out of gaussian fit range
    steps = 100;
    if (gMax < drawEnd) {
        for (int i = 0; i <= steps; i++) {
            double x = gMax + ((drawEnd - gMax) / steps) * i;
            double y = g.value(x);
            gs.add(x, y);
        }
    }
    // add gaussian
    XYSeriesCollection gsdata = new XYSeriesCollection(gs);
    int index = plot.getDatasetCount();
    plot.setDataset(index, gsdata);
    plot.setRenderer(index, new XYLineAndShapeRenderer(true, false));

    if (annotations)
        addGaussianFitAnnotations(plot, fit);

    return fit;
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createTimeSeriesChart2(XYDataset dataset) {

    DateAxis timeAxis = new DateAxis(xAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);/*  www  .  java  2 s  .  com*/
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    JFreeChart chart = new JFreeChart("TimeSeries Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);

    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}

From source file:wef.articulab.view.ui.CombinedBNXYPlot.java

private XYPlot createPlot(ChartContainer chartContainer) {
    createDataset(chartContainer);/*w ww  . java  2  s.  co m*/
    chartContainer.target = new IntervalMarker(14, 16);
    chartContainer.target.setLabel("Activation Threshold");
    chartContainer.target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    chartContainer.target.setLabelAnchor(RectangleAnchor.LEFT);
    chartContainer.target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    chartContainer.target.setPaint(new Color(222, 222, 255, 128));
    XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    BasicStroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    for (int i = 0; i < chartContainer.series.length - 1; i++) {
        renderer.setSeriesStroke(i, stroke);
    }
    renderer.setSeriesStroke(chartContainer.series.length - 1, new BasicStroke(2.0f, BasicStroke.CAP_BUTT,
            BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f));

    NumberAxis rangeAxis = new NumberAxis("Activation");
    NumberAxis domainAxis = new NumberAxis("Time");
    XYPlot plot = new XYPlot(chartContainer.dataset, domainAxis, rangeAxis, renderer);
    plot.addRangeMarker(chartContainer.target, Layer.BACKGROUND);
    plot.setRenderer(renderer);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    chartContainer.plot = plot;
    return plot;
}

From source file:ucar.unidata.idv.flythrough.ChartDecorator.java

/**
 * _more_/*w w  w .j  a v a2s. c o  m*/
 *
 * @param g2 _more_
 * @param comp _more_
 *
 * @return _more_
 */
public boolean paintDashboard(Graphics2D g2, JComponent comp) {
    try {
        List<SampleInfo> infos = new ArrayList<SampleInfo>(sampleInfos);
        if (infos.size() == 0) {
            return false;
        }
        Rectangle b = comp.getBounds();
        JFrame dummyFrame = new JFrame("");
        XYSeriesCollection dataset = new XYSeriesCollection();
        JFreeChart chart = Flythrough.createChart(dataset);
        XYPlot xyPlot = (XYPlot) chart.getPlot();

        int chartHeight = b.height - flythrough.getDashboardImage().getHeight(null);
        chartHeight = Math.max(chartHeight, 50);
        int chartWidth = Math.min(chartHeight * 4, b.width);

        int dx = b.width / 2 - chartWidth / 2;
        int dy = 0;

        Image lastImage = lastChartImage;
        if ((lastImage != null) && (lastImage.getWidth(null) == chartWidth)
                && (lastImage.getHeight(null) == chartHeight)) {
            g2.translate(dx, dy);
            g2.drawImage(lastImage, 0, 0, null);
            g2.translate(-dx, -dy);
            return false;
        }

        for (int i = 0; i < infos.size(); i++) {
            SampleInfo info = infos.get(i);
            ValueAxis rangeAxis = new NumberAxis(info.getName());
            if (info.getRange() != null) {
                rangeAxis
                        .setRange(new org.jfree.data.Range(info.getRange().getMin(), info.getRange().getMax()));
            }
            dataset = new XYSeriesCollection();
            dataset.addSeries(info.getSeries());
            xyPlot.setRangeAxis(i, rangeAxis, false);
            xyPlot.setDataset(i, dataset);
            xyPlot.mapDatasetToRangeAxis(i, i);
            final Color color = COLORS[i % COLORS.length];
            XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false) {
                public Paint xgetItemPaint(final int row, final int column) {
                    return color;
                }
            };
            renderer.setSeriesPaint(0, color);
            xyPlot.setRenderer(i, renderer);
        }

        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(new Dimension(chartWidth, chartHeight));
        dummyFrame.setContentPane(chartPanel);
        dummyFrame.pack();
        Image image = ImageUtils.getImage(chartPanel);
        lastChartImage = image;
        g2.translate(dx, dy);
        g2.drawImage(image, 0, 0, null);
        g2.translate(-dx, -dy);
    } catch (Exception exc) {
        logException("Painting chart", exc);

    }

    return false;

}