Search in sources :

Example 1 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer 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 2 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer 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 3 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer 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 4 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer 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 5 with DefaultXYItemRenderer

use of org.jfree.chart.renderer.xy.DefaultXYItemRenderer 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)

Aggregations

DefaultXYItemRenderer (org.jfree.chart.renderer.xy.DefaultXYItemRenderer)13 NumberAxis (org.jfree.chart.axis.NumberAxis)12 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)12 Test (org.junit.Test)12 StandardXYItemRenderer (org.jfree.chart.renderer.xy.StandardXYItemRenderer)11 DefaultXYDataset (org.jfree.data.xy.DefaultXYDataset)11 IntervalXYDataset (org.jfree.data.xy.IntervalXYDataset)11 XYDataset (org.jfree.data.xy.XYDataset)11 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)11 XYSeries (org.jfree.data.xy.XYSeries)6 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)4 List (java.util.List)3 BasicStroke (java.awt.BasicStroke)1 GradientPaint (java.awt.GradientPaint)1 Stroke (java.awt.Stroke)1 Point2D (java.awt.geom.Point2D)1 LegendItem (org.jfree.chart.LegendItem)1 LegendItemCollection (org.jfree.chart.LegendItemCollection)1 DefaultShadowGenerator (org.jfree.chart.util.DefaultShadowGenerator)1 RectangleInsets (org.jfree.ui.RectangleInsets)1