Example #1
0
  /** Paint data series */
  protected void paintData(Graphics2D g2, Variate.N xData, Variate.N yData) {

    g2.setPaint(linePaint);
    g2.setStroke(lineStroke);

    if (getSelectedPoints() != null && getSelectedPoints().size() > 0) {
      for (int i : getSelectedPoints()) {

        double x = ((Number) xTipData.get(i)).doubleValue();
        double y = ((Number) yTipData.get(i)).doubleValue();

        double x1 = transformX(x);
        double y1 = transformY(y);

        double x2 = transformX(((Number) xData.get(0)).doubleValue());
        double y2 = transformY(((Number) yData.get(0)).doubleValue());

        GeneralPath path = new GeneralPath();
        path.moveTo((float) x1, (float) y1);
        //            path.lineTo((float) x2, (float) y1);
        path.lineTo((float) x2, (float) y2);

        g2.draw(path);
      }
    } else {
      for (int i = 0; i < xData.getCount(); i++) {

        double x1 = transformX(((Number) xTipData.get(i)).doubleValue());
        double y1 = transformY(((Number) yTipData.get(i)).doubleValue());

        double x2 = transformX(((Number) xData.get(i)).doubleValue());
        double y2 = transformY(((Number) yData.get(i)).doubleValue());

        GeneralPath path = new GeneralPath();
        path.moveTo((float) x1, (float) y1);
        //            path.lineTo((float) x2, (float) y1);
        path.lineTo((float) x2, (float) y2);

        g2.draw(path);
      }
    }
  }
Example #2
0
  /** Paint data series */
  protected void paintData(Graphics2D g2, Variate.N xData, Variate.N yData) {

    double x1, y1, x2, y2;
    double lower = 0.0, upper = 0.0;
    int n = xData.getCount();

    if (hasQuantiles) {
      lower = raw.getQuantile(quantiles);
      upper = raw.getQuantile(1.0 - quantiles);
    } else if (hasIntervals) {
      lower = lowerInterval;
      upper = upperInterval;
    }

    g2.setStroke(lineStroke);
    for (int i = 0; i < n; i += 2) {

      x1 = (Double) xData.get(i);
      y1 = (Double) yData.get(i);
      x2 = (Double) xData.get(i + 1);
      y2 = (Double) yData.get(i + 1);

      if (y1 != y2) {
        if (barPaint != null) {
          if (hasQuantiles || hasIntervals) {
            if (x1 < lower) {
              if (x2 <= lower) {
                g2.setPaint(quantilePaint);
                fillRect(g2, x1, y1, x2, y2);
              } else {
                g2.setPaint(quantilePaint);
                fillRect(g2, x1, y1, lower, y2);
                g2.setPaint(barPaint);
                fillRect(g2, lower, y1, x2, y2);
              }
            } else if (x2 > upper) {
              if (x1 >= upper) {
                g2.setPaint(quantilePaint);
                fillRect(g2, x1, y1, x2, y2);
              } else {
                g2.setPaint(barPaint);
                fillRect(g2, x1, y1, upper, y2);
                g2.setPaint(quantilePaint);
                fillRect(g2, upper, y1, x2, y2);
              }
            } else {
              g2.setPaint(barPaint);
              fillRect(g2, x1, y1, x2, y2);
            }
          } else if (hasIncredibleSet) {
            if (traceDistribution.inCredibleSetContains((int) x1)
                || traceDistribution.inCredibleSetContains((int) x2)) {
              g2.setPaint(quantilePaint);
            } else {
              g2.setPaint(barPaint);
            }
            fillRect(g2, x1, y1, x2, y2);
          } else {
            g2.setPaint(barPaint);
            fillRect(g2, x1, y1, x2, y2);
          }
        }

        if (lineStroke != null && linePaint != null) {
          g2.setStroke(lineStroke);
          g2.setPaint(linePaint);
          drawRect(g2, x1, y1, x2, y2);
        }
      }
    }
  }