List of usage examples for org.jfree.data.xy XYSeriesCollection getSeriesCount
@Override public int getSeriesCount()
From source file:umontreal.iro.lecuyer.charts.YListSeriesCollection.java
private void initYListSeries(boolean flag, double[]... data) { // if flag = true, h = 1; else h = 1/numPoints double h;/*from w w w . j a v a 2 s . c om*/ renderer = new XYLineAndShapeRenderer(true, false); seriesCollection = new XYSeriesCollection(); XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection; for (int i = 0; i < data.length; i++) { XYSeries serie = new XYSeries(" "); if (flag) h = 1; else h = 1.0 / data[i].length; for (int j = 0; j < data[i].length; j++) serie.add(h * (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"; } // dashPattern[s-1] = "dashed"; // for the line y = x }
From source file:carfuzzy.Operations.java
public JFreeChart setToChart(double input, double membership, XYSeries series, XYSeriesCollection collection, String x_axis) { // kurallari cizdirdikten sonra cizdir. series.add(input, membership);//from w w w . j a va2 s. c o m series.add(input, 0); series.add(0, membership); collection.addSeries(series); JFreeChart chart = XYGraph.drawChart(collection, x_axis, "Membership"); XYPlot plot = chart.getXYPlot(); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f)); renderer.setSeriesStroke(collection.getSeriesCount() - 1, new BasicStroke(3.5f)); plot.setRenderer(renderer); return chart; }
From source file:PlotsBuilding.PlotPanel.java
private JFreeChart fillCollection(ArrayList<PlotsData> plotscollection) { XYSeriesCollection col = new XYSeriesCollection(); ArrayList<Integer> seriesCount = new ArrayList<>(); int SeriesCount = 0; PlotsData plotdata = new PlotsData(); if (plotscollection.isEmpty()) { XYSeries series = new XYSeries("1. "); series.add(0, 0);//w w w .j a va2 s . c om plotdata.y1 = -10; plotdata.y2 = 10; col.addSeries(series); } for (int i = 0; i < plotscollection.size(); i++) { plotdata = (PlotsData) plotscollection.get(i); col = plotdata.createPlotdataset(i, col); seriesCount.add(col.getSeriesCount() - SeriesCount); SeriesCount = col.getSeriesCount(); } double y1 = plotdata.y1; double y2 = plotdata.y2; JFreeChart chart = createChart(col, seriesCount, y1, y2); return chart; }
From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java
private XYItemRenderer getShipmentRenderer(XYSeriesCollection shipments) { XYItemRenderer shipmentsRenderer = new XYLineAndShapeRenderer(true, false); // Shapes only for (int i = 0; i < shipments.getSeriesCount(); i++) { shipmentsRenderer.setSeriesPaint(i, Color.DARK_GRAY); shipmentsRenderer.setSeriesStroke(i, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.f, new float[] { 4.0f, 4.0f }, 0.0f)); }//from ww w . ja va 2 s . c om return shipmentsRenderer; }
From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java
private XYItemRenderer getRouteRenderer(XYSeriesCollection solutionColl) { XYItemRenderer solutionRenderer = new XYLineAndShapeRenderer(true, false); // Lines only for (int i = 0; i < solutionColl.getSeriesCount(); i++) { XYSeries s = solutionColl.getSeries(i); XYDataItem firstCustomer = s.getDataItem(1); firstActivities.add(firstCustomer); }/*from ww w.j a va2 s .co m*/ return solutionRenderer; }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Some basic checks for the addSeries() method. *//*w ww . ja va 2 s . co m*/ public void testAddSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); // the dataset should prevent the addition of a series with the // same name as an existing series in the dataset XYSeries s2 = new XYSeries("s1"); boolean pass = false; try { c.addSeries(s2); } catch (RuntimeException e) { pass = true; } assertTrue(pass); assertEquals(1, c.getSeriesCount()); }
From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java
/** * Adds data series into the series collection. The input format of * <TT>data</TT> is described in constructor * <TT>XYListSeriesCollection(double[][] data)</TT>. * Only <SPAN CLASS="textit">the first</SPAN> <TT>numPoints</TT> of <TT>data</TT> * (the first <TT>numPoints</TT> columns of the matrix) * will be added to each new series.//from w w w. j a va 2 s . co m * * @param data input data. * * @param numPoints Number of points to add for each new series * * @return Integer that represent the number of point sets added to the current dataset. * */ public int add(double[][] data, int numPoints) { XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection; int n = tempSeriesCollection.getSeriesCount(); if (data.length < 2) throw new IllegalArgumentException("Unable to render the plot. data contains less than two rows"); for (int j = 0; j < data.length; j++) if (data[j].length < numPoints) throw new IllegalArgumentException("data[" + j + "] has not enough points"); for (int j = 1; j < data.length; j++) { XYSeries serie = new XYSeries(" "); serie.setNotify(true); for (int k = 0; k < numPoints; k++) serie.add(data[0][k], data[j][k]); tempSeriesCollection.addSeries(serie); } // color for (int j = n; j < tempSeriesCollection.getSeriesCount(); j++) renderer.setSeriesPaint(j, getDefaultColor(j)); String[] newPlotStyle = new String[tempSeriesCollection.getSeriesCount()]; String[] newMarksType = new String[tempSeriesCollection.getSeriesCount()]; String[] newDashPattern = new String[tempSeriesCollection.getSeriesCount()]; for (int j = 0; j < n; j++) { newPlotStyle[j] = plotStyle[j]; newMarksType[j] = marksType[j]; newDashPattern[j] = dashPattern[j]; } for (int j = n; j < tempSeriesCollection.getSeriesCount(); j++) { newPlotStyle[j] = "smooth"; newMarksType[j] = " "; newDashPattern[j] = "solid"; } plotStyle = newPlotStyle; marksType = newMarksType; dashPattern = newDashPattern; return (tempSeriesCollection.getSeriesCount() - n); }
From source file:org.pentaho.plugin.jfreereport.reportcharts.XYChartExpression.java
protected TableXYDataset convertToTable(final XYSeriesCollection xyDataset) { final ExtCategoryTableXYDataset tableXYDataset = new ExtCategoryTableXYDataset(); final int count = xyDataset.getSeriesCount(); for (int i = 0; i < count; i++) { final XYSeries timeSeries = xyDataset.getSeries(i); final Comparable key = timeSeries.getKey(); final int itemCount = timeSeries.getItemCount(); for (int ic = 0; ic < itemCount; ic++) { final XYDataItem seriesDataItem = timeSeries.getDataItem(ic); tableXYDataset.add(seriesDataItem.getX(), seriesDataItem.getY(), key, false); }/*from www . j a v a 2 s . c om*/ } return tableXYDataset; }
From source file:umontreal.iro.lecuyer.charts.XYListSeriesCollection.java
/** * Creates a new <TT>XYListSeriesCollection</TT> instance with default parameters and given data series. * The input parameter represents a set of plotting data. * Each series of the given collection corresponds to a curve on the plot. * //from w w w. jav a 2 s . c om * @param data series of point sets. * */ public XYListSeriesCollection(XYSeriesCollection data) { renderer = new XYLineAndShapeRenderer(true, false); // ((XYLineAndShapeRenderer)renderer).setShapesVisible(false); seriesCollection = data; for (int i = 0; i < data.getSeriesCount(); i++) { XYSeries serie = data.getSeries(i); } // set default colors for (int i = 0; i < data.getSeriesCount(); i++) { renderer.setSeriesPaint(i, getDefaultColor(i)); } // set default plot style plotStyle = new String[data.getSeriesCount()]; marksType = new String[data.getSeriesCount()]; dashPattern = new String[data.getSeriesCount()]; for (int i = 0; i < data.getSeriesCount(); i++) { marksType[i] = " "; plotStyle[i] = "smooth"; dashPattern[i] = "solid"; } }
From source file:mt.LengthDistribution.java
public static void GetLengthDistributionArrayatTime(ArrayList<File> AllMovies, double[] calibration, final int framenumber) { ArrayList<Double> maxlist = new ArrayList<Double>(); for (int i = 0; i < AllMovies.size(); ++i) { ArrayList<Pair<Integer, Double>> lengthlist = LengthDistribution.LengthdistroatTime(AllMovies.get(i), framenumber);//w w w. jav a2 s . c om for (int index = 0; index < lengthlist.size(); ++index) { if (lengthlist.get(index).getB() != Double.NaN && lengthlist.get(index).getB() > 0) maxlist.add(lengthlist.get(index).getB()); } } Collections.sort(maxlist); int min = 0; int max = 0; if (maxlist.size() > 0) max = (int) Math.round(maxlist.get(maxlist.size() - 1)) + 1; XYSeries counterseries = new XYSeries("MT length distribution"); XYSeries Logcounterseries = new XYSeries("MT Log length distribution"); final ArrayList<Point> points = new ArrayList<Point>(); for (int length = 0; length < max; ++length) { HashMap<Integer, Integer> frameseed = new HashMap<Integer, Integer>(); int count = 0; for (int i = 0; i < AllMovies.size(); ++i) { File file = AllMovies.get(i); ArrayList<FLSobject> currentobject = Tracking.loadMTStat(file); if (currentobject != null) for (int index = 0; index < currentobject.size(); ++index) { ArrayList<Integer> seedlist = new ArrayList<Integer>(); if (currentobject.get(index).length >= length && currentobject.get(index).Framenumber == framenumber) { seedlist.add(currentobject.get(index).seedID); if (frameseed.get(currentobject.get(index).Framenumber) != null && frameseed.get(currentobject.get(index).Framenumber) != Double.NaN) { int currentcount = frameseed.get(currentobject.get(index).Framenumber); frameseed.put(currentobject.get(index).Framenumber, seedlist.size() + currentcount); } else if (currentobject.get(index) != null) frameseed.put(currentobject.get(index).Framenumber, seedlist.size()); } } } // Get maxima length, count int maxvalue = Integer.MIN_VALUE; for (int key : frameseed.keySet()) { int Count = frameseed.get(key); if (Count >= maxvalue) maxvalue = Count; } if (maxvalue != Integer.MIN_VALUE) { counterseries.add(length, maxvalue); if (maxvalue > 0) { System.out.println("Max " + maxvalue); Logcounterseries.add((length), Math.log(maxvalue)); points.add(new Point(new double[] { length, Math.log(maxvalue) })); } } } final XYSeriesCollection dataset = new XYSeriesCollection(); final XYSeriesCollection nofitdataset = new XYSeriesCollection(); dataset.addSeries(counterseries); nofitdataset.addSeries(counterseries); final XYSeriesCollection Logdataset = new XYSeriesCollection(); Logdataset.addSeries(Logcounterseries); final JFreeChart chart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", dataset); final JFreeChart nofitchart = ChartFactory.createScatterPlot("MT length distribution", "Number of MT", "Length (micrometer)", nofitdataset); // Fitting line to log of the length distribution interpolation.Polynomial poly = new interpolation.Polynomial(1); try { poly.fitFunction(points); } catch (NotEnoughDataPointsException e) { } DisplayPoints.display(nofitchart, new Dimension(800, 500)); dataset.addSeries(Tracking.drawexpFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Exponential fit")); NumberFormat nf = NumberFormat.getInstance(Locale.ENGLISH); nf.setMaximumFractionDigits(3); TextTitle legendText = new TextTitle("Mean Length" + " : " + nf.format(-1.0 / poly.getCoefficients(1)) + " " + "Standard Deviation" + " : " + nf.format(poly.SSE)); legendText.setPosition(RectangleEdge.RIGHT); DisplayPoints.display(chart, new Dimension(800, 500)); chart.addSubtitle(legendText); System.out.println("Series count" + dataset.getSeriesCount()); final JFreeChart logchart = ChartFactory.createScatterPlot("MT Log length distribution", "Length (micrometer)", "Number of MT", Logdataset); // DisplayPoints.display(logchart, new Dimension(800, 500)); for (int i = 1; i >= 0; --i) System.out.println(poly.getCoefficients(i) + " " + "x" + " X to the power of " + i); // Logdataset.addSeries(Tracking.drawFunction(poly, counterseries.getMinX(), counterseries.getMaxX(), 0.5, "Straight line fit")); WriteLengthdistroFile(AllMovies, counterseries, framenumber); }