use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.
the class MultiplePiePlot method getLegendItems.
/**
* Returns a collection of legend items for the pie chart.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.dataset == null) {
return result;
}
List keys = null;
prefetchSectionPaints();
if (this.dataExtractOrder == TableOrder.BY_ROW) {
keys = this.dataset.getColumnKeys();
} else if (this.dataExtractOrder == TableOrder.BY_COLUMN) {
keys = this.dataset.getRowKeys();
}
if (keys == null) {
return result;
}
int section = 0;
Iterator iterator = keys.iterator();
while (iterator.hasNext()) {
Comparable key = (Comparable) iterator.next();
// TODO: use a generator here
String label = key.toString();
String description = label;
Paint paint = (Paint) this.sectionPaints.get(key);
LegendItem item = new LegendItem(label, description, null, null, getLegendItemShape(), paint, Plot.DEFAULT_OUTLINE_STROKE, paint);
item.setSeriesKey(key);
item.setSeriesIndex(section);
item.setDataset(getDataset());
result.add(item);
section++;
}
if (this.limit > 0.0) {
LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, getLegendItemShape(), this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint);
result.add(a);
}
return result;
}
use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.
the class XYBubbleRenderer method getLegendItem.
/**
* Returns a legend item for the specified series. The default method
* is overridden so that the legend displays circles for all series.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return A legend item for the series.
*/
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
LegendItem result = null;
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset != null) {
if (getItemVisible(series, 0)) {
String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
}
Shape shape = lookupLegendShape(series);
Paint paint = lookupSeriesPaint(series);
Paint outlinePaint = lookupSeriesOutlinePaint(series);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint);
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
}
}
return result;
}
use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.
the class StandardXYItemRenderer method getLegendItem.
/**
* Returns a legend item for a series.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return A legend item for the series.
*/
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
LegendItem result = null;
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset != null) {
if (getItemVisible(series, 0)) {
String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
}
Shape shape = lookupLegendShape(series);
boolean shapeFilled = getItemShapeFilled(series, 0);
Paint paint = lookupSeriesPaint(series);
Paint linePaint = paint;
Stroke lineStroke = lookupSeriesStroke(series);
result = new LegendItem(label, description, toolTipText, urlText, this.baseShapesVisible, shape, shapeFilled, paint, !shapeFilled, paint, lineStroke, this.plotLines, this.legendLine, lineStroke, linePaint);
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
}
}
return result;
}
use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.
the class XYLineAndShapeRenderer method getLegendItem.
/**
* Returns a legend item for the specified series.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return A legend item for the series (possibly {@code null}).
*/
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot plot = getPlot();
if (plot == null) {
return null;
}
XYDataset dataset = plot.getDataset(datasetIndex);
if (dataset == null) {
return null;
}
if (!getItemVisible(series, 0)) {
return null;
}
String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
}
boolean shapeIsVisible = getItemShapeVisible(series, 0);
Shape shape = lookupLegendShape(series);
boolean shapeIsFilled = getItemShapeFilled(series, 0);
Paint fillPaint = (this.useFillPaint ? lookupSeriesFillPaint(series) : lookupSeriesPaint(series));
boolean shapeOutlineVisible = this.drawOutlines;
Paint outlinePaint = (this.useOutlinePaint ? lookupSeriesOutlinePaint(series) : lookupSeriesPaint(series));
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
boolean lineVisible = getItemLineVisible(series, 0);
Stroke lineStroke = lookupSeriesStroke(series);
Paint linePaint = lookupSeriesPaint(series);
LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeIsVisible, shape, shapeIsFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, this.legendLine, lineStroke, linePaint);
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
return result;
}
use of org.jfree.chart.LegendItem in project SIMVA-SoS by SESoS.
the class XYBarRenderer method getLegendItem.
/**
* Returns a default legend item for the specified series. Subclasses
* should override this method to generate customised items.
*
* @param datasetIndex the dataset index (zero-based).
* @param series the series index (zero-based).
*
* @return A legend item for the series.
*/
@Override
public LegendItem getLegendItem(int datasetIndex, int series) {
XYPlot xyplot = getPlot();
if (xyplot == null) {
return null;
}
XYDataset dataset = xyplot.getDataset(datasetIndex);
if (dataset == null) {
return null;
}
LegendItem result;
XYSeriesLabelGenerator lg = getLegendItemLabelGenerator();
String label = lg.generateLabel(dataset, series);
String description = label;
String toolTipText = null;
if (getLegendItemToolTipGenerator() != null) {
toolTipText = getLegendItemToolTipGenerator().generateLabel(dataset, series);
}
String urlText = null;
if (getLegendItemURLGenerator() != null) {
urlText = getLegendItemURLGenerator().generateLabel(dataset, series);
}
Shape shape = this.legendBar;
Paint paint = lookupSeriesPaint(series);
Paint outlinePaint = lookupSeriesOutlinePaint(series);
Stroke outlineStroke = lookupSeriesOutlineStroke(series);
if (this.drawBarOutline) {
result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint);
} else {
result = new LegendItem(label, description, toolTipText, urlText, shape, paint);
}
result.setLabelFont(lookupLegendTextFont(series));
Paint labelPaint = lookupLegendTextPaint(series);
if (labelPaint != null) {
result.setLabelPaint(labelPaint);
}
result.setDataset(dataset);
result.setDatasetIndex(datasetIndex);
result.setSeriesKey(dataset.getSeriesKey(series));
result.setSeriesIndex(series);
if (getGradientPaintTransformer() != null) {
result.setFillPaintTransformer(getGradientPaintTransformer());
}
return result;
}
Aggregations