use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testGetRendererForDataset2.
@Test
public void testGetRendererForDataset2() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
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
CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
assertEquals(renderer2, plot.getRendererForDataset(dataset2));
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testDatasetIndices.
/**
* Datasets are now stored in a Map, and it should be possible to assign
* them an arbitrary key (index).
*/
@Test
public void testDatasetIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
assertEquals(dataset, plot.getDataset(0));
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
// we should be able to give a dataset an arbitrary index
plot.setDataset(99, dataset2);
assertEquals(2, plot.getDatasetCount());
assertEquals(dataset2, plot.getDataset(99));
assertEquals(0, plot.indexOf(dataset));
assertEquals(99, plot.indexOf(dataset2));
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CombinedDomainCategoryPlotTest method createPlot.
/**
* Creates a sample plot.
*
* @return A sample plot.
*/
private CombinedDomainCategoryPlot createPlot() {
CategoryDataset dataset1 = createDataset1();
NumberAxis rangeAxis1 = new NumberAxis("Value");
rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
subplot1.setDomainGridlinesVisible(true);
CategoryDataset dataset2 = createDataset2();
NumberAxis rangeAxis2 = new NumberAxis("Value");
rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer2 = new BarRenderer();
renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
subplot2.setDomainGridlinesVisible(true);
CategoryAxis domainAxis = new CategoryAxis("Category");
CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
plot.add(subplot1, 2);
plot.add(subplot2, 1);
return plot;
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testDomainMarkerIndices.
@Test
public void testDomainMarkerIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
// add a second dataset, plotted against a second x axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
CategoryAxis xAxis2 = new CategoryAxis("X2");
plot.setDomainAxis(1, xAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToDomainAxis(99, 1);
CategoryMarker xMarker1 = new CategoryMarker(123);
plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(xMarker1));
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testAxisLocationIndices.
@Test
public void testAxisLocationIndices() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new BarRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
CategoryAxis xAxis2 = new CategoryAxis("X2");
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setDomainAxis(99, xAxis2);
plot.setRangeAxis(99, yAxis2);
plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(AxisLocation.BOTTOM_OR_RIGHT, plot.getDomainAxisLocation(99));
plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT);
assertEquals(AxisLocation.BOTTOM_OR_LEFT, plot.getRangeAxisLocation(99));
}
Aggregations