Program: 58704
Project: 58704
Buggy source:
private void handleCursorDraggingLevel1(final GL gl){
  Point currentPoint=glMouseListener.getPickedPoint();
  float[] fArTargetWorldCoordinates=new float[3];
  int iselElement;
  int iNrSamples;
  fArTargetWorldCoordinates=GLCoordinateUtils.convertWindowCoordinatesToWorldCoordinates(gl,currentPoint.x,currentPoint.y);
  float fTextureHeight=viewFrustum.getHeight() - 0.6f;
  float fStep=fTextureHeight / iNumberOfElements;
  float fYPosMouse=fArTargetWorldCoordinates[1] - 0.4f;
  if (iDraggedCursorLevel1 == 1) {
    if (fYPosMouse > fPosCursorLastElementLevel1 && fYPosMouse <= viewFrustum.getHeight() - 0.6f) {
      iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
      iNrSamples=iLastSampleLevel1 - iselElement + 1;
      if (iNrSamples >= MIN_SAMPLES_PER_TEXTURE && iNrSamples < MAX_SAMPLES_PER_TEXTURE) {
        fPosCursorFirstElementLevel1=fYPosMouse;
        iFirstSampleLevel1=iselElement;
        iSamplesLevel2=iLastSampleLevel1 - iFirstSampleLevel1 + 1;
      }
    }
  }
  if (iDraggedCursorLevel1 == 2) {
    if (fYPosMouse < fPosCursorFirstElementLevel1 && fYPosMouse >= 0.0f) {
      iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
      iNrSamples=iselElement - iFirstSampleLevel1 + 1;
      if (iNrSamples >= MIN_SAMPLES_PER_TEXTURE && iNrSamples < MAX_SAMPLES_PER_TEXTURE) {
        fPosCursorLastElementLevel1=fYPosMouse;
        iLastSampleLevel1=iselElement;
        iSamplesLevel2=iLastSampleLevel1 - iFirstSampleLevel1 + 1;
      }
    }
  }
  setDisplayListDirty();
  setEmbeddedHeatMapData();
  if (glMouseListener.wasMouseReleased()) {
    bIsDraggingActiveLevel1=false;
    bDisableBlockDraggingLevel1=false;
    bActivateDraggingLevel1=false;
  }
}

Fixed version (ground truth):
private void handleCursorDraggingLevel1(final GL gl){
  Point currentPoint=glMouseListener.getPickedPoint();
  float[] fArTargetWorldCoordinates=new float[3];
  int iselElement;
  int iNrSamples;
  fArTargetWorldCoordinates=GLCoordinateUtils.convertWindowCoordinatesToWorldCoordinates(gl,currentPoint.x,currentPoint.y);
  float fTextureHeight=viewFrustum.getHeight() - 0.6f;
  float fStep=fTextureHeight / iNumberOfElements;
  float fYPosMouse=fArTargetWorldCoordinates[1] - 0.4f;
  if (iDraggedCursorLevel1 == 1) {
    if (fYPosMouse > fPosCursorLastElementLevel1 && fYPosMouse <= viewFrustum.getHeight() - 0.6f) {
      iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
      iNrSamples=iLastSampleLevel1 - iselElement + 1;
      if (iNrSamples >= MIN_SAMPLES_LEVEL_2 && iNrSamples < MAX_SAMPLES_LEVEL_2) {
        fPosCursorFirstElementLevel1=fYPosMouse;
        iFirstSampleLevel1=iselElement;
        iSamplesLevel2=iLastSampleLevel1 - iFirstSampleLevel1 + 1;
      }
    }
  }
  if (iDraggedCursorLevel1 == 2) {
    if (fYPosMouse < fPosCursorFirstElementLevel1 && fYPosMouse >= 0.0f) {
      iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
      iNrSamples=iselElement - iFirstSampleLevel1 + 1;
      if (iNrSamples >= MIN_SAMPLES_LEVEL_2 && iNrSamples < MAX_SAMPLES_LEVEL_2) {
        fPosCursorLastElementLevel1=fYPosMouse;
        iLastSampleLevel1=iselElement;
        iSamplesLevel2=iLastSampleLevel1 - iFirstSampleLevel1 + 1;
      }
    }
  }
  setDisplayListDirty();
  setEmbeddedHeatMapData();
  if (glMouseListener.wasMouseReleased()) {
    bIsDraggingActiveLevel1=false;
    bDisableBlockDraggingLevel1=false;
    bActivateDraggingLevel1=false;
  }
}