List of usage examples for org.jfree.data.xy XYSeriesCollection getSeriesCount
@Override public int getSeriesCount()
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private void updateDeletedData(int row0, int row1, int offset) { XYSeriesCollection series = getCategory(); for (int col = 0; col < series.getSeriesCount(); col++) { XYSeries xyseries = series.getSeries(col); for (int row = row1; row >= row0; row--) { xyseries.remove(row);/* ww w . ja v a2 s . c o m*/ } } }
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private void updateInsertData(int row0, int row1, int offset) { ChartModel model = this.model; XYSeriesCollection series = getCategory(); for (int col = 0; col < series.getSeriesCount(); col++) { XYSeries xyseries = series.getSeries(col); for (int row = row0; row <= row1; row++) { xyseries.add(row, model.getValueAt(row, col), false); }//from w w w .j a v a2 s .co m xyseries.fireSeriesChanged(); } }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.GpsScatterPlotUIComponent.java
/*********************************************************************************************** * Update the existing Chart referenced by the DAO, by applying the specified datasets. * No Channel selection or DatasetDomain adjustment is allowed, * so just re-apply the original dataset. * This Chart does not use secondary datasets (yet). * * @param dao/* www . j ava2s . com*/ * @param datasettype * @param primarydataset * @param secondarydatasets * @param displaylimit * @param domainstartpoint * @param domainendpoint * @param channelselector * @param debug */ public void updateChartForSelection(final ObservatoryInstrumentDAOInterface dao, final DatasetType datasettype, final XYDataset primarydataset, final List<XYDataset> secondarydatasets, final int displaylimit, final int domainstartpoint, final int domainendpoint, final ChannelSelectorUIComponentInterface channelselector, final boolean debug) { final String SOURCE = "GpsScatterPlotUIComponent.updateChartForSelection() "; LOGGER.debug(debug, SOURCE); if ((dao != null) && (dao.getChartUI() != null) && (dao.getChartUI().getChartPanel() != null) && (dao.getChartUI().getChartPanel().getChart() != null) && (dao.getChartUI().getChartPanel().getChart().getXYPlot() != null) && (datasettype != null) && (primarydataset != null)) { // Confirm the DatasetType if ((datasettype.getName().equals(DatasetType.XY.getName())) && (primarydataset instanceof XYSeriesCollection)) { final XYSeriesCollection collectionPrimary; // There should be a collection of <channelcount> XYSeries in the Primary Dataset collectionPrimary = (XYSeriesCollection) primarydataset; if ((collectionPrimary.getSeriesCount() > 0) && (collectionPrimary.getSeries() != null)) { LOGGER.debug(debug, SOURCE + "Update the data shown on existing Chart"); // No Channel selection or DatasetDomain adjustment is allowed, // so just re-apply the original dataset // This Chart does not use secondary datasets (yet) dao.getChartUI().getChartPanel().getChart().getXYPlot().setDataset(INDEX_DATA, collectionPrimary); updateCentroidCrosshairs(); } else { LOGGER.error(SOURCE + " The XYSeriesCollection does not have any XYSeries"); } } else { LOGGER.error(SOURCE + " The Dataset is of an invalid type"); } } else { LOGGER.debug(debug, SOURCE + " Unable to change the Chart - invalid parameters"); } }
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private void updateData0(int row0, int row1, int offset) { ChartModel model = this.model; XYSeriesCollection series = getCategory(); int col0 = 0; int col1 = series.getSeriesCount() - 1; for (int col = col0; col <= col1; col++) { XYSeries xyseries = series.getSeries(col); for (int row = row0; row <= row1; row++) { double value = model.getValueAt(row + offset, col); xyseries.updateByIndex(row, value); }/* w w w. j ava 2 s . c o m*/ } }
From source file:celeste.Celeste.java
public void generarGrafica(XYSeriesCollection coleccion, boolean shapes) { JFreeChart grafica;//from ww w .ja v a 2 s.c om grafica = ChartFactory.createXYLineChart("", "", "", coleccion, PlotOrientation.HORIZONTAL, true, true, false); // configuracion de la grafica XYPlot xyplot = (XYPlot) grafica.getPlot(); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); int n = coleccion.getSeriesCount(); for (int l = 1; l < n; l = l + 2) { xylineandshaperenderer.setSeriesShape(l, new Ellipse2D.Double(-3 + l, -3 + l, 15, 15)); xylineandshaperenderer.setSeriesShapesVisible(l, shapes); } //generacion ventana grafica ChartPanel Panel = new ChartPanel(grafica); JFrame Ventana = new JFrame("JFreeChart"); Ventana.getContentPane().add(Panel); Ventana.pack(); Ventana.setVisible(true); Ventana.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); }
From source file:umontreal.iro.lecuyer.charts.YListSeriesCollection.java
/** * Creates a new <TT>YListSeriesCollection</TT> instance with default * parameters and given data series. The matrix <TT>data</TT> represents a * set of plotting data. More specifically, each row of <TT>data</TT> * represents a <SPAN CLASS="MATH"><I>y</I></SPAN>-coordinates set. * Position in the vector will form the <SPAN CLASS="MATH"><I>x</I></SPAN>-coordinates. Indeed, for each serie * <SPAN CLASS="MATH"><I>i</I></SPAN>, the value <TT>data</TT><SPAN CLASS="MATH">[<I>i</I>][<I>j</I>]</SPAN> corresponds to the point * /* ww w .j av a 2s . c om*/ * <SPAN CLASS="MATH">(<I>j</I> + 1,<TT>data</TT>[<I>j</I>])</SPAN> on the chart. * However, only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> of <TT>data</TT> will * be considered for each series of points. * * @param data series of point sets. * * @param numPoints Number of points to plot * */ public YListSeriesCollection(double[][] data, int numPoints) { renderer = new XYLineAndShapeRenderer(true, false); seriesCollection = new XYSeriesCollection(); XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection; for (int i = 0; i < data.length; i++) { XYSeries serie = new XYSeries(" "); for (int j = 0; j < numPoints; j++) serie.add(j + 1, data[i][j]); tempSeriesCollection.addSeries(serie); } final int s = tempSeriesCollection.getSeriesCount(); // set default colors for (int i = 0; i < s; i++) { renderer.setSeriesPaint(i, getDefaultColor(i)); } // set default plot style plotStyle = new String[s]; marksType = new String[s]; dashPattern = new String[s]; for (int i = 0; i < s; i++) { marksType[i] = " "; plotStyle[i] = "smooth"; dashPattern[i] = "solid"; } }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * Some checks for the constructor.//from w w w.j a v a 2 s .co m */ @Test public void testConstructor() { XYSeriesCollection xysc = new XYSeriesCollection(); assertEquals(0, xysc.getSeriesCount()); assertEquals(1.0, xysc.getIntervalWidth(), EPSILON); assertEquals(0.5, xysc.getIntervalPositionFactor(), EPSILON); }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Some basic checks for the removeSeries() method. *///ww w .j a va2s.c om public void testRemoveSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); boolean pass = false; try { c.removeSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.removeSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:no.ntnu.mmfplanner.ui.graph.NpvChart.java
/** * Helper method for updateModel(). Adds a rolling npv line with self * funding and break even, as well as adding legend elements *//*from www . j a v a2 s . c om*/ private void addNpvLine(ProjectRoi projectRoi, String caption, Paint paint, XYSeriesCollection dataset, XYLineAndShapeRenderer renderer) { // adds the rolling npvseries and sets approperiate render properties XYSeries rollingNpv = new XYSeries(caption); rollingNpv.add(0.5, 0.0); for (int i = 0; i < projectRoi.rollingNpv.length; i++) { rollingNpv.add(i + 1.5, projectRoi.rollingNpv[i]); } int series = dataset.getSeriesCount(); dataset.addSeries(rollingNpv); renderer.setSeriesShapesVisible(series, false); renderer.setSeriesStroke(series, STROKE_LINE); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, true); // break even if (projectRoi.breakevenPeriod > 0) { XYSeries breakEven = new XYSeries("Break Even"); breakEven.add(projectRoi.breakevenRegression - 0.5, 0.0); series = dataset.getSeriesCount(); dataset.addSeries(breakEven); renderer.setSeriesLinesVisible(series, false); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, false); renderer.setSeriesShape(series, ShapeUtilities.createDiamond(3.5f)); } // selfFunding if (projectRoi.selfFundingPeriod > 1) { XYSeries selfFunding = new XYSeries("Self Funding"); double x = projectRoi.selfFundingPeriod - 0.5; double y = projectRoi.rollingNpv[projectRoi.selfFundingPeriod - 2]; selfFunding.add(x, y); series = dataset.getSeriesCount(); dataset.addSeries(selfFunding); renderer.setSeriesLinesVisible(series, false); renderer.setSeriesPaint(series, paint); renderer.setSeriesVisibleInLegend(series, false); renderer.setSeriesShape(series, ShapeUtilities.createUpTriangle(3.5f)); } }
From source file:org.jfree.data.xy.XYSeriesCollectionTest.java
/** * Some basic checks for the removeSeries() method. *///from www . j a v a 2s .c o m @Test public void testRemoveSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); c.removeSeries(0); assertEquals(0, c.getSeriesCount()); c.addSeries(s1); try { c.removeSeries(-1); fail("Should have thrown IndexOutOfBoundsException on negative key"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds.", e.getMessage()); } try { c.removeSeries(1); fail("Should have thrown IndexOutOfBoundsException on key out of range"); } catch (IllegalArgumentException e) { assertEquals("Series index out of bounds.", e.getMessage()); } }