@Override
public LegendItemCollection getLegendItems() {
LegendItemCollection itemCollection = new LegendItemCollection();
final Placemark[] displayedPins = getDisplayedPins();
final List<DisplayableSpectrum> spectra = getSelectedSpectra();
for (Placemark pin : displayedPins) {
Paint pinPaint = PlacemarkUtils.getPlacemarkColor(pin, currentView);
spectra.stream().filter(DisplayableSpectrum::hasSelectedBands).forEach(spectrum -> {
String legendLabel = pin.getLabel() + "_" + spectrum.getName();
LegendItem item = createLegendItem(spectrum, pinPaint, legendLabel);
itemCollection.add(item);
});
}
if (isShowingCursorSpectrum() && showsValidCursorSpectra()) {
spectra.stream().filter(DisplayableSpectrum::hasSelectedBands).forEach(spectrum -> {
Paint defaultPaint = Color.BLACK;
LegendItem item = createLegendItem(spectrum, defaultPaint, spectrum.getName());
itemCollection.add(item);
});
}
return itemCollection;
}