/** Paint data series */ protected void paintData(Graphics2D g2, Variate.D xData, Variate.D yData) { double x1, y1, x2, y2, x; int n = xData.getCount(); g2.setStroke(lineStroke); for (int i = 0; i < n; i += 2) { x1 = xData.get(i); x2 = xData.get(i + 1); x = x2 - x1; if (barCount > 1) { x1 = x1 - ((double) (barCount - 1)) * x + 2.0 * ((double) barId) * x; x2 = x2 - ((double) (barCount - 1)) * x + 2.0 * ((double) barId) * x; } y1 = yData.get(i); y2 = yData.get(i + 1); if (y1 != y2) { if (linePaint != null) { Paint fillPaint = new Color( ((Color) linePaint).getRed(), ((Color) linePaint).getGreen(), ((Color) linePaint).getBlue(), 125); g2.setPaint(fillPaint); fillRect(g2, x1, y1, x2, y2); } if (lineStroke != null && linePaint != null) { g2.setStroke(lineStroke); g2.setPaint(linePaint); drawRect(g2, x1, y1, x2, y2); } } } }
/** Set data */ public void setData(Variate data, int minimumBinCount) { raw = data; FrequencyDistribution frequency = getFrequencyDistribution(data, minimumBinCount); Variate.D xData = new Variate.D(); Variate.D yData = new Variate.D(); double x = frequency.getLowerBound(); for (int i = 0; i < frequency.getBinCount(); i++) { xData.add(x); yData.add(0.0); x += frequency.getBinSize(); xData.add(x); yData.add(frequency.getProb(i)); } setData(xData, yData); }