List of usage examples for org.jfree.data.statistics HistogramBin getStartBoundary
public double getStartBoundary()
From source file:umontreal.iro.lecuyer.charts.HistogramChart.java
/** * Synchronizes <SPAN CLASS="MATH"><I>x</I></SPAN>-axis ticks to the <SPAN CLASS="MATH"><I>s</I></SPAN>-th histogram bins. * //from w w w.j a v a 2s.com * @param s selects histogram used to define ticks. * * */ public void setTicksSynchro(int s) { if (((CustomHistogramDataset) this.dataset.getSeriesCollection()).getBinWidth(s) == -1) { DoubleArrayList newTicks = new DoubleArrayList(); ListIterator binsIter = ((HistogramSeriesCollection) this.dataset).getBins(s).listIterator(); int i = 0; HistogramBin prec = (HistogramBin) binsIter.next(); double var; newTicks.add(prec.getStartBoundary()); newTicks.add(var = prec.getEndBoundary()); HistogramBin temp; while (binsIter.hasNext()) { temp = (HistogramBin) binsIter.next(); if (temp.getStartBoundary() != var) { newTicks.add(var = temp.getStartBoundary()); } else if (temp.getEndBoundary() != var) { newTicks.add(var = temp.getEndBoundary()); } } XAxis.setLabels(newTicks.elements()); } else { XAxis.setLabels(((CustomHistogramDataset) this.dataset.getSeriesCollection()).getBinWidth(s)); } }
From source file:org.jfree.data.statistics.HistogramDataset.java
/** * Returns the X value for a bin. This value won't be used for plotting * histograms, since the renderer will ignore it. But other renderers can * use it (for example, you could use the dataset to create a line * chart)./*from w w w . java 2s . c om*/ * * @param series the series index (in the range <code>0</code> to * <code>getSeriesCount() - 1</code>). * @param item the item index (zero based). * * @return The start value. * * @throws IndexOutOfBoundsException if <code>series</code> is outside the * specified range. */ @Override public Number getX(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.; return new Double(x); }
From source file:org.jfree.data.statistics.HistogramDataset.java
/** * Returns the start value for a bin./*from w w w . j a va2 s . c o m*/ * * @param series the series index (in the range <code>0</code> to * <code>getSeriesCount() - 1</code>). * @param item the item index (zero based). * * @return The start value. * * @throws IndexOutOfBoundsException if <code>series</code> is outside the * specified range. */ @Override public Number getStartX(int series, int item) { List bins = getBins(series); HistogramBin bin = (HistogramBin) bins.get(item); return new Double(bin.getStartBoundary()); }
From source file:adapters.HistogramChartAdapter.java
/** * Synchronizes <SPAN CLASS="MATH"><I>x</I></SPAN>-axis ticks to the <SPAN CLASS="MATH"><I>s</I></SPAN>-th histogram bins if the number * of bins is not larger than 10;/*from w ww . j av a2 s. c om*/ * otherwise, choose approximately 10 ticks. * * @param s selects histogram used to define ticks. * * */ public void setTicksSynchro(int s) { if (((CustomHistogramDataset) this.dataset.getSeriesCollection()).getBinWidth(s) == -1) { DoubleArrayList newTicks = new DoubleArrayList(); ListIterator binsIter = ((HistogramSeriesCollection) this.dataset).getBins(s).listIterator(); int i = 0; HistogramBin prec = (HistogramBin) binsIter.next(); double var; newTicks.add(prec.getStartBoundary()); newTicks.add(var = prec.getEndBoundary()); HistogramBin temp; while (binsIter.hasNext()) { temp = (HistogramBin) binsIter.next(); if (temp.getStartBoundary() != var) { newTicks.add(var = temp.getStartBoundary()); } else if (temp.getEndBoundary() != var) { newTicks.add(var = temp.getEndBoundary()); } } XAxis.setLabels(newTicks.elements()); } else { // set a label-tick for each bin, if num bins is <= 10 int n = ((HistogramSeriesCollection) this.dataset).getBins(s).size(); if (n > 10) { // number of bins is too large, set ~10 labels-ticks for histogram n = 10; double[] B = ((HistogramSeriesCollection) this.dataset).getDomainBounds(); double w = (B[1] - B[0]) / n; XAxis.setLabels(w); } else { XAxis.setLabels(((CustomHistogramDataset) this.dataset.getSeriesCollection()).getBinWidth(s)); } } }
From source file:umontreal.iro.lecuyer.charts.HistogramSeriesCollection.java
public String toLatex(double XScale, double YScale, double XShift, double YShift, double xmin, double xmax, double ymin, double ymax) { // Calcule les bornes reelles du graphique, en prenant en compte la position des axes xmin = Math.min(XShift, xmin); xmax = Math.max(XShift, xmax); ymin = Math.min(YShift, ymin); ymax = Math.max(YShift, ymax); CustomHistogramDataset tempSeriesCollection = (CustomHistogramDataset) seriesCollection; Formatter formatter = new Formatter(Locale.US); double var; double margin = ((XYBarRenderer) renderer).getMargin(); for (int i = tempSeriesCollection.getSeriesCount() - 1; i >= 0; i--) { List temp = tempSeriesCollection.getBins(i); ListIterator iter = temp.listIterator(); Color color = (Color) renderer.getSeriesPaint(i); String colorString = detectXColorClassic(color); if (colorString == null) { colorString = "color" + i; formatter.format("\\definecolor{%s}{rgb}{%.2f, %.2f, %.2f}%n", colorString, color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0); }//from w w w .j a v a2 s.c om HistogramBin currentBin = null; while (iter.hasNext()) { double currentMargin; currentBin = (HistogramBin) iter.next(); currentMargin = ((margin * (currentBin.getEndBoundary() - currentBin.getStartBoundary()))) * XScale; if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() <= ymax)) { var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (currentBin.getCount() - YShift) * YScale); } } else if ((currentBin.getStartBoundary() >= xmin && currentBin.getStartBoundary() <= xmax) && (currentBin.getCount() >= ymin && currentBin.getCount() > ymax)) { // Cas ou notre rectangle ne peut pas etre affiche en entier (trop haut) var = Math.min(currentBin.getEndBoundary(), xmax); if (filled[i]) { formatter.format( "\\filldraw [line width=%.2fpt, opacity=%.2f, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], (color.getAlpha() / 255.0), colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } else { formatter.format( "\\draw [line width=%.2fpt, color=%s] ([xshift=%.4f] %.4f, %.4f) rectangle ([xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, 0.0, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); formatter.format( "\\draw [line width=%.2fpt, color=%s, style=dotted] ([xshift=%.4f] %.4f, %.4f) rectangle ([yshift=3mm, xshift=-%.4f] %.4f, %.4f); %%%n", lineWidth[i], colorString, currentMargin, (currentBin.getStartBoundary() - XShift) * XScale, (ymax - YShift) * YScale, currentMargin, (var - XShift) * XScale, (ymax - YShift) * YScale); } } } } return formatter.toString(); }