use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class ChartFactory method createGanttChart.
/**
* Creates a Gantt chart using the supplied attributes plus default values
* where required. The chart object returned by this method uses a
* {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
* for the domain axis, a {@link DateAxis} as the range axis, and a
* {@link GanttRenderer} as the renderer.
*
* @param title the chart title (<code>null</code> permitted).
* @param categoryAxisLabel the label for the category axis
* (<code>null</code> permitted).
* @param dateAxisLabel the label for the date axis
* (<code>null</code> permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return A Gantt chart.
*/
public static JFreeChart createGanttChart(String title, String categoryAxisLabel, String dateAxisLabel, IntervalCategoryDataset dataset, boolean legend, boolean tooltips, boolean urls) {
CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
DateAxis dateAxis = new DateAxis(dateAxisLabel);
CategoryItemRenderer renderer = new GanttRenderer();
if (tooltips) {
renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()));
}
if (urls) {
renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
}
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer);
plot.setOrientation(PlotOrientation.HORIZONTAL);
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
currentTheme.apply(chart);
return chart;
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class ChartFactory method createStackedBarChart3D.
/**
* Creates a stacked bar chart with a 3D effect and default settings. The
* chart object returned by this method uses a {@link CategoryPlot}
* instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
* a {@link NumberAxis3D} as the range axis, and a
* {@link StackedBarRenderer3D} as the renderer.
*
* @param title the chart title (<code>null</code> permitted).
* @param categoryAxisLabel the label for the category axis
* (<code>null</code> permitted).
* @param valueAxisLabel the label for the value axis (<code>null</code>
* permitted).
* @param dataset the dataset for the chart (<code>null</code> permitted).
* @param orientation the orientation (horizontal or vertical)
* (<code>null</code> not permitted).
* @param legend a flag specifying whether or not a legend is required.
* @param tooltips configure chart to generate tool tips?
* @param urls configure chart to generate URLs?
*
* @return A stacked bar chart with a 3D effect.
*/
public static JFreeChart createStackedBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {
ParamChecks.nullNotPermitted(orientation, "orientation");
CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
// create the renderer...
CategoryItemRenderer renderer = new StackedBarRenderer3D();
if (tooltips) {
renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
}
if (urls) {
renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
}
// create the plot...
CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
plot.setOrientation(orientation);
if (orientation == PlotOrientation.HORIZONTAL) {
// change rendering order to ensure that bar overlapping is the
// right way around
plot.setColumnRenderingOrder(SortOrder.DESCENDING);
}
// create the chart...
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
currentTheme.apply(chart);
return chart;
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class WaterfallChartTest method testSetSeriesToolTipGenerator.
/**
* Check that setting a tool tip generator for a series does override the
* default generator.
*/
@Test
public void testSetSeriesToolTipGenerator() {
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
renderer.setSeriesToolTipGenerator(0, tt);
CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
assertTrue(tt2 == tt);
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class WaterfallChartTest method testSetSeriesURLGenerator.
/**
* Check that setting a URL generator for a series does override the
* default generator.
*/
@Test
public void testSetSeriesURLGenerator() {
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
CategoryItemRenderer renderer = plot.getRenderer();
StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
renderer.setSeriesItemURLGenerator(0, url1);
CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
assertTrue(url2 == url1);
}
use of org.jfree.chart.renderer.category.CategoryItemRenderer in project SIMVA-SoS by SESoS.
the class CategoryPlot method clone.
/**
* Returns a clone of the plot.
*
* @return A clone.
*
* @throws CloneNotSupportedException if the cloning is not supported.
*/
@Override
public Object clone() throws CloneNotSupportedException {
CategoryPlot clone = (CategoryPlot) super.clone();
clone.domainAxes = CloneUtils.cloneMapValues(this.domainAxes);
for (CategoryAxis axis : clone.domainAxes.values()) {
if (axis != null) {
axis.setPlot(clone);
axis.addChangeListener(clone);
}
}
clone.rangeAxes = CloneUtils.cloneMapValues(this.rangeAxes);
for (ValueAxis axis : clone.rangeAxes.values()) {
if (axis != null) {
axis.setPlot(clone);
axis.addChangeListener(clone);
}
}
// AxisLocation is immutable, so we can just copy the maps
clone.domainAxisLocations = new HashMap<Integer, AxisLocation>(this.domainAxisLocations);
clone.rangeAxisLocations = new HashMap<Integer, AxisLocation>(this.rangeAxisLocations);
clone.datasets = new HashMap<Integer, CategoryDataset>(this.datasets);
for (CategoryDataset dataset : clone.datasets.values()) {
if (dataset != null) {
dataset.addChangeListener(clone);
}
}
clone.datasetToDomainAxesMap = new TreeMap();
clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap);
clone.datasetToRangeAxesMap = new TreeMap();
clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap);
clone.renderers = CloneUtils.cloneMapValues(this.renderers);
for (CategoryItemRenderer renderer : clone.renderers.values()) {
if (renderer != null) {
renderer.setPlot(clone);
renderer.addChangeListener(clone);
}
}
if (this.fixedDomainAxisSpace != null) {
clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedDomainAxisSpace);
}
if (this.fixedRangeAxisSpace != null) {
clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone(this.fixedRangeAxisSpace);
}
clone.annotations = (List) ObjectUtilities.deepClone(this.annotations);
clone.foregroundDomainMarkers = cloneMarkerMap(this.foregroundDomainMarkers);
clone.backgroundDomainMarkers = cloneMarkerMap(this.backgroundDomainMarkers);
clone.foregroundRangeMarkers = cloneMarkerMap(this.foregroundRangeMarkers);
clone.backgroundRangeMarkers = cloneMarkerMap(this.backgroundRangeMarkers);
if (this.fixedLegendItems != null) {
clone.fixedLegendItems = (LegendItemCollection) this.fixedLegendItems.clone();
}
return clone;
}
Aggregations