use of org.jfree.chart.renderer.category.CategoryItemRenderer in project java-examples by urvanov-ru.
the class MyChartTheme method createStackedAreaChart.
/**
*/
protected JFreeChart createStackedAreaChart() throws JRException {
JFreeChart jfreeChart = super.createStackedAreaChart();
for (int n = 0; n < jfreeChart.getCategoryPlot().getRendererCount(); n++) {
System.out.println("n=" + n);
CategoryItemRenderer renderer = jfreeChart.getCategoryPlot().getRenderer(n);
renderer.setBaseItemLabelsVisible(true);
renderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
renderer.setBaseItemLabelPaint(getChart().getForecolor());
renderer.setBaseItemLabelFont(FontUtil.getInstance(chartContext.getJasperReportsContext()).getAwtFont(getFont(null), getLocale()));
}
return jfreeChart;
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer 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.renderer.category.CategoryItemRenderer 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.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testDomainMarkerIndices.
@Test
public void testDomainMarkerIndices() {
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 x axis
DefaultCategoryDataset dataset2 = new DefaultCategoryDataset();
dataset2.setValue(1, "R1", "C1");
plot.setDataset(99, dataset);
CategoryAxis xAxis2 = new CategoryAxis("X2");
plot.setDomainAxis(1, xAxis2);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
plot.setRenderer(99, renderer2);
plot.mapDatasetToDomainAxis(99, 1);
CategoryMarker xMarker1 = new CategoryMarker(123);
plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND);
assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains(xMarker1));
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlotTest method testAxisLocationIndices.
@Test
public void testAxisLocationIndices() {
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);
CategoryAxis xAxis2 = new CategoryAxis("X2");
NumberAxis yAxis2 = new NumberAxis("Y2");
plot.setDomainAxis(99, xAxis2);
plot.setRangeAxis(99, yAxis2);
plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT);
assertEquals(AxisLocation.BOTTOM_OR_RIGHT, plot.getDomainAxisLocation(99));
plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT);
assertEquals(AxisLocation.BOTTOM_OR_LEFT, plot.getRangeAxisLocation(99));
}
Aggregations