protected void drawHistogram(Graphics g, MBinSummary binCnt) {
      //    ********************************
      // * Draw the histogram
      // ********************************
      MClusterSummary[] bins;
      int value;
      int height;
      int y;

      Color color;
      Font f = g.getFont();
      Font newFont = new Font(UIManager.getFont("Label.font").getName(), Font.PLAIN, 14);
      g.setFont(newFont);

      bins = binCnt.GetBins();
      // _maxBinsIndex

      // ***********************
      // draw the outliner even it is zero
      // ***********************
      value = bins[0].getCount();

      height = (int) ((double) value * _pixel_per_unit);

      y = _abs_line_height - height;

      g.setColor(MColorMgr.GetInstance().GetColor(0, MGlobal.FADE_IDX_MAX));
      g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
      g.setColor(Color.BLACK);
      g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
      g.drawString("0", (int) _bin_cur_x, _abs_axis_height);

      _bin_cur_x += (int) _bin_width_two;

      // ***********************
      // * draw the rest
      // ***********************

      for (int idx = 1; idx <= binCnt.GetMaxBinIndex(); idx++) {

        value = bins[idx].getCount();

        if (value > 0) {

          height = (int) ((double) value * _pixel_per_unit);

          y = _abs_line_height - height;

          g.setColor(MColorMgr.GetInstance().GetColor(idx, MGlobal.FADE_IDX_MAX));
          g.fillRect(_bin_cur_x, y, (int) _bin_width, height);
          g.setColor(Color.BLACK);
          g.drawString(value + "", (int) _bin_cur_x, y - LABEL_HEIGHT);
          g.drawString(idx + "", (int) _bin_cur_x, _abs_axis_height);

          _bin_cur_x += (int) _bin_width_two;
        }
      }
      g.setFont(f);
      bins = null;
    }
  public void AddValue(int x, int y, int bin, int windowIdx) {
    System.out.println("Adding value " + bin + ", " + windowIdx);
    if (_binCnt == null || _curWindowIdx < windowIdx) {

      if (_binCnt != null && _isAutoCapture) {
        new Thread(new CaptureThread(_capturePath + (_capCounter++) + ".jpg", _histogramArea))
            .start();
      }

      if (_binCnt != null) {
        _oldBinCnt = _binCnt;
      }

      _binCnt = new MBinSummary(_bufferSize);
      _binCnt.SetDynamicResize(true);
      _curWindowIdx = windowIdx;
    }
    _binCnt.Add(x, y, bin);
    setDrawStatus(true);
  }