use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method setDataset.
/**
* Sets a dataset for the plot and sends a change notification to all
* registered listeners.
*
* @param index the dataset index (must be >= 0).
* @param dataset the dataset ({@code null} permitted).
*
* @see #getDataset(int)
*/
public void setDataset(int index, CategoryDataset dataset) {
CategoryDataset existing = (CategoryDataset) this.datasets.get(index);
if (existing != null) {
existing.removeChangeListener(this);
}
this.datasets.put(index, dataset);
if (dataset != null) {
dataset.addChangeListener(this);
}
// send a dataset change event to self...
DatasetChangeEvent event = new DatasetChangeEvent(this, dataset);
datasetChanged(event);
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class CategoryPlot method drawDomainGridlines.
/**
* Draws the domain gridlines for the plot, if they are visible.
*
* @param g2 the graphics device.
* @param dataArea the area inside the axes.
*
* @see #drawRangeGridlines(Graphics2D, Rectangle2D, List)
*/
protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) {
if (!isDomainGridlinesVisible()) {
return;
}
CategoryAnchor anchor = getDomainGridlinePosition();
RectangleEdge domainAxisEdge = getDomainAxisEdge();
CategoryDataset dataset = getDataset();
if (dataset == null) {
return;
}
CategoryAxis axis = getDomainAxis();
if (axis != null) {
int columnCount = dataset.getColumnCount();
for (int c = 0; c < columnCount; c++) {
double xx = axis.getCategoryJava2DCoordinate(anchor, c, columnCount, dataArea, domainAxisEdge);
CategoryItemRenderer renderer1 = getRenderer();
if (renderer1 != null) {
renderer1.drawDomainGridline(g2, this, dataArea, xx);
}
}
}
}
use of org.jfree.data.category.CategoryDataset in project SIMVA-SoS by SESoS.
the class BarChart3DTest method testReplaceDataset.
/**
* Replaces the dataset and checks that the data range is 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 StackedAreaChartTest method testReplaceDataset.
/**
* Replaces the dataset and checks that it has changed as expected.
*/
@Test
public void testReplaceDataset() {
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 StackedBarChartTest method createChart.
/**
* Create a stacked bar chart with sample data in the range -3 to +3.
*
* @return The chart.
*/
private static JFreeChart createChart() {
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.createStackedBarChart(// chart title
"Stacked Bar Chart", "Domain", "Range", // data
dataset, PlotOrientation.HORIZONTAL, // include legend
true, true, true);
}
Aggregations