use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testRangeMarkerIndices.
@Test
public void testRangeMarkerIndices() {
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 axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setRangeAxis(1, yAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToRangeAxis(99, 1);
ValueMarker yMarker1 = new ValueMarker(123);
plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND);
assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1));
}
use of org.jfree.data.category.CategoryDataset 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.data.category.CategoryDataset 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.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class BarChartFXDemo1 method start.
/**
* Adds a chart viewer to the stage and displays it.
*
* @param stage the stage.
* @throws Exception if something goes wrong.
*/
@Override
public void start(Stage stage) throws Exception {
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartViewer viewer = new ChartViewer(chart);
viewer.addChartMouseListener(this);
stage.setScene(new Scene(viewer));
stage.setTitle("JFreeChart: BarChartFXDemo1.java");
stage.setWidth(700);
stage.setHeight(390);
stage.show();
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class BarChartTest method testReplaceDataset.
/**
* Replaces the chart's dataset and then checks that the new dataset is OK.
*/
@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);
}
Aggregations