/** * Copies our dataset and includes only species marked as visible in the legend. * * @param oLegend Legend for this chart. * @return The copied dataset. * @throws ModelException Passing through an underlying exception. */ protected ModelHistogramDataset updateForVisible(Legend oLegend) throws ModelException { ModelHistogramDataset oNewDataset = (ModelHistogramDataset) m_oDataset.clone(); String sName; int i; for (i = 0; i < oNewDataset.getSeriesCount(); i++) { sName = (String) oNewDataset.getSeriesKey(i); if (sName.equalsIgnoreCase("total") == false) { // If it's enabled, add the series to the copy if (!oLegend.getIsSpeciesSelected(m_oManager.getSpeciesCodeFromName(sName))) { oNewDataset.removeSeries(i); i--; } } } return oNewDataset; }