public String itemWithHighestPeak() {
   String result = "";
   double max = data.getSeries(0).getDataItem(0).getY().doubleValue();
   for (int i = 0; i < data.getSeriesCount(); i++)
     for (int j = 0; j < data.getSeries(i).getItemCount(); j++) {
       if (data.getSeries(i).getDataItem(j).getY().doubleValue() > max) {
         max = data.getSeries(i).getDataItem(j).getY().doubleValue();
         result = data.getSeriesName(i);
       }
     }
   return result;
 }
 private TreeMap decisionResults(double thresh) {
   TreeMap map = new TreeMap();
   decisResult res;
   int peakRt = 12345, recogRt = 12345;
   double peak = -1;
   boolean recognized = false;
   for (int i = 0; i < data.getSeriesCount(); i++) {
     peakRt = 12345;
     recogRt = 12345;
     peak = data.getSeries(i).getDataItem(0).getY().doubleValue();
     recognized = false;
     for (int j = 0; j < data.getSeries(i).getItemCount(); j++) {
       if (data.getSeries(i).getDataItem(j).getY().doubleValue() > peak) {
         peak = data.getSeries(i).getDataItem(j).getY().doubleValue();
         peakRt = j;
       }
       if (data.getSeries(i).getDataItem(j).getY().doubleValue() >= thresh && !recognized) {
         recogRt = j;
         recognized = true;
       }
     }
     System.out.println(
         "put "
             + data.getSeriesName(i)
             + " "
             + recogRt
             + " "
             + peakRt
             + " "
             + thresh
             + " "
             + peak);
     map.put(
         (new decisResult(data.getSeriesName(i), recogRt, peakRt, thresh, peak)),
         (new decisResult(data.getSeriesName(i), recogRt, peakRt, thresh, peak)));
   }
   System.out.println("\n");
   // return ((Collection)map.values()).iterator();
   return map;
 }
 public int peakRtForItem(String target) {
   if (target.startsWith("-") && target.length() > 1) {
     target = target.split("-")[1];
   }
   int targetSeries = -1;
   for (int i = 0; i < data.getSeriesCount(); i++)
     if (data.getSeriesName(i).equals(target)) {
       targetSeries = i;
       break;
     }
   if (targetSeries == -1) return -1;
   int peakCycle = 0;
   for (int j = 0; j < data.getSeries(targetSeries).getItemCount(); j++)
     if (data.getSeries(targetSeries).getDataItem(j).getY().doubleValue()
         > data.getSeries(targetSeries).getDataItem(peakCycle).getY().doubleValue()) peakCycle = j;
   return peakCycle;
 }
  public int rtForItem(String target, double threshold) {
    if (target.startsWith("-") && target.length() > 1) {
      if (target.equals("-")) target = "-";
      else if (target.split("-").length <= 0) target = "-";
      else target = target.split("-")[1];
    }
    int targetSeries = -1;
    for (int i = 0; i < data.getSeriesCount(); i++)
      if (data.getSeriesName(i).equals(target)) {
        targetSeries = i;
        break;
      }

    if (targetSeries == -1) return -1;
    for (int j = 0; j < data.getSeries(targetSeries).getItemCount(); j++)
      if (data.getSeries(targetSeries).getDataItem(j).getY().doubleValue() > threshold) return j;
    return -1;
  }
  public double peakValueOfItem(String item) {
    int targetSeries = -1;
    if (item.startsWith("-") && item.length() > 1) {
      item = item.split("-")[1];
    }
    // System.out.println("peakValueOfItem("+item+")");
    for (int i = 0; i < data.getSeriesCount(); i++)
      if (data.getSeriesName(i).equals(item)) {
        targetSeries = i;
        break;
      }

    if (targetSeries == -1) return 0d;
    double max = data.getSeries(targetSeries).getDataItem(0).getY().doubleValue();
    for (int j = 0; j < data.getSeries(targetSeries).getItemCount(); j++)
      if (data.getSeries(targetSeries).getDataItem(j).getY().doubleValue() > max)
        max = data.getSeries(targetSeries).getDataItem(j).getY().doubleValue();
    return max;
  }
 private TreeMap peakResults() {
   TreeMap map = new TreeMap();
   peakResult res;
   int peakRt = 0;
   double peak = -1;
   for (int i = 0; i < data.getSeriesCount(); i++) {
     peakRt = 0;
     peak = data.getSeries(i).getDataItem(0).getY().doubleValue();
     for (int j = 0; j < data.getSeries(i).getItemCount(); j++) {
       if (data.getSeries(i).getDataItem(j).getY().doubleValue() > peak) {
         peak = data.getSeries(i).getDataItem(j).getY().doubleValue();
         peakRt = j;
       }
     }
     map.put(
         new peakResult(data.getSeriesName(i), peakRt, peak),
         new peakResult(data.getSeriesName(i), peakRt, peak));
   }
   return map;
 }