Search in sources :

Example 6 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project SIMVA-SoS by SESoS.

the class RendererUtilitiesTest method testFindLiveItemsLowerBound_Ascending.

/**
 * Some checks for the findLiveItemsLowerBound() method when the dataset is
 * ASCENDING.
 */
@Test
public void testFindLiveItemsLowerBound_Ascending() {
    DefaultXYDataset d = new DefaultXYDataset() {

        @Override
        public DomainOrder getDomainOrder() {
            // only add data in ascending order by x-value
            return DomainOrder.ASCENDING;
        }
    };
    // check a series with no items
    d.addSeries("S1", new double[][] { {}, {} });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.1));
    // check a series with one item
    d.addSeries("S2", new double[][] { { 1.0 }, { 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, 2.2));
    // check a series with two items
    d.addSeries("S3", new double[][] { { 1.0, 2.0 }, { 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, 2.2));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, 3.3));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, 4.4));
    // check a series with three items
    d.addSeries("S4", new double[][] { { 1.0, 2.0, 3.0 }, { 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.2));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.3));
    assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.4));
    // check a series with four items
    d.addSeries("S5", new double[][] { { 1.0, 2.0, 3.0, 4.0 }, { 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 2.2));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 3.3));
    assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.4));
    assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, 5.5));
    // check a series with repeating items
    d.addSeries("S5", new double[][] { { 1.0, 2.0, 2.0, 2.0, 3.0 }, { 9.9, 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, 4.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, 4.0));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, 4.0));
    assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, 4.0));
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 7 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project SIMVA-SoS by SESoS.

the class RendererUtilitiesTest method testFindLiveItemsLowerBound_Descending.

/**
 * Some checks for the findLiveItemsLowerBound() method when the dataset is
 * DESCENDING.
 */
@Test
public void testFindLiveItemsLowerBound_Descending() {
    DefaultXYDataset d = new DefaultXYDataset() {

        @Override
        public DomainOrder getDomainOrder() {
            // only add data in descending order by x-value
            return DomainOrder.DESCENDING;
        }
    };
    // check a series with no items
    d.addSeries("S1", new double[][] { {}, {} });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, 11.0));
    // check a series with one item
    d.addSeries("S2", new double[][] { { 1.0 }, { 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, 1.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, 2.0));
    // check a series with two items
    d.addSeries("S3", new double[][] { { 2.0, 1.0 }, { 9.9, 9.9 } });
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 0.5));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, 1.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, 2.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, 3.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, 4.0));
    // check a series with three items
    d.addSeries("S4", new double[][] { { 3.0, 2.0, 1.0 }, { 9.9, 9.9, 9.9 } });
    assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, 1.0));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, 2.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, 3.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, 4.0));
    // check a series with four items
    d.addSeries("S5", new double[][] { { 4.0, 3.0, 2.0, 1.0 }, { 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 0.5));
    assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, 1.0));
    assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, 2.0));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, 3.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, 4.0));
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, 5.0));
    // check a series with repeating items
    d.addSeries("S6", new double[][] { { 3.0, 2.0, 2.0, 2.0, 1.0 }, { 9.9, 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 3.0));
    assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 2.0));
    assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 1.0));
    assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, 0.5));
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 8 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project SIMVA-SoS by SESoS.

the class RendererUtilitiesTest method testFindLiveItemsUpperBound_Unordered.

/**
 * Some checks for the findLiveItemsUpperBound() method when the dataset is
 * unordered.
 */
@Test
public void testFindLiveItemsUpperBound_Unordered() {
    DefaultXYDataset d = new DefaultXYDataset();
    // check a series with no items
    d.addSeries("S1", new double[][] { {}, {} });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, 11.0));
    // check a series with one item
    d.addSeries("S2", new double[][] { { 1.0 }, { 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, 1.1));
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, 3.3));
    // check a series with two items
    d.addSeries("S3", new double[][] { { 1.0, 2.0 }, { 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, 1.1));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, 2.2));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, 3.3));
    assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, 4.4));
    // check a series with three items
    d.addSeries("S4", new double[][] { { 1.0, 2.0, 1.5 }, { 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, 1.1));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, 2.2));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, 3.3));
    assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, 4.4));
    // check a series with four items
    d.addSeries("S5", new double[][] { { 1.0, 2.0, 1.5, 1.8 }, { 9.9, 9.9, 9.9, 9.9 } });
    assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, 1.1));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, 2.2));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, 3.3));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, 4.4));
    assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, 5.5));
}
Also used : DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 9 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project SIMVA-SoS by SESoS.

the class ChartPanelTest method test2502355_zoomInRange.

/**
 * Checks that a call to the zoomInRange() method, for a plot with more
 * than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomInRange() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomInRange(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Example 10 with DefaultXYDataset

use of org.jfree.data.xy.DefaultXYDataset in project SIMVA-SoS by SESoS.

the class ChartPanelTest method test2502355_zoomOutRange.

/**
 * Checks that a call to the zoomOutRange() method, for a plot with more
 * than one range axis, generates just one ChartChangeEvent.
 */
@Test
public void test2502355_zoomOutRange() {
    DefaultXYDataset dataset = new DefaultXYDataset();
    JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setRangeAxis(1, new NumberAxis("X2"));
    ChartPanel panel = new ChartPanel(chart);
    chart.addChangeListener(this);
    this.chartChangeEvents.clear();
    panel.zoomOutRange(1.0, 2.0);
    assertEquals(1, this.chartChangeEvents.size());
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) Test(org.junit.Test)

Aggregations

DefaultXYDataset (org.jfree.data.xy.DefaultXYDataset)28 Test (org.junit.Test)24 JFreeChart (org.jfree.chart.JFreeChart)8 NumberAxis (org.jfree.chart.axis.NumberAxis)7 XYPlot (org.jfree.chart.plot.XYPlot)7 Rectangle2D (java.awt.geom.Rectangle2D)4 BufferedImage (java.awt.image.BufferedImage)4 Graphics2D (java.awt.Graphics2D)3 Range (org.jfree.data.Range)3 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 OutputStream (java.io.OutputStream)2 List (java.util.List)2 JFrame (javax.swing.JFrame)2 ChartPanel (org.jfree.chart.ChartPanel)2 XYSplineRenderer (org.jfree.chart.renderer.xy.XYSplineRenderer)2 VCellHelper (org.vcell.imagej.helper.VCellHelper)2 IJDataList (org.vcell.imagej.helper.VCellHelper.IJDataList)2 IJTimeSeriesJobResults (org.vcell.imagej.helper.VCellHelper.IJTimeSeriesJobResults)2 IJVarInfos (org.vcell.imagej.helper.VCellHelper.IJVarInfos)2