Java Code Examples for org.jfree.chart.LegendItem#setDataset()
The following examples show how to use
org.jfree.chart.LegendItem#setDataset() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpiderWebPlot.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * 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; }
Example 2
Source File: SpiderWebPlot.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Returns a collection of legend items for the spider web chart. * * @return The legend items (never <code>null</code>). */ 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; }
Example 3
Source File: Arja_002_s.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }
Example 4
Source File: Arja_00174_t.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }
Example 5
Source File: Cardumen_00139_t.java From coming with MIT License | 4 votes |
/** * Returns a legend item for a series. This default implementation will * return <code>null</code> if {@link #isSeriesVisible(int)} or * {@link #isSeriesVisibleInLegend(int)} returns <code>false</code>. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). * * @see #getLegendItems() */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = this.legendItemLabelGenerator.generateLabel(dataset, series); String description = label; String toolTipText = null; if (this.legendItemToolTipGenerator != null) { toolTipText = this.legendItemToolTipGenerator.generateLabel( dataset, series); } String urlText = null; if (this.legendItemURLGenerator != null) { urlText = this.legendItemURLGenerator.generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; }
Example 6
Source File: JGenProg2017_0044_s.java From coming with MIT License | 4 votes |
/** * Returns a legend item for a series. This default implementation will * return <code>null</code> if {@link #isSeriesVisible(int)} or * {@link #isSeriesVisibleInLegend(int)} returns <code>false</code>. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). * * @see #getLegendItems() */ public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = this.legendItemLabelGenerator.generateLabel(dataset, series); String description = label; String toolTipText = null; if (this.legendItemToolTipGenerator != null) { toolTipText = this.legendItemToolTipGenerator.generateLabel( dataset, series); } String urlText = null; if (this.legendItemURLGenerator != null) { urlText = this.legendItemURLGenerator.generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; }
Example 7
Source File: CategoryStepRenderer.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); 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); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; }
Example 8
Source File: Arja_0063_s.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }
Example 9
Source File: Arja_001_s.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }
Example 10
Source File: PiePlot.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items (never <code>null</code>). */ @Override public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset == null) { return result; } List keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number n = this.dataset.getValue(key); boolean include; if (n == null) { include = !this.ignoreNullValues; } else { double v = n.doubleValue(); if (v == 0.0) { include = !this.ignoreZeroValues; } else { include = v > 0.0; } } if (include) { String label = this.legendLabelGenerator.generateSectionLabel( this.dataset, key); if (label != null) { String description = label; String toolTipText = null; if (this.legendLabelToolTipGenerator != null) { toolTipText = this.legendLabelToolTipGenerator .generateSectionLabel(this.dataset, key); } String urlText = null; if (this.legendLabelURLGenerator != null) { urlText = this.legendLabelURLGenerator.generateURL( this.dataset, key, this.pieIndex); } Paint paint = lookupSectionPaint(key); Paint outlinePaint = lookupSectionOutlinePaint(key); Stroke outlineStroke = lookupSectionOutlineStroke(key); LegendItem item = new LegendItem(label, description, toolTipText, urlText, true, shape, true, paint, true, outlinePaint, outlineStroke, false, // line not visible new Line2D.Float(), new BasicStroke(), Color.black); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item); } section++; } else { section++; } } return result; }
Example 11
Source File: AbstractXYItemRenderer.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * 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; } String label = this.legendItemLabelGenerator.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); LegendItem item = new LegendItem(label, paint); item.setToolTipText(toolTipText); item.setURLText(urlText); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getSeriesKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); if (getTreatLegendShapeAsLine()) { item.setLineVisible(true); item.setLine(shape); item.setLinePaint(paint); item.setShapeVisible(false); } else { Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); item.setOutlinePaint(outlinePaint); item.setOutlineStroke(outlineStroke); } return item; }
Example 12
Source File: LineAndShapeRenderer.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); 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 fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); boolean lineVisible = getItemLineVisible(series, 0); boolean shapeVisible = getItemShapeVisible(series, 0); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeVisible, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; }
Example 13
Source File: LineAndShapeRenderer.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); 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 fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); boolean lineVisible = getItemLineVisible(series, 0); boolean shapeVisible = getItemShapeVisible(series, 0); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shapeVisible, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; }
Example 14
Source File: BoxAndWhiskerRenderer.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); 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); LegendItem 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.getRowKey(series)); result.setSeriesIndex(series); return result; }
Example 15
Source File: AreaRenderer.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ public LegendItem getLegendItem(int datasetIndex, int series) { // if there is no plot, there is no dataset to access... CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); 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 = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; }
Example 16
Source File: BoxAndWhiskerRenderer.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = cp.getDataset(datasetIndex); 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); LegendItem 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.getRowKey(series)); result.setSeriesIndex(series); return result; }
Example 17
Source File: Arja_002_t.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }
Example 18
Source File: ScatterRenderer.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item. */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot cp = getPlot(); if (cp == null) { return null; } if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { CategoryDataset dataset = cp.getDataset(datasetIndex); 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 fillPaint = (this.useFillPaint ? getItemFillPaint(series, 0) : paint); boolean shapeOutlineVisible = this.drawOutlines; Paint outlinePaint = (this.useOutlinePaint ? getItemOutlinePaint(series, 0) : paint); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem result = new LegendItem(label, description, toolTipText, urlText, true, shape, getItemShapeFilled(series, 0), fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, false, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), getItemStroke(series, 0), getItemPaint(series, 0)); result.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { result.setLabelPaint(labelPaint); } result.setDataset(dataset); result.setDatasetIndex(datasetIndex); result.setSeriesKey(dataset.getRowKey(series)); result.setSeriesIndex(series); return result; } return null; }
Example 19
Source File: AbstractCategoryItemRenderer.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Returns a legend item for a series. This default implementation will * return <code>null</code> if {@link #isSeriesVisible(int)} or * {@link #isSeriesVisibleInLegend(int)} returns <code>false</code>. * * @param datasetIndex the dataset index (zero-based). * @param series the series index (zero-based). * * @return The legend item (possibly <code>null</code>). * * @see #getLegendItems() */ @Override public LegendItem getLegendItem(int datasetIndex, int series) { CategoryPlot p = getPlot(); if (p == null) { return null; } // check that a legend item needs to be displayed... if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { return null; } CategoryDataset dataset = p.getDataset(datasetIndex); String label = this.legendItemLabelGenerator.generateLabel(dataset, series); String description = label; String toolTipText = null; if (this.legendItemToolTipGenerator != null) { toolTipText = this.legendItemToolTipGenerator.generateLabel( dataset, series); } String urlText = null; if (this.legendItemURLGenerator != null) { urlText = this.legendItemURLGenerator.generateLabel(dataset, series); } Shape shape = lookupLegendShape(series); Paint paint = lookupSeriesPaint(series); Paint outlinePaint = lookupSeriesOutlinePaint(series); Stroke outlineStroke = lookupSeriesOutlineStroke(series); LegendItem item = new LegendItem(label, description, toolTipText, urlText, shape, paint, outlineStroke, outlinePaint); item.setLabelFont(lookupLegendTextFont(series)); Paint labelPaint = lookupLegendTextPaint(series); if (labelPaint != null) { item.setLabelPaint(labelPaint); } item.setSeriesKey(dataset.getRowKey(series)); item.setSeriesIndex(series); item.setDataset(dataset); item.setDatasetIndex(datasetIndex); return item; }
Example 20
Source File: arja3_three_s.java From coming with MIT License | 4 votes |
/** * Returns a collection of legend items for the pie chart. * * @return The legend items. */ public LegendItemCollection getLegendItems() { LegendItemCollection result = new LegendItemCollection(); if (this.dataset != null) { 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) { int section = 0; Iterator iterator = keys.iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); String label = key.toString(); String description = label; Paint paint = (Paint) this.sectionPaints.get(key); LegendItem item = new LegendItem(label, description, null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, paint, Plot.DEFAULT_OUTLINE_STROKE, paint); item.setDataset(getDataset()); result.add(item); section++; } } if (this.limit > 0.0) { result.add(new LegendItem(this.aggregatedItemsKey.toString(), this.aggregatedItemsKey.toString(), null, null, Plot.DEFAULT_LEGEND_ITEM_CIRCLE, this.aggregatedItemsPaint, Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint)); } } return result; }