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 = getSeriesShape(series);
                boolean shapeIsFilled = getItemShapeFilled(series, 0);
                Paint fillPaint = (this.useFillPaint 
                    ? getSeriesFillPaint(series) : getSeriesPaint(series));
                boolean shapeOutlineVisible = this.drawOutlines;  
                Paint outlinePaint = (this.useOutlinePaint 
                    ? getSeriesOutlinePaint(series) 
                    : getSeriesPaint(series));
                Stroke outlineStroke = getSeriesOutlineStroke(series);
                boolean lineVisible = getItemLineVisible(series, 0);
                Stroke lineStroke = getSeriesStroke(series);
                Paint linePaint = getSeriesPaint(series);
                result = new LegendItem(label, description, toolTipText, 
                        urlText, shapeIsVisible, shape, shapeIsFilled, 
                        fillPaint, shapeOutlineVisible, outlinePaint, 
                        outlineStroke, lineVisible, this.legendLine, 
                        lineStroke, linePaint);
                result.setSeriesIndex(series);
                result.setDatasetIndex(datasetIndex);
            }
        }

        return result;

    }