Search in sources :

Example 11 with LegendItemCollection

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

the class CombinedDomainCategoryPlot method getLegendItems.

/**
 * Returns a collection of legend items for the plot.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    LegendItemCollection result = getFixedLegendItems();
    if (result == null) {
        result = new LegendItemCollection();
        if (this.subplots != null) {
            Iterator iterator = this.subplots.iterator();
            while (iterator.hasNext()) {
                CategoryPlot plot = (CategoryPlot) iterator.next();
                LegendItemCollection more = plot.getLegendItems();
                result.addAll(more);
            }
        }
    }
    return result;
}
Also used : LegendItemCollection(org.jfree.chart.LegendItemCollection) Iterator(java.util.Iterator)

Example 12 with LegendItemCollection

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

the class CombinedRangeCategoryPlot method getLegendItems.

/**
 * Returns a collection of legend items for the plot.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    LegendItemCollection result = getFixedLegendItems();
    if (result == null) {
        result = new LegendItemCollection();
        if (this.subplots != null) {
            Iterator iterator = this.subplots.iterator();
            while (iterator.hasNext()) {
                CategoryPlot plot = (CategoryPlot) iterator.next();
                LegendItemCollection more = plot.getLegendItems();
                result.addAll(more);
            }
        }
    }
    return result;
}
Also used : LegendItemCollection(org.jfree.chart.LegendItemCollection) Iterator(java.util.Iterator)

Example 13 with LegendItemCollection

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

the class SpiderWebPlot method getLegendItems.

/**
 * Returns a collection of legend items for the spider web chart.
 *
 * @return The legend items (never <code>null</code>).
 */
@Override
public LegendItemCollection getLegendItems() {
    LegendItemCollection result = new LegendItemCollection();
    if (getDataset() == null) {
        return result;
    }
    List keys = null;
    if (this.dataExtractOrder == TableOrder.BY_ROW) {
        keys = this.dataset.getRowKeys();
    } else if (this.dataExtractOrder == TableOrder.BY_COLUMN) {
        keys = this.dataset.getColumnKeys();
    }
    if (keys == null) {
        return result;
    }
    int series = 0;
    Iterator iterator = keys.iterator();
    Shape shape = getLegendItemShape();
    while (iterator.hasNext()) {
        Comparable key = (Comparable) iterator.next();
        String label = key.toString();
        String description = label;
        Paint paint = getSeriesPaint(series);
        Paint outlinePaint = getSeriesOutlinePaint(series);
        Stroke stroke = getSeriesOutlineStroke(series);
        LegendItem item = new LegendItem(label, description, null, null, shape, paint, stroke, outlinePaint);
        item.setDataset(getDataset());
        item.setSeriesKey(key);
        item.setSeriesIndex(series);
        result.add(item);
        series++;
    }
    return result;
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape) LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) Iterator(java.util.Iterator) List(java.util.List) StrokeList(org.jfree.util.StrokeList) PaintList(org.jfree.util.PaintList) Paint(java.awt.Paint) Paint(java.awt.Paint)

Example 14 with LegendItemCollection

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

the class XYPlot method getLegendItems.

/**
 * Returns the legend items for the plot.  Each legend item is generated by
 * the plot's renderer, since the renderer is responsible for the visual
 * representation of the data.
 *
 * @return The legend items.
 */
@Override
public LegendItemCollection getLegendItems() {
    if (this.fixedLegendItems != null) {
        return this.fixedLegendItems;
    }
    LegendItemCollection result = new LegendItemCollection();
    for (XYDataset dataset : this.datasets.values()) {
        if (dataset == null) {
            continue;
        }
        int datasetIndex = indexOf(dataset);
        XYItemRenderer renderer = getRenderer(datasetIndex);
        if (renderer == null) {
            renderer = getRenderer(0);
        }
        if (renderer != null) {
            int seriesCount = dataset.getSeriesCount();
            for (int i = 0; i < seriesCount; i++) {
                if (renderer.isSeriesVisible(i) && renderer.isSeriesVisibleInLegend(i)) {
                    LegendItem item = renderer.getLegendItem(datasetIndex, i);
                    if (item != null) {
                        result.add(item);
                    }
                }
            }
        }
    }
    return result;
}
Also used : LegendItem(org.jfree.chart.LegendItem) LegendItemCollection(org.jfree.chart.LegendItemCollection) XYDataset(org.jfree.data.xy.XYDataset) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) Paint(java.awt.Paint)

Example 15 with LegendItemCollection

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

the class WaferMapRenderer method getLegendCollection.

/**
 * Builds the list of legend entries.  called by getLegendItems in
 * WaferMapPlot to populate the plot legend.
 *
 * @return The legend items.
 */
public LegendItemCollection getLegendCollection() {
    LegendItemCollection result = new LegendItemCollection();
    if (this.paintIndex != null && this.paintIndex.size() > 0) {
        if (this.paintIndex.size() <= this.paintLimit) {
            for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext(); ) {
                // in this case, every color has a unique value
                Map.Entry entry = (Map.Entry) i.next();
                String label = entry.getKey().toString();
                String description = label;
                Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
                Paint paint = lookupSeriesPaint(((Integer) entry.getValue()).intValue());
                Paint outlinePaint = Color.black;
                Stroke outlineStroke = DEFAULT_STROKE;
                result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint));
            }
        } else {
            // in this case, every color has a range of values
            Set unique = new HashSet();
            for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext(); ) {
                Map.Entry entry = (Map.Entry) i.next();
                if (unique.add(entry.getValue())) {
                    String label = getMinPaintValue((Integer) entry.getValue()).toString() + " - " + getMaxPaintValue((Integer) entry.getValue()).toString();
                    String description = label;
                    Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d);
                    Paint paint = getSeriesPaint(((Integer) entry.getValue()).intValue());
                    Paint outlinePaint = Color.black;
                    Stroke outlineStroke = DEFAULT_STROKE;
                    result.add(new LegendItem(label, description, null, null, shape, paint, outlineStroke, outlinePaint));
                }
            }
        // end foreach map entry
        }
    // end else
    }
    return result;
}
Also used : Stroke(java.awt.Stroke) Shape(java.awt.Shape) Set(java.util.Set) HashSet(java.util.HashSet) LegendItemCollection(org.jfree.chart.LegendItemCollection) Paint(java.awt.Paint) LegendItem(org.jfree.chart.LegendItem) Iterator(java.util.Iterator) HashMap(java.util.HashMap) Map(java.util.Map) HashSet(java.util.HashSet)

Aggregations

LegendItemCollection (org.jfree.chart.LegendItemCollection)30 LegendItem (org.jfree.chart.LegendItem)19 Paint (java.awt.Paint)12 Test (org.junit.Test)12 Iterator (java.util.Iterator)9 BasicStroke (java.awt.BasicStroke)6 Stroke (java.awt.Stroke)6 GradientPaint (java.awt.GradientPaint)5 NumberAxis (org.jfree.chart.axis.NumberAxis)5 List (java.util.List)4 XYDataset (org.jfree.data.xy.XYDataset)4 Shape (java.awt.Shape)3 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)3 Color (java.awt.Color)2 Font (java.awt.Font)2 HashSet (java.util.HashSet)2 JFreeChart (org.jfree.chart.JFreeChart)2 DefaultPolarItemRenderer (org.jfree.chart.renderer.DefaultPolarItemRenderer)2 DefaultXYItemRenderer (org.jfree.chart.renderer.xy.DefaultXYItemRenderer)2 LegendTitle (org.jfree.chart.title.LegendTitle)2