use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testGetDomainAxisForDataset.
/**
* Some tests for the getDomainAxisForDataset() method.
*/
@Test
public void testGetDomainAxisForDataset() {
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(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...
CategoryAxis xAxis2 = new CategoryAxis("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));
}
use of org.jfree.chart.axis.NumberAxis in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testGetRangeAxisForDataset.
/**
* Some tests for the getRangeAxisForDataset() method.
*/
@Test
public void testGetRangeAxisForDataset() {
CategoryDataset dataset = new DefaultCategoryDataset();
CategoryAxis xAxis = new CategoryAxis("X");
NumberAxis yAxis = new NumberAxis("Y");
CategoryItemRenderer renderer = new DefaultCategoryItemRenderer();
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
// should get IllegalArgumentException for negative index
boolean pass = false;
try {
plot.getRangeAxisForDataset(-1);
} catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
// if multiple axes are mapped, the first in the list should be
// returned...
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
plot.mapDatasetToRangeAxis(0, 1);
assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
List axisIndices = Arrays.asList(new Integer[] { new Integer(0), new Integer(1) });
plot.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(yAxis, plot.getRangeAxisForDataset(0));
axisIndices = Arrays.asList(new Integer[] { new Integer(1), new Integer(2) });
plot.mapDatasetToRangeAxes(0, axisIndices);
assertEquals(yAxis2, plot.getRangeAxisForDataset(0));
}
use of org.jfree.chart.axis.NumberAxis 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.chart.axis.NumberAxis 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.chart.axis.NumberAxis 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;
}
Aggregations