public static double[] getOLSRegression(XYDataset data, int series) { int itemCount = data.getItemCount(series); if (itemCount < 2) { string str = "Not enough data."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { double num1 = 0.0; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; for (int i2 = 0; i2 < itemCount; ++i2) { double xvalue = data.getXValue(series, i2); double yvalue = data.getYValue(series, i2); num1 += xvalue; num2 += yvalue; double num5 = xvalue * xvalue; num3 += num5; double num6 = xvalue * yvalue; num4 += num6; } double num7 = num3 - num1 * num1 / (double) itemCount; double num8 = num4 - num1 * num2 / (double) itemCount; double num9 = num1 / (double) itemCount; double num10 = num2 / (double) itemCount; double[] numArray = new double[2] { 0.0, num8 / num7 }; numArray[0] = num10 - numArray[1] * num9; return numArray; } }
protected internal override void drawPrimaryLineAsPath(XYItemRendererState state, Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, Rectangle2D dataArea) { RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double xvalue = dataset.getXValue(series, item); double yvalue = dataset.getYValue(series, item); double num1 = domainAxis.valueToJava2D(xvalue, dataArea, domainAxisEdge); double num2 = rangeAxis.valueToJava2D(yvalue, dataArea, rangeAxisEdge); if (!Double.isNaN(num1) && !Double.isNaN(num2)) { XYSplineRenderer.ControlPoint controlPoint = new XYSplineRenderer.ControlPoint(this, plot.getOrientation() != PlotOrientation.__\u003C\u003EHORIZONTAL ? (float) num1 : (float) num2, plot.getOrientation() != PlotOrientation.__\u003C\u003EHORIZONTAL ? (float) num2 : (float) num1); if (!this.points.contains((object) controlPoint)) this.points.add((object) controlPoint); } if (item != dataset.getItemCount(series) - 1) return; XYLineAndShapeRenderer.State state1 = (XYLineAndShapeRenderer.State) state; if (this.points.size() > 1) { XYSplineRenderer.ControlPoint controlPoint1 = (XYSplineRenderer.ControlPoint) this.points.get(0); ((Path2D.Float) state1.seriesPath).moveTo(controlPoint1.x, controlPoint1.y); if (this.points.size() == 2) { XYSplineRenderer.ControlPoint controlPoint2 = (XYSplineRenderer.ControlPoint) this.points.get(1); ((Path2D.Float) state1.seriesPath).lineTo(controlPoint2.x, controlPoint2.y); } else { int length = this.points.size(); float[] numArray1 = new float[length]; float[] numArray2 = new float[length]; float[] numArray3 = new float[length]; float[] numArray4 = new float[length]; for (int index = 0; index < length; ++index) { XYSplineRenderer.ControlPoint controlPoint2 = (XYSplineRenderer.ControlPoint) this.points.get(index); numArray2[index] = controlPoint2.x; numArray1[index] = controlPoint2.y; } for (int index = 1; index <= length - 1; ++index) numArray4[index] = numArray2[index] - numArray2[index - 1]; float[] numArray5 = new float[length - 1]; float[] numArray6 = new float[length - 1]; float[] numArray7 = new float[length - 1]; for (int index = 1; index <= length - 2; ++index) { numArray6[index] = (numArray4[index] + numArray4[index + 1]) / 3f; numArray7[index] = numArray4[index + 1] / 6f; numArray5[index] = numArray4[index] / 6f; numArray3[index] = (numArray1[index + 1] - numArray1[index]) / numArray4[index + 1] - (numArray1[index] - numArray1[index - 1]) / numArray4[index]; } this.solveTridiag(numArray5, numArray6, numArray7, numArray3, length - 2); float num3 = numArray2[0]; float num4 = numArray1[0]; ((Path2D.Float) state1.seriesPath).moveTo(num3, num4); for (int index1 = 1; index1 <= length - 1; ++index1) { for (int index2 = 1; index2 <= this.precision; ++index2) { float num5 = numArray4[index1] * (float) index2 / (float) this.precision; float num6 = numArray4[index1] - num5; float num7 = (((float) (-(double) numArray3[index1 - 1] / 6.0) * (num6 + numArray4[index1]) * num5 + numArray1[index1 - 1]) * num6 + ((float) (-(double) numArray3[index1] / 6.0) * (num5 + numArray4[index1]) * num6 + numArray1[index1]) * num5) / numArray4[index1]; float num8 = numArray2[index1 - 1] + num5; ((Path2D.Float) state1.seriesPath).lineTo(num8, num7); } } } this.drawFirstPassShape(g2, pass, series, item, (Shape) state1.seriesPath); } this.points = new Vector(); }
public override void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { if (!this.getItemVisible(series, item)) return; if (pass == 0) { IntervalXYDataset ntervalXyDataset = (IntervalXYDataset) dataset; DeviationRenderer.State state1 = (DeviationRenderer.State) state; double xvalue = ntervalXyDataset.getXValue(series, item); double startYvalue = ntervalXyDataset.getStartYValue(series, item); double endYvalue = ntervalXyDataset.getEndYValue(series, item); RectangleEdge domainAxisEdge = plot.getDomainAxisEdge(); RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge(); double num1 = domainAxis.valueToJava2D(xvalue, dataArea, domainAxisEdge); double num2 = rangeAxis.valueToJava2D(startYvalue, dataArea, rangeAxisEdge); double num3 = rangeAxis.valueToJava2D(endYvalue, dataArea, rangeAxisEdge); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num2; numArray1[index1] = num4; int index2 = 1; double num5 = num1; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num3; numArray2[index3] = num6; int index4 = 1; double num7 = num1; numArray2[index4] = num7; list2.add((object) numArray2); } else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL) { List list1 = state1.lowerCoordinates; double[] numArray1 = new double[2]; int index1 = 0; double num4 = num1; numArray1[index1] = num4; int index2 = 1; double num5 = num2; numArray1[index2] = num5; list1.add((object) numArray1); List list2 = state1.upperCoordinates; double[] numArray2 = new double[2]; int index3 = 0; double num6 = num1; numArray2[index3] = num6; int index4 = 1; double num7 = num3; numArray2[index4] = num7; list2.add((object) numArray2); } if (item == dataset.getItemCount(series) - 1) { Composite composite = g2.getComposite(); g2.setComposite((Composite) AlphaComposite.getInstance(3, this.alpha)); g2.setPaint(this.getItemFillPaint(series, item)); GeneralPath generalPath = new GeneralPath(); double[] numArray1 = (double[]) state1.lowerCoordinates.get(0); ((Path2D.Float) generalPath).moveTo((float) numArray1[0], (float) numArray1[1]); for (int index = 1; index < state1.lowerCoordinates.size(); ++index) { double[] numArray2 = (double[]) state1.lowerCoordinates.get(index); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); } int num4 = state1.upperCoordinates.size(); double[] numArray3 = (double[]) state1.upperCoordinates.get(num4 - 1); ((Path2D.Float) generalPath).lineTo((float) numArray3[0], (float) numArray3[1]); int num5 = num4 - 2; while (num5 >= 0) { double[] numArray2 = (double[]) state1.upperCoordinates.get(num5); ((Path2D.Float) generalPath).lineTo((float) numArray2[0], (float) numArray2[1]); num5 += -1; } ((Path2D) generalPath).closePath(); g2.fill((Shape) generalPath); g2.setComposite(composite); state1.lowerCoordinates.clear(); state1.upperCoordinates.clear(); } } if (this.isLinePass(pass)) { if (item == 0) { DeviationRenderer.State state1 = (DeviationRenderer.State) state; ((Path2D) state1.seriesPath).reset(); state1.setLastPointGood(false); } if (!this.getItemLineVisible(series, item)) return; this.drawPrimaryLineAsPath(state, g2, plot, dataset, pass, series, item, domainAxis, rangeAxis, dataArea); } else { if (!this.isItemPass(pass)) return; EntityCollection entities = (EntityCollection) null; if (info != null) entities = info.getOwner().getEntityCollection(); this.drawSecondaryPass(g2, plot, dataset, pass, series, item, domainAxis, dataArea, rangeAxis, crosshairState, entities); } }
public virtual void drawSeries(Graphics2D g2, Rectangle2D dataArea, PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, int seriesIndex) { Polygon polygon = new Polygon(); int itemCount = dataset.getItemCount(seriesIndex); for (int i2 = 0; i2 < itemCount; ++i2) { double xvalue = dataset.getXValue(seriesIndex, i2); double yvalue = dataset.getYValue(seriesIndex, i2); Point point = plot.translateValueThetaRadiusToJava2D(xvalue, yvalue, dataArea); polygon.addPoint((int) point.x, (int) point.y); } g2.setPaint(this.lookupSeriesPaint(seriesIndex)); g2.setStroke(this.lookupSeriesStroke(seriesIndex)); if (this.isSeriesFilled(seriesIndex)) { Composite composite = g2.getComposite(); g2.setComposite((Composite) AlphaComposite.getInstance(3, 0.5f)); g2.fill((Shape) polygon); g2.setComposite(composite); } else g2.draw((Shape) polygon); }
public static XYSeries createMovingAverage(XYDataset source, int series, string name, double period, double skip) { if (source == null) { string str = "Null source (XYDataset)."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else if (period < 4.94065645841247E-324) { string str = "period must be positive."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else if (skip < 0.0) { string str = "skip must be >= 0.0."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { XYSeries xySeries = new XYSeries((IComparable) name); if (source.getItemCount(series) > 0) { double num1 = source.getXValue(series, 0) + skip; int i2 = source.getItemCount(series) - 1; while (i2 >= 0) { double xvalue1 = source.getXValue(series, i2); if (xvalue1 >= num1) { int num2 = 0; double num3 = 0.0; double num4 = xvalue1 - period; int num5 = 0; int num6 = 0; while (num6 == 0) { if (i2 - num5 >= 0) { double xvalue2 = source.getXValue(series, i2 - num5); Number y = source.getY(series, i2 - num5); if (xvalue2 > num4) { if (y != null) { num3 += y.doubleValue(); ++num2; } } else num6 = 1; } else num6 = 1; ++num5; } if (num2 > 0) xySeries.add(xvalue1, num3 / (double) num2); else xySeries.add(xvalue1, (Number) null); } i2 += -1; } } return xySeries; } }
public static double[] getPowerRegression(XYDataset data, int series) { int itemCount = data.getItemCount(series); if (itemCount < 2) { string str = "Not enough data."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { double num1 = 0.0; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; for (int i2 = 0; i2 < itemCount; ++i2) { double num5 = Math.log(data.getXValue(series, i2)); double num6 = Math.log(data.getYValue(series, i2)); num1 += num5; num2 += num6; double num7 = num5 * num5; num3 += num7; double num8 = num5 * num6; num4 += num8; } double num9 = num3 - num1 * num1 / (double) itemCount; double num10 = num4 - num1 * num2 / (double) itemCount; double num11 = num1 / (double) itemCount; double num12 = num2 / (double) itemCount; double[] numArray = new double[2] { 0.0, num10 / num9 }; numArray[0] = Math.pow(Math.exp(1.0), num12 - numArray[1] * num11); return numArray; } }
public static int findLiveItemsLowerBound(XYDataset dataset, int series, double xLow, double xHigh) { if (dataset == null) { string str = "Null 'dataset' argument."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else if (xLow >= xHigh) { string str = "Requires xLow < xHigh."; Throwable.__\u003CsuppressFillInStackTrace\u003E(); throw new IllegalArgumentException(str); } else { int itemCount = dataset.getItemCount(series); if (itemCount <= 1) return 0; if (dataset.getDomainOrder() == DomainOrder.__\u003C\u003EASCENDING) { int i2_1 = 0; int i2_2 = itemCount - 1; if (dataset.getXValue(series, i2_1) >= xLow) return i2_1; if (dataset.getXValue(series, i2_2) < xLow) return i2_2; while (i2_2 - i2_1 > 1) { int i2_3 = (i2_1 + i2_2) / 2; if (dataset.getXValue(series, i2_3) >= xLow) i2_2 = i2_3; else i2_1 = i2_3; } return i2_2; } else if (dataset.getDomainOrder() == DomainOrder.__\u003C\u003EDESCENDING) { int i2_1 = 0; int i2_2 = itemCount - 1; if (dataset.getXValue(series, i2_1) <= xHigh) return i2_1; if (dataset.getXValue(series, i2_2) > xHigh) return i2_2; while (i2_2 - i2_1 > 1) { int i2_3 = (i2_1 + i2_2) / 2; if (dataset.getXValue(series, i2_3) > xHigh) i2_1 = i2_3; else i2_2 = i2_3; int num = (i2_1 + i2_2) / 2; } return i2_2; } else { int i2 = 0; double xvalue = dataset.getXValue(series, i2); while (i2 < itemCount && (xvalue < xLow || xvalue > xHigh)) { ++i2; if (i2 < itemCount) xvalue = dataset.getXValue(series, i2); } return Math.min(Math.max(0, i2), itemCount - 1); } } }