use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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<S> 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;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class PolarPlot method getLegendItems.
/**
* Returns the legend items for the plot. Each legend item is generated by
* the plot's m_Renderer, since the m_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();
int count = this.datasets.size();
for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) {
XYDataset dataset = getDataset(datasetIndex);
PolarItemRenderer renderer = getRenderer(datasetIndex);
if (dataset != null && renderer != null) {
int seriesCount = dataset.getSeriesCount();
for (int i = 0; i < seriesCount; i++) {
LegendItem item = renderer.getLegendItem(i);
result.add(item);
}
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class AbstractCategoryItemRenderer method getLegendItems.
/**
* Returns a (possibly empty) collection of legend items for the series
* that this renderer is responsible for drawing.
*
* @return The legend item collection (never {@code null}).
*
* @see #getLegendItem(int, int)
*/
@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection result = new LegendItemCollection();
if (this.plot == null) {
return result;
}
int index = this.plot.getIndexOf(this);
CategoryDataset dataset = this.plot.getDataset(index);
if (dataset == null) {
return result;
}
int seriesCount = dataset.getRowCount();
if (plot.getRowRenderingOrder().equals(SortOrder.ASCENDING)) {
for (int i = 0; i < seriesCount; i++) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
} else {
for (int i = seriesCount - 1; i >= 0; i--) {
if (isSeriesVisibleInLegend(i)) {
LegendItem item = getLegendItem(index, i);
if (item != null) {
result.add(item);
}
}
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
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) {
for (CategoryPlot subplot : this.subplots) {
LegendItemCollection more = subplot.getLegendItems();
result.addAll(more);
}
}
}
return result;
}
use of org.jfree.chart.legend.LegendItemCollection in project ES-LEI-2Sem-2022-Grupo-1 by tmrbo-iscte.
the class CategoryPlot method getLegendItems.
/**
* Returns the legend items for the plot. By default, this method creates
* a legend item for each series in each of the datasets. You can change
* this behaviour by overriding this method.
*
* @return The legend items.
*/
@Override
public LegendItemCollection getLegendItems() {
if (this.fixedLegendItems != null) {
return this.fixedLegendItems;
}
LegendItemCollection result = new LegendItemCollection();
// get the legend items for the datasets...
for (CategoryDataset<R, C> dataset : this.datasets.values()) {
if (dataset != null) {
int datasetIndex = indexOf(dataset);
CategoryItemRenderer renderer = getRenderer(datasetIndex);
if (renderer != null) {
result.addAll(renderer.getLegendItems());
}
}
}
return result;
}
Aggregations