예제 #1
0
 // Takes objects and produces an object->count mapping
 HashMap convertIntoAmountsAndLabels(Object[] objs) {
   // Total the amounts
   HashMap map = new HashMap();
   for (int i = 0; i < objs.length; i++) {
     String label = "null";
     if (objs[i] != null) label = objs[i].toString();
     if (map.containsKey(label))
       map.put(label, new Double(((Double) (map.get(label))).doubleValue() + 1));
     else map.put(label, new Double(1));
   }
   return map;
 }
    public void addValue(long x, double y) {
      // calculate the bar in which this value should go
      int bar = (int) (x / barsize);

      double Y = y;
      if (ysum.containsKey(bar)) {

        double newyvalue = Y + ysum.get(bar);
        long newxvalue = x + xsum.get(bar);

        Integer newcount = count.get(bar) + 1;

        ysum.put(bar, newyvalue);
        xsum.put(bar, newxvalue);
        count.put(bar, newcount);
        Vector<Double> barvalues = values.get(bar);
        barvalues.add(Y);
        values.put(bar, barvalues);

      } else {
        ysum.put(bar, Y);
        xsum.put(bar, x);
        count.put(bar, 1);
        Vector<Double> barvalues = new Vector<Double>();
        barvalues.add(Y);
        values.put(bar, barvalues);
      }
    }