/** * Add a value to a specific series of the chart. * * @param seriesname The series name. * @param valx The x value. * @param valy The y value. * @param data The data table. * @param row The current data row. */ protected void addValue( Comparable seriesname, Object valx, Object valy, DataTable data, Object[] row) { // Determine series number for adding the new data. int seriesnum = 0; VectorSeriesCollection dataset = (VectorSeriesCollection) ((XYPlot) getChart().getPlot()).getDataset(); int sercnt = dataset.getSeriesCount(); Integer sernum = (Integer) seriesmap.get(seriesname); if (sernum != null) seriesnum = sernum.intValue(); else seriesnum = sercnt; for (int j = sercnt; j <= seriesnum; j++) { Integer maxitemcnt = (Integer) getProperty("maxitemcount"); VectorSeries series; if (seriesname != null) { series = new VectorSeries(seriesname); if (maxitemcnt != null) series.setMaximumItemCount(maxitemcnt.intValue()); seriesmap.put(seriesname, new Integer(j)); } else { series = new VectorSeries(new Integer(j)); if (maxitemcnt != null) series.setMaximumItemCount(maxitemcnt.intValue()); seriesmap.put(new Integer(j), new Integer(j)); } dataset.addSeries(series); // System.out.println("Created series: "+seriesname+" "+j); } VectorSeries ser = dataset.getSeries(seriesnum); // Add the value. // System.out.println("Added: "+valx+" "+valy); ser.add(((Number) valx).doubleValue(), ((Number) valy).doubleValue(), 0, 0); }
/** * Removes all the series from the collection and sends a {@link DatasetChangeEvent} to all * registered listeners. */ public void removeAllSeries() { // deregister the collection as a change listener to each series in the // collection for (int i = 0; i < this.data.size(); i++) { VectorSeries series = (VectorSeries) this.data.get(i); series.removeChangeListener(this); } // remove all the series from the collection and notify listeners. this.data.clear(); fireDatasetChanged(); }
/** * Removes the specified series from the collection and sends a {@link DatasetChangeEvent} to all * registered listeners. * * @param series the series ({@code null} not permitted). * @return A boolean indicating whether the series has actually been removed. */ public boolean removeSeries(VectorSeries series) { ParamChecks.nullNotPermitted(series, "series"); boolean removed = this.data.remove(series); if (removed) { series.removeChangeListener(this); fireDatasetChanged(); } return removed; }
/** * Adds a series to the collection and sends a {@link DatasetChangeEvent} to all registered * listeners. * * @param series the series ({@code null} not permitted). */ public void addSeries(VectorSeries series) { ParamChecks.nullNotPermitted(series, "series"); this.data.add(series); series.addChangeListener(this); fireDatasetChanged(); }
/** * Returns the y-component of the vector for an item in a series. * * @param series the series index. * @param item the item index. * @return The y-component of the vector. */ @Override public double getVectorYValue(int series, int item) { VectorSeries s = (VectorSeries) this.data.get(series); VectorDataItem di = (VectorDataItem) s.getDataItem(item); return di.getVectorY(); }