Search in sources :

Example 1 with XYSeriesLabelGenerator

use of org.jfree.chart.labels.XYSeriesLabelGenerator in project SIMVA-SoS by SESoS.

the class XYAreaRenderer 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) {
    LegendItem result = null;
    XYPlot xyplot = getPlot();
    if (xyplot != null) {
        XYDataset dataset = xyplot.getDataset(datasetIndex);
        if (dataset != null) {
            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);
            }
            Paint paint = lookupSeriesPaint(series);
            result = new LegendItem(label, description, toolTipText, urlText, this.legendArea, 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);
        }
    }
    return result;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) XYDataset(org.jfree.data.xy.XYDataset) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint) XYSeriesLabelGenerator(org.jfree.chart.labels.XYSeriesLabelGenerator)

Example 2 with XYSeriesLabelGenerator

use of org.jfree.chart.labels.XYSeriesLabelGenerator in project SIMVA-SoS by SESoS.

the class XYAreaRenderer2 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) {
    LegendItem result = null;
    XYPlot xyplot = getPlot();
    if (xyplot != null) {
        XYDataset dataset = xyplot.getDataset(datasetIndex);
        if (dataset != null) {
            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);
            }
            Paint paint = lookupSeriesPaint(series);
            result = new LegendItem(label, description, toolTipText, urlText, this.legendArea, 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);
        }
    }
    return result;
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) XYDataset(org.jfree.data.xy.XYDataset) Paint(java.awt.Paint) XYSeriesLabelGenerator(org.jfree.chart.labels.XYSeriesLabelGenerator)

Example 3 with XYSeriesLabelGenerator

use of org.jfree.chart.labels.XYSeriesLabelGenerator 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;
}
Also used : Stroke(java.awt.Stroke) Shape(java.awt.Shape) XYPlot(org.jfree.chart.plot.XYPlot) LegendItem(org.jfree.chart.LegendItem) IntervalXYDataset(org.jfree.data.xy.IntervalXYDataset) XYDataset(org.jfree.data.xy.XYDataset) Paint(java.awt.Paint) XYSeriesLabelGenerator(org.jfree.chart.labels.XYSeriesLabelGenerator)

Aggregations

Paint (java.awt.Paint)3 LegendItem (org.jfree.chart.LegendItem)3 XYSeriesLabelGenerator (org.jfree.chart.labels.XYSeriesLabelGenerator)3 XYPlot (org.jfree.chart.plot.XYPlot)3 XYDataset (org.jfree.data.xy.XYDataset)3 GradientPaint (java.awt.GradientPaint)1 Shape (java.awt.Shape)1 Stroke (java.awt.Stroke)1 IntervalXYDataset (org.jfree.data.xy.IntervalXYDataset)1