Esempio n. 1
0
 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 (!(dataset is IntervalXYDataset) || !(dataset is TableXYDataset))
   {
     string str1 = new StringBuffer().append("dataset (type ").append(Object.instancehelper_getClass((object) dataset).getName()).append(") has wrong type:").toString();
     int num = 0;
     if (!(StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset != null ? StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset : (StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024IntervalXYDataset = StackedXYBarRenderer.class\u0024("org.jfree.data.xy.IntervalXYDataset"))).isAssignableFrom(Object.instancehelper_getClass((object) dataset)))
     {
       str1 = new StringBuffer().append(str1).append(" it is no IntervalXYDataset").toString();
       num = 1;
     }
     if (!(StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset != null ? StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset : (StackedXYBarRenderer.class\u0024org\u0024jfree\u0024data\u0024xy\u0024TableXYDataset = StackedXYBarRenderer.class\u0024("org.jfree.data.xy.TableXYDataset"))).isAssignableFrom(Object.instancehelper_getClass((object) dataset)))
     {
       if (num != 0)
         str1 = new StringBuffer().append(str1).append(" and").toString();
       str1 = new StringBuffer().append(str1).append(" it is no TableXYDataset").toString();
     }
     string str2 = str1;
     Throwable.__\u003CsuppressFillInStackTrace\u003E();
     throw new IllegalArgumentException(str2);
   }
   else
   {
     IntervalXYDataset ntervalXyDataset = (IntervalXYDataset) dataset;
     double yvalue1 = ntervalXyDataset.getYValue(series, item);
     if (Double.isNaN(yvalue1))
       return;
     double num1 = 0.0;
     if (this.renderAsPercentages)
     {
       num1 = DatasetUtilities.calculateStackTotal((TableXYDataset) dataset, item);
       yvalue1 /= num1;
     }
     double d1 = 0.0;
     double d2 = 0.0;
     for (int i1 = 0; i1 < series; ++i1)
     {
       double yvalue2 = dataset.getYValue(i1, item);
       if (!Double.isNaN(yvalue2))
       {
         if (this.renderAsPercentages)
           yvalue2 /= num1;
         if (yvalue2 > 0.0)
           d1 += yvalue2;
         else
           d2 += yvalue2;
       }
     }
     RectangleEdge rangeAxisEdge = plot.getRangeAxisEdge();
     double num2;
     double num3;
     if (yvalue1 > 0.0)
     {
       num2 = rangeAxis.valueToJava2D(d1, dataArea, rangeAxisEdge);
       num3 = rangeAxis.valueToJava2D(d1 + yvalue1, dataArea, rangeAxisEdge);
     }
     else
     {
       num2 = rangeAxis.valueToJava2D(d2, dataArea, rangeAxisEdge);
       num3 = rangeAxis.valueToJava2D(d2 + yvalue1, dataArea, rangeAxisEdge);
     }
     RectangleEdge domainAxisEdge = plot.getDomainAxisEdge();
     double startXvalue = ntervalXyDataset.getStartXValue(series, item);
     if (Double.isNaN(startXvalue))
       return;
     double num4 = domainAxis.valueToJava2D(startXvalue, dataArea, domainAxisEdge);
     double endXvalue = ntervalXyDataset.getEndXValue(series, item);
     if (Double.isNaN(endXvalue))
       return;
     double num5 = domainAxis.valueToJava2D(endXvalue, dataArea, domainAxisEdge);
     double num6 = Math.max(1.0, Math.abs(num5 - num4));
     double num7 = Math.abs(num3 - num2);
     if (this.getMargin() > 0.0)
     {
       double num8 = num6 * this.getMargin();
       num6 -= num8;
       num4 += num8 / 2.0;
     }
     Rectangle2D.Double @double = (Rectangle2D.Double) null;
     PlotOrientation orientation = plot.getOrientation();
     if (orientation == PlotOrientation.__\u003C\u003EHORIZONTAL)
       @double = new Rectangle2D.Double(Math.min(num2, num3), num5, num7, num6);
     else if (orientation == PlotOrientation.__\u003C\u003EVERTICAL)
       @double = new Rectangle2D.Double(num4, Math.min(num2, num3), num6, num7);
     int num9 = yvalue1 > 0.0 ? 1 : 0;
     int num10 = rangeAxis.isInverted() ? 1 : 0;
     RectangleEdge re = orientation != PlotOrientation.__\u003C\u003EHORIZONTAL ? (num9 != 0 && num10 == 0 || num9 == 0 && num10 != 0 ? RectangleEdge.__\u003C\u003EBOTTOM : RectangleEdge.__\u003C\u003ETOP) : (num9 != 0 && num10 != 0 || num9 == 0 && num10 == 0 ? RectangleEdge.__\u003C\u003ERIGHT : RectangleEdge.__\u003C\u003ELEFT);
     if (pass == 0)
     {
       if (!this.getShadowsVisible())
         return;
       this.getBarPainter().paintBarShadow(g2, (XYBarRenderer) this, series, item, (RectangularShape) @double, re, false);
     }
     else if (pass == 1)
     {
       this.getBarPainter().paintBar(g2, (XYBarRenderer) this, series, item, (RectangularShape) @double, re);
       if (info == null)
         return;
       EntityCollection entityCollection = info.getOwner().getEntityCollection();
       if (entityCollection == null)
         return;
       this.addEntity(entityCollection, (Shape) @double, dataset, series, item, ((RectangularShape) @double).getCenterX(), ((RectangularShape) @double).getCenterY());
     }
     else
     {
       if (pass != 2 || !this.isItemLabelVisible(series, item))
         return;
       XYItemLabelGenerator itemLabelGenerator = this.getItemLabelGenerator(series, item);
       this.drawItemLabel(g2, dataset, series, item, plot, itemLabelGenerator, (Rectangle2D) @double, yvalue1 < 0.0);
     }
   }
 }
 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);
 }
Esempio n. 5
0
 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;
   }
 }