Program: 31779
Project: 31779
Buggy source:
void drawSpectrogramPlot(Canvas c){
  labelBeginX=getLabelBeginX();
  labelBeginY=getLabelBeginY();
  if (showFreqAlongX) {
    axisFreq.setNCanvasPixel(canvasWidth - labelBeginX);
    axisTime.setNCanvasPixel(labelBeginY);
  }
 else {
    axisTime.setNCanvasPixel(canvasWidth - labelBeginX);
    axisFreq.setNCanvasPixel(labelBeginY);
  }
  fqGridLabel.setDensity(axisFreq.nCanvasPixel * gridDensity / DPRatio);
  tmGridLabel.setDensity(axisTime.nCanvasPixel * gridDensity / DPRatio);
  fqGridLabel.updateGridLabels(axisFreq.vMinInView(),axisFreq.vMaxInView());
  tmGridLabel.updateGridLabels(axisTime.vMinInView(),axisTime.vMaxInView());
  float halfFreqResolutionShift;
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LINEAR) {
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
  }
 else {
    halfFreqResolutionShift=0;
  }
  matrixSpectrogram.reset();
  if (showFreqAlongX) {
    matrixSpectrogram.postScale(axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints,axisTime.zoom * axisTime.nCanvasPixel / nTimePoints);
    matrixSpectrogram.postTranslate((labelBeginX - axisFreq.shift * axisFreq.zoom * axisFreq.nCanvasPixel + halfFreqResolutionShift),-axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel);
  }
 else {
    matrixSpectrogram.postRotate(-90);
    matrixSpectrogram.postScale(axisTime.zoom * axisTime.nCanvasPixel / nTimePoints,axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints);
    matrixSpectrogram.postTranslate((labelBeginX - axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel),(1 - axisFreq.shift) * axisFreq.zoom * axisFreq.nCanvasPixel - halfFreqResolutionShift);
  }
  c.save();
  c.concat(matrixSpectrogram);
  if (!isPaused && updateTimeDiff) {
    double timeCurrent=System.currentTimeMillis() / 1000.0;
    pixelTimeCompensate=(float)((timeLastSample - timeCurrent) / (timeInc * timeMultiplier * nTimePoints) * nTimePoints);
    updateTimeDiff=false;
  }
  if (showModeSpectrogram == TimeAxisMode.SHIFT) {
    c.translate(0.0f,pixelTimeCompensate);
  }
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LOG && spectrogramBMP.logAxisMode == SpectrogramBMP.LogAxisPlotMode.REPLOT) {
    c.scale(1f / axisFreq.zoom,1f);
    if (showFreqAlongX) {
      c.translate(nFreqPoints * axisFreq.shift * axisFreq.zoom,0.0f);
    }
 else {
      c.translate(nFreqPoints * (1f - axisFreq.shift - 1f / axisFreq.zoom) * axisFreq.zoom,0.0f);
    }
  }
  spectrogramBMP.draw(c,axisFreq.mapType,showModeSpectrogram,smoothBmpPaint,cursorTimePaint);
  c.restore();
  drawFreqCursor(c);
  if (showFreqAlongX) {
    c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginX > 0) {
      c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
 else {
    c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginY != canvasHeight) {
      c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
}

Fixed version (ground truth):
void drawSpectrogramPlot(Canvas c){
  if (canvasWidth == 0 || canvasHeight == 0) {
    return;
  }
  labelBeginX=getLabelBeginX();
  labelBeginY=getLabelBeginY();
  if (showFreqAlongX) {
    axisFreq.setNCanvasPixel(canvasWidth - labelBeginX);
    axisTime.setNCanvasPixel(labelBeginY);
  }
 else {
    axisTime.setNCanvasPixel(canvasWidth - labelBeginX);
    axisFreq.setNCanvasPixel(labelBeginY);
  }
  fqGridLabel.setDensity(axisFreq.nCanvasPixel * gridDensity / DPRatio);
  tmGridLabel.setDensity(axisTime.nCanvasPixel * gridDensity / DPRatio);
  fqGridLabel.updateGridLabels(axisFreq.vMinInView(),axisFreq.vMaxInView());
  tmGridLabel.updateGridLabels(axisTime.vMinInView(),axisTime.vMaxInView());
  float halfFreqResolutionShift;
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LINEAR) {
    halfFreqResolutionShift=axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints / 2;
  }
 else {
    halfFreqResolutionShift=0;
  }
  matrixSpectrogram.reset();
  if (showFreqAlongX) {
    matrixSpectrogram.postScale(axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints,axisTime.zoom * axisTime.nCanvasPixel / nTimePoints);
    matrixSpectrogram.postTranslate((labelBeginX - axisFreq.shift * axisFreq.zoom * axisFreq.nCanvasPixel + halfFreqResolutionShift),-axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel);
  }
 else {
    matrixSpectrogram.postRotate(-90);
    matrixSpectrogram.postScale(axisTime.zoom * axisTime.nCanvasPixel / nTimePoints,axisFreq.zoom * axisFreq.nCanvasPixel / nFreqPoints);
    matrixSpectrogram.postTranslate((labelBeginX - axisTime.shift * axisTime.zoom * axisTime.nCanvasPixel),(1 - axisFreq.shift) * axisFreq.zoom * axisFreq.nCanvasPixel - halfFreqResolutionShift);
  }
  c.save();
  c.concat(matrixSpectrogram);
  if (!isPaused && updateTimeDiff) {
    double timeCurrent=System.currentTimeMillis() / 1000.0;
    pixelTimeCompensate=(float)((timeLastSample - timeCurrent) / (timeInc * timeMultiplier * nTimePoints) * nTimePoints);
    updateTimeDiff=false;
  }
  if (showModeSpectrogram == TimeAxisMode.SHIFT) {
    c.translate(0.0f,pixelTimeCompensate);
  }
  if (axisFreq.mapType == ScreenPhysicalMapping.Type.LOG && spectrogramBMP.logAxisMode == SpectrogramBMP.LogAxisPlotMode.REPLOT) {
    c.scale(1f / axisFreq.zoom,1f);
    if (showFreqAlongX) {
      c.translate(nFreqPoints * axisFreq.shift * axisFreq.zoom,0.0f);
    }
 else {
      c.translate(nFreqPoints * (1f - axisFreq.shift - 1f / axisFreq.zoom) * axisFreq.zoom,0.0f);
    }
  }
  spectrogramBMP.draw(c,axisFreq.mapType,showModeSpectrogram,smoothBmpPaint,cursorTimePaint);
  c.restore();
  drawFreqCursor(c);
  if (showFreqAlongX) {
    c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginX > 0) {
      c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
 else {
    c.drawRect(0,0,labelBeginX,labelBeginY,backgroundPaint);
    drawFreqAxis(c,labelBeginX,labelBeginY,showFreqAlongX);
    if (labelBeginY != canvasHeight) {
      c.drawRect(0,labelBeginY,canvasWidth,canvasHeight,backgroundPaint);
      drawTimeAxis(c,labelBeginX,labelBeginY,!showFreqAlongX);
    }
  }
}