Пример #1
0
 private int DomainMin() {
   double smallest = Double.MAX_VALUE;
   for (Number d : dates) {
     if (d.doubleValue() < smallest) smallest = d.doubleValue();
   }
   return (int) (smallest / 86400);
 }
Пример #2
0
 private Double FindMaximum() {
   Double greatest = 0.0;
   for (Number d : weights) {
     if (d.doubleValue() > greatest) greatest = d.doubleValue();
   }
   Double bit = 1 - greatest % 1;
   return greatest + bit;
 }
Пример #3
0
 private Double FindMinimum() {
   Double smallest = 1000.0;
   for (Number d : weights) {
     if (d.doubleValue() < smallest.doubleValue()) smallest = d.doubleValue();
   }
   Double bit = smallest % 1;
   return smallest - bit;
 }
Пример #4
0
  private int DomainMax() {
    double greatest = 0.0;
    for (Number d : dates) {
      if (d.doubleValue() > greatest) greatest = d.doubleValue();
    }

    return (int) (greatest / 86400);
  }
  private void onPlotClicked(PointF point) {

    // make sure the point lies within the graph area.  we use gridrect
    // because it accounts for margins and padding as well.
    if (plot.containsPoint(point.x, point.y)) {
      Number x = plot.getXVal(point);
      Number y = plot.getYVal(point);

      selection = null;
      double xDistance = 0;
      double yDistance = 0;

      // find the closest value to the selection:
      for (SeriesBundle<XYSeries, ? extends XYSeriesFormatter> sfPair :
          plot.getRegistry().getSeriesAndFormatterList()) {
        XYSeries series = sfPair.getSeries();
        for (int i = 0; i < series.size(); i++) {
          Number thisX = series.getX(i);
          Number thisY = series.getY(i);
          if (thisX != null && thisY != null) {
            double thisXDistance = Region.measure(x, thisX).doubleValue();
            double thisYDistance = Region.measure(y, thisY).doubleValue();
            if (selection == null) {
              selection = new Pair<>(i, series);
              xDistance = thisXDistance;
              yDistance = thisYDistance;
            } else if (thisXDistance < xDistance) {
              selection = new Pair<>(i, series);
              xDistance = thisXDistance;
              yDistance = thisYDistance;
            } else if (thisXDistance == xDistance
                && thisYDistance < yDistance
                && thisY.doubleValue() >= y.doubleValue()) {
              selection = new Pair<>(i, series);
              xDistance = thisXDistance;
              yDistance = thisYDistance;
            }
          }
        }
      }

    } else {
      // if the press was outside the graph area, deselect:
      selection = null;
    }

    if (selection == null) {
      selectionWidget.setText(NO_SELECTION_TXT);
    } else {
      selectionWidget.setText(
          "Selected: "
              + selection.second.getTitle()
              + " Value: "
              + selection.second.getY(selection.first));
    }
    plot.redraw();
  }