Search in sources :

Example 96 with NumberAxis

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

the class BoxAndWhiskerRendererTest method testGetLegendItem.

/**
 * Some checks for the getLegendItem() method.
 */
@Test
public void testGetLegendItem() {
    DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
    List values = new ArrayList();
    values.add(new Double(1.10));
    values.add(new Double(1.45));
    values.add(new Double(1.33));
    values.add(new Double(1.23));
    dataset.add(values, "R1", "C1");
    BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), new NumberAxis("y"), r);
    /*JFreeChart chart =*/
    new JFreeChart(plot);
    LegendItem li = r.getLegendItem(0, 0);
    assertNotNull(li);
    r.setSeriesVisibleInLegend(0, Boolean.FALSE);
    li = r.getLegendItem(0, 0);
    assertNull(li);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) LegendItem(org.jfree.chart.LegendItem) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) DefaultBoxAndWhiskerCategoryDataset(org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Test(org.junit.Test)

Example 97 with NumberAxis

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

the class XYPlotTest method testMapDatasetToDomainAxis.

@Test
public void testMapDatasetToDomainAxis() {
    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);
    NumberAxis xAxis2 = new NumberAxis("X2");
    plot.setDomainAxis(11, xAxis2);
    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);
    assertEquals(xAxis, plot.getDomainAxisForDataset(99));
    // now map the dataset to the second xAxis
    plot.mapDatasetToDomainAxis(99, 11);
    assertEquals(xAxis2, plot.getDomainAxisForDataset(99));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) XYSeries(org.jfree.data.xy.XYSeries) 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 98 with NumberAxis

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

the class XYPlotTest method testGetRendererForDataset2.

@Test
public void testGetRendererForDataset2() {
    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);
    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset2);
    // by default, the renderer with index 0 is used
    assertEquals(renderer, plot.getRendererForDataset(dataset2));
    // add a second renderer with the same index as dataset2, now it will
    // be used
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(99, renderer);
    assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) 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 99 with NumberAxis

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

the class XYPlotTest method testMapDatasetToRangeAxis.

@Test
public void testMapDatasetToRangeAxis() {
    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);
    NumberAxis yAxis2 = new NumberAxis("Y2");
    plot.setRangeAxis(22, yAxis2);
    // add a second dataset
    XYSeriesCollection dataset2 = new XYSeriesCollection();
    dataset2.addSeries(new XYSeries("Series in dataset 2"));
    plot.setDataset(99, dataset);
    assertEquals(yAxis, plot.getRangeAxisForDataset(99));
    // now map the dataset to the second xAxis
    plot.mapDatasetToRangeAxis(99, 22);
    assertEquals(yAxis2, plot.getRangeAxisForDataset(99));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) XYSeries(org.jfree.data.xy.XYSeries) 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 100 with NumberAxis

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

the class XYPlotTest method testRendererIndices.

@Test
public void testRendererIndices() {
    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(renderer, plot.getRenderer(0));
    // we should be able to give a renderer an arbitrary index
    XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    plot.setRenderer(20, renderer2);
    assertEquals(2, plot.getRendererCount());
    assertEquals(renderer2, plot.getRenderer(20));
    assertEquals(20, plot.getIndexOf(renderer2));
}
Also used : DefaultXYItemRenderer(org.jfree.chart.renderer.xy.DefaultXYItemRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) 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)

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