Search in sources :

Example 86 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testGetDomainAxisForDataset.

/**
 * Some tests for the getDomainAxisForDataset() method.
 */
@Test
public void testGetDomainAxisForDataset() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(xAxis, plot.getDomainAxisForDataset(0));
    // should get IllegalArgumentException for negative index
    boolean pass = false;
    try {
        plot.getDomainAxisForDataset(-1);
    } catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
    // if multiple axes are mapped, the first in the list should be
    // returned...
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(1, xAxis2);
    assertEquals(xAxis, plot.getDomainAxisForDataset(0));
    plot.mapDatasetToDomainAxis(0, 1);
    assertEquals(xAxis2, plot.getDomainAxisForDataset(0));
    List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
    plot.mapDatasetToDomainAxes(0, axisIndices);
    assertEquals(xAxis, plot.getDomainAxisForDataset(0));
    axisIndices = Arrays.asList(new Integer[] { new Integer(1), new Integer(2) });
    plot.mapDatasetToDomainAxes(0, axisIndices);
    assertEquals(xAxis2, plot.getDomainAxisForDataset(0));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) List(java.util.List) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 87 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testCloning2.

/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) List(java.util.List) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) Test(org.junit.Test)

Example 88 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class XYPlotTest method testAxisIndices.

@Test
public void testAxisIndices() {
    XYDataset dataset = new XYSeriesCollection();
    NumberAxis xAxis = new NumberAxis("X");
    NumberAxis yAxis = new NumberAxis("Y");
    XYItemRenderer renderer = new DefaultXYItemRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    assertEquals(xAxis, plot.getDomainAxis(0));
    assertEquals(yAxis, plot.getRangeAxis(0));
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(99, xAxis2);
    assertEquals(xAxis2, plot.getDomainAxis(99));
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(99, yAxis2);
    assertEquals(yAxis2, plot.getRangeAxis(99));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) DefaultXYDataset(org.jfree.data.xy.DefaultXYDataset) DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) Test(org.junit.Test)

Example 89 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullQ1.

/**
 * Draws a chart where the dataset contains a null Q1 value.
 */
@Test
public void testDrawWithNullQ1() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), null, new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 90 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.

the class BoxAndWhiskerRendererTest method testDrawWithNullMedian.

/**
 * Draws a chart where the dataset contains a null median value.
 */
@Test
public void testDrawWithNullMedian() {
    boolean success;
    try {
        DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
        dataset.add(new BoxAndWhiskerItem(new Double(1.0), null, new Double(0.0), new Double(4.0), new Double(0.5), new Double(4.5), new Double(-0.5), new Double(5.5), null), "S1", "C1");
        CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("Category"), new NumberAxis("Value"), new BoxAndWhiskerRenderer());
        ChartRenderingInfo info = new ChartRenderingInfo();
        JFreeChart chart = new JFreeChart(plot);
        /* BufferedImage image = */
        chart.createBufferedImage(300, 200, info);
        success = true;
    } catch (Exception e) {
        success = false;
    }
    assertTrue(success);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) BoxAndWhiskerItem(org.jfree.data.statistics.BoxAndWhiskerItem) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Aggregations

NumberAxis (org.jfree.chart.axis.NumberAxis)259 JFreeChart (org.jfree.chart.JFreeChart)146 Test (org.junit.Test)118 XYPlot (org.jfree.chart.plot.XYPlot)98 CategoryAxis (org.jfree.chart.axis.CategoryAxis)95 CategoryPlot (org.jfree.chart.plot.CategoryPlot)80 ValueAxis (org.jfree.chart.axis.ValueAxis)45 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)44 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)40 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)39 XYSeries (org.jfree.data.xy.XYSeries)38 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)37 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)30 XYDataset (org.jfree.data.xy.XYDataset)30 Color (java.awt.Color)28 DateAxis (org.jfree.chart.axis.DateAxis)27 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)27 BasicStroke (java.awt.BasicStroke)25 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)24 CategoryDataset (org.jfree.data.category.CategoryDataset)21