use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class StackedBarChartTest method testReplaceDataset.
/**
* Replaces the dataset and checks that it has changed as expected.
*/
@Test
public void testReplaceDataset() {
// create a dataset...
Number[][] data = new Integer[][] { { new Integer(-30), new Integer(-20) }, { new Integer(-10), new Integer(10) }, { new Integer(20), new Integer(30) } };
CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);
LocalListener l = new LocalListener();
this.chart.addChangeListener(l);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
plot.setDataset(newData);
assertEquals(true, l.flag);
ValueAxis axis = plot.getRangeAxis();
Range range = axis.getRange();
assertTrue("Expecting the lower bound of the range to be around -30: " + range.getLowerBound(), range.getLowerBound() <= -30);
assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class WaterfallChartTest method createWaterfallChart.
/**
* Create a bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createWaterfallChart() {
Number[][] data = new Integer[][] { { new Integer(-3), new Integer(-2) }, { new Integer(-1), new Integer(1) }, { new Integer(2), new Integer(3) } };
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
return ChartFactory.createWaterfallChart("Waterfall Chart", "Domain", "Range", dataset, PlotOrientation.HORIZONTAL, // include legend
true, true, true);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class LineChart3DTest method createLineChart3D.
/**
* Create a line chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createLineChart3D() {
Number[][] data = new Integer[][] { { new Integer(-3), new Integer(-2) }, { new Integer(-1), new Integer(1) }, { new Integer(2), new Integer(3) } };
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
return ChartFactory.createLineChart3D("Line Chart", "Domain", "Range", dataset);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class LineChartTest method createLineChart.
/**
* Create a line chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createLineChart() {
Number[][] data = new Integer[][] { { new Integer(-3), new Integer(-2) }, { new Integer(-1), new Integer(1) }, { new Integer(2), new Integer(3) } };
CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);
return ChartFactory.createLineChart("Line Chart", "Domain", "Range", dataset);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class DatasetReader method readCategoryDatasetFromXML.
/**
* Reads a {@link CategoryDataset} from a stream.
*
* @param in the stream.
*
* @return A dataset.
*
* @throws IOException if there is a problem reading the file.
*/
public static CategoryDataset readCategoryDatasetFromXML(InputStream in) throws IOException {
CategoryDataset result = null;
SAXParserFactory factory = SAXParserFactory.newInstance();
try {
SAXParser parser = factory.newSAXParser();
CategoryDatasetHandler handler = new CategoryDatasetHandler();
parser.parse(in, handler);
result = handler.getDataset();
} catch (SAXException e) {
System.out.println(e.getMessage());
} catch (ParserConfigurationException e2) {
System.out.println(e2.getMessage());
}
return result;
}
Aggregations