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));
}
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));
}
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));
}
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);
}
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);
}
Aggregations