Example usage for org.jfree.chart LegendItem setSeriesIndex

List of usage examples for org.jfree.chart LegendItem setSeriesIndex

Introduction

In this page you can find the example usage for org.jfree.chart LegendItem setSeriesIndex.

Prototype

public void setSeriesIndex(int index) 

Source Link

Document

Sets the series index for this legend item.

Usage

From source file:msi.gama.outputs.layers.charts.StandardXYItemRenderer.java

/**
 * Returns a legend item for a series.//from w  w  w  .j  av  a2  s  . com
 *
 * @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(final int datasetIndex, final int series) {
    final XYPlot plot = getPlot();
    if (plot == null) {
        return null;
    }
    LegendItem result = null;
    final XYDataset dataset = plot.getDataset(datasetIndex);
    if (dataset != null) {
        if (getItemVisible(series, 0)) {
            final String label = getLegendItemLabelGenerator().generateLabel(dataset, series);
            final 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);
            }
            final Shape shape = lookupLegendShape(series);
            final boolean shapeFilled = getItemShapeFilled(series, 0);
            final Paint paint = lookupSeriesPaint(series);
            final Paint linePaint = paint;
            final 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));
            final 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;
}

From source file:edu.dlnu.liuwenpeng.render.XYLineAndShapeRenderer.java

/**    
 * Returns a legend item for the specified series.    
 *    //ww w  . j a v  a2  s.  co m
 * @param datasetIndex  the dataset index (zero-based).    
 * @param series  the series index (zero-based).    
 *    
 * @return A legend item for the series.    
 */
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);
            }
            boolean shapeIsVisible = getItemShapeVisible(series, 0);
            Shape shape = lookupSeriesShape(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);
            result = new LegendItem(label, description, toolTipText, urlText, shapeIsVisible, shape,
                    shapeIsFilled, fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible,
                    this.legendLine, lineStroke, linePaint);
            result.setSeriesKey(dataset.getSeriesKey(series));
            result.setSeriesIndex(series);
            result.setDataset(dataset);
            result.setDatasetIndex(datasetIndex);
        }
    }

    return result;

}