Program: 58663
Project: 58663
Buggy source:
/** 
 * Function used for updating position of block (block of elements rendered in level 2) in case of dragging
 * @param gl
 */
private void handleBlockDraggingLevel1(final GL gl){
  Point currentPoint=glMouseListener.getPickedPoint();
  float[] fArTargetWorldCoordinates=new float[3];
  int iselElement;
  fArTargetWorldCoordinates=GLCoordinateUtils.convertWindowCoordinatesToWorldCoordinates(gl,currentPoint.x,currentPoint.y);
  float fTextureHeight=viewFrustum.getHeight() - 0.6f;
  float fStep=fTextureHeight / iNumberOfElements;
  float fYPosMouse=fArTargetWorldCoordinates[1] - 0.4f;
  iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
  if (iSamplesLevel2 % 2 == 0) {
    if ((iselElement - (int)Math.floor(iSamplesLevel2 / 2) + 1) >= 0 && (iselElement + (int)Math.floor(iSamplesLevel2 / 2)) < iNumberOfElements) {
      iFirstSampleLevel1=iselElement - (int)Math.floor(iSamplesLevel2 / 2) + 1;
      fPosCursorFirstElementLevel1=fTextureHeight - (iFirstSampleLevel1 * fStep);
      iLastSampleLevel1=iselElement + (int)Math.floor(iSamplesLevel2 / 2);
      fPosCursorLastElementLevel1=fTextureHeight - ((iLastSampleLevel1 + 1) * fStep);
    }
  }
 else {
    if ((iselElement - (int)Math.ceil(iSamplesLevel2 / 2)) >= 0 && (iselElement + (int)Math.floor(iSamplesLevel2 / 2)) < iNumberOfElements) {
      iFirstSampleLevel1=iselElement - (int)Math.ceil(iSamplesLevel2 / 2);
      fPosCursorFirstElementLevel1=fTextureHeight - (iFirstSampleLevel1 * fStep);
      iLastSampleLevel1=iselElement + (int)Math.floor(iSamplesLevel2 / 2);
      fPosCursorLastElementLevel1=fTextureHeight - ((iLastSampleLevel1 + 1) * fStep);
    }
  }
  setDisplayListDirty();
  setEmbeddedHeatMapData();
  if (glMouseListener.wasMouseReleased()) {
    bIsDraggingWholeBlockLevel1=false;
    bDisableCursorDraggingLevel1=false;
    bActivateDraggingLevel1=false;
  }
}

Fixed version (ground truth):
/** 
 * Function used for updating position of block (block of elements rendered in level 2) in case of dragging
 * @param gl
 */
private void handleBlockDraggingLevel1(final GL gl){
  Point currentPoint=glMouseListener.getPickedPoint();
  float[] fArTargetWorldCoordinates=new float[3];
  int iselElement;
  fArTargetWorldCoordinates=GLCoordinateUtils.convertWindowCoordinatesToWorldCoordinates(gl,currentPoint.x,currentPoint.y);
  float fTextureHeight=viewFrustum.getHeight() - 0.6f;
  float fStep=fTextureHeight / iNumberOfElements;
  float fYPosMouse=fArTargetWorldCoordinates[1] - 0.4f;
  iselElement=(int)Math.floor((fTextureHeight - fYPosMouse) / fStep);
  if (iSamplesLevel2 % 2 == 0) {
    if ((iselElement - (int)Math.floor(iSamplesLevel2 / 2) + 1) >= 0 && (iselElement + (int)Math.floor(iSamplesLevel2 / 2)) < iNumberOfElements) {
      iFirstSampleLevel1=iselElement - (int)Math.floor(iSamplesLevel2 / 2) + 1;
      fPosCursorFirstElementLevel1=fTextureHeight - (iFirstSampleLevel1 * fStep);
      iLastSampleLevel1=iselElement + (int)Math.floor(iSamplesLevel2 / 2);
      fPosCursorLastElementLevel1=fTextureHeight - ((iLastSampleLevel1 + 1) * fStep);
    }
  }
 else {
    if ((iselElement - (int)Math.ceil(iSamplesLevel2 / 2)) >= 0 && (iselElement + (int)Math.floor(iSamplesLevel2 / 2)) < iNumberOfElements) {
      iFirstSampleLevel1=iselElement - (int)Math.ceil(iSamplesLevel2 / 2);
      fPosCursorFirstElementLevel1=fTextureHeight - (iFirstSampleLevel1 * fStep);
      iLastSampleLevel1=iselElement + (int)Math.floor(iSamplesLevel2 / 2);
      fPosCursorLastElementLevel1=fTextureHeight - ((iLastSampleLevel1 + 1) * fStep);
    }
  }
  setDisplayListDirty();
  if (glMouseListener.wasMouseReleased()) {
    bIsDraggingWholeBlockLevel1=false;
    bDisableCursorDraggingLevel1=false;
    bActivateDraggingLevel1=false;
  }
}