use of org.xwiki.chart.PlotGeneratorException in project xwiki-platform by xwiki.
the class AbstractXYPlotGenerator method generate.
@Override
public Plot generate(ChartModel model, Map<String, String> parameters) throws PlotGeneratorException {
XYDataset dataset;
ValueAxis domainAxis;
ValueAxis rangeAxis;
if (model.getDataset() instanceof XYDataset) {
dataset = (XYDataset) model.getDataset();
} else {
throw new PlotGeneratorException("Incompatible dataset for xy plot.");
}
if (model.getAxis(0) instanceof ValueAxis) {
domainAxis = (ValueAxis) model.getAxis(0);
} else {
throw new PlotGeneratorException("Incompatible axis 0 for xy plot.");
}
if (model.getAxis(1) instanceof ValueAxis) {
rangeAxis = (ValueAxis) model.getAxis(1);
} else {
throw new PlotGeneratorException("Incompatible axis 1 for xy plot.");
}
return new XYPlot(dataset, domainAxis, rangeAxis, getRenderer(parameters));
}
use of org.xwiki.chart.PlotGeneratorException in project xwiki-platform by xwiki.
the class PiePlotGenerator method generate.
@Override
public Plot generate(ChartModel model, Map<String, String> parameters) throws PlotGeneratorException {
PieDataset dataset;
try {
dataset = (PieDataset) model.getDataset();
} catch (ClassCastException e) {
throw new PlotGeneratorException("Incompatible dataset for the pie plot.");
}
PiePlot piePlot = new PiePlot(dataset);
// Allow customizing the label to use
String pieLabelFormat = parameters.get(PIE_LABEL_FORMAT_KEY);
if (pieLabelFormat != null) {
piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(pieLabelFormat, NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
}
return piePlot;
}
use of org.xwiki.chart.PlotGeneratorException in project xwiki-platform by xwiki.
the class AbstractCategoryPlotGenerator method generate.
@Override
public Plot generate(ChartModel model, Map<String, String> parameters) throws PlotGeneratorException {
CategoryDataset dataset;
CategoryAxis domainAxis;
ValueAxis rangeAxis;
if (model.getDataset() instanceof CategoryDataset) {
dataset = (CategoryDataset) model.getDataset();
} else {
throw new PlotGeneratorException("Incompatible dataset for category plot.");
}
if (model.getAxis(0) instanceof CategoryAxis) {
domainAxis = (CategoryAxis) model.getAxis(0);
} else {
throw new PlotGeneratorException("Incompatible axis 0 for category plot.");
}
if (model.getAxis(1) instanceof ValueAxis) {
rangeAxis = (ValueAxis) model.getAxis(1);
} else {
throw new PlotGeneratorException("Incompatible axis 1 for category plot.");
}
return new CategoryPlot(dataset, domainAxis, rangeAxis, getRenderer(parameters));
}
Aggregations