Program: 46156
Project: 46156
Buggy source:
/** 
 * Picker for mouse events for the Embedded Swing case. To be called by Embedded Swing toolkit createCoordinateHandler. Returns non-null if window is a WindowSwing. If it is a WindowSwing then return the appropriate hit entity and the corresponding pick info.
 * @param awtEvent The event whose entity and pickInfo need to be picked.
 * @return An object of class PickEventReturn, which contains the returnvalues entity and pickDetails.
 */
public InputManager.PickEventReturn pickMouseEventSwing(MouseEvent awtMouseEvent){
  boolean inSwingRegion=false;
  logger.fine("String_Node_Str" + awtMouseEvent);
  PickInfo hitPickInfo;
  DetermineDestPickInfoReturn ret=determineDestPickInfo(awtMouseEvent);
  if (ret == null) {
    destPickInfo=null;
    hitPickInfo=null;
  }
 else {
    destPickInfo=ret.destPickInfo;
    hitPickInfo=ret.hitPickInfo;
  }
  logger.fine("String_Node_Str" + destPickInfo);
  logger.fine("String_Node_Str" + hitPickInfo);
  int eventID=awtMouseEvent.getID();
  if (eventID == MouseEvent.MOUSE_MOVED || eventID == MouseEvent.MOUSE_DRAGGED || eventID == MouseEvent.MOUSE_ENTERED || eventID == MouseEvent.MOUSE_EXITED) {
    generateEnterExitEvents(awtMouseEvent,destPickInfo);
  }
  if (destPickInfo == null || destPickInfo.size() <= 0) {
    logger.finest("String_Node_Str");
    logger.finest("String_Node_Str");
    logger.finest("String_Node_Str" + awtMouseEvent);
    swingPickInfos.add(new PickInfoQueueEntry(null,awtMouseEvent));
    generateSwingEnterExitEvents(null);
    return null;
  }
  MouseEvent3D event=(MouseEvent3D)createWonderlandEvent(awtMouseEvent);
  boolean propagatesToUnder=true;
  PickDetails pickDetails=destPickInfo.get(0);
  logger.fine("String_Node_Str" + pickDetails);
  int idx=0;
  while (pickDetails != null && idx < destPickInfo.size() && propagatesToUnder) {
    Entity entity=pickDetails.getEntity();
    logger.fine("String_Node_Str" + entity);
    if (entity == null) {
      idx++;
      if (idx < destPickInfo.size()) {
        pickDetails=destPickInfo.get(idx);
      }
 else {
        pickDetails=null;
      }
      continue;
    }
    boolean consumesEvent=false;
    propagatesToUnder=false;
    EventListenerCollection listeners=(EventListenerCollection)entity.getComponent(EventListenerCollection.class);
    if (listeners == null) {
      consumesEvent=false;
      propagatesToUnder=false;
    }
 else {
      event.setPickDetails(pickDetails);
      if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null) {
        MouseDraggedEvent3D de3d=(MouseDraggedEvent3D)event;
        if (idx < hitPickInfo.size()) {
          de3d.setHitPickDetails(hitPickInfo.get(idx));
        }
      }
      Iterator<EventListener> it=listeners.iterator();
      while (it.hasNext()) {
        EventListener listener=it.next();
        if (listener.isEnabled()) {
          Event distribEvent=EventDistributor.createEventForEntity(event,entity);
          logger.finest("String_Node_Str");
          logger.finest("String_Node_Str" + listener);
          logger.finest("String_Node_Str" + distribEvent);
          consumesEvent|=listener.consumesEvent(distribEvent);
          logger.finest("String_Node_Str" + consumesEvent);
        }
      }
    }
    logger.finest("String_Node_Str" + isWindowSwingEntity(entity));
    if (consumesEvent && isWindowSwingEntity(entity) && !isChangeControlEvent(awtMouseEvent)) {
      logger.fine("String_Node_Str");
      generateSwingEnterExitEvents(entity);
      cleanupGrab(awtMouseEvent);
      if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null && idx < hitPickInfo.size()) {
        return new InputManager.PickEventReturn(entity,pickDetails,hitPickInfo.get(idx));
      }
 else {
        return new InputManager.PickEventReturn(entity,pickDetails,null);
      }
    }
    if (propagatesToUnder) {
      idx++;
      if (idx < destPickInfo.size()) {
        pickDetails=destPickInfo.get(idx);
      }
 else {
        pickDetails=null;
      }
    }
  }
  logger.finest("String_Node_Str");
  logger.finest("String_Node_Str" + awtMouseEvent);
  logger.finest("String_Node_Str" + hitPickInfo);
  logger.finest("String_Node_Str" + destPickInfo);
  swingPickInfos.add(new PickInfoQueueEntry(hitPickInfo,awtMouseEvent));
  generateSwingEnterExitEvents(null);
  return null;
}

Fixed version (ground truth):
/** 
 * Picker for mouse events for the Embedded Swing case. To be called by Embedded Swing toolkit createCoordinateHandler. Returns non-null if window is a WindowSwing. If it is a WindowSwing then return the appropriate hit entity and the corresponding pick info.
 * @param awtEvent The event whose entity and pickInfo need to be picked.
 * @return An object of class PickEventReturn, which contains the returnvalues entity and pickDetails.
 */
public InputManager.PickEventReturn pickMouseEventSwing(MouseEvent awtMouseEvent){
  boolean inSwingRegion=false;
  logger.fine("String_Node_Str" + awtMouseEvent);
  PickInfo hitPickInfo;
  DetermineDestPickInfoReturn ret=determineDestPickInfo(awtMouseEvent);
  if (ret == null) {
    destPickInfo=null;
    hitPickInfo=null;
  }
 else {
    destPickInfo=ret.destPickInfo;
    hitPickInfo=ret.hitPickInfo;
  }
  logger.fine("String_Node_Str" + destPickInfo);
  logger.fine("String_Node_Str" + hitPickInfo);
  int eventID=awtMouseEvent.getID();
  if (eventID == MouseEvent.MOUSE_MOVED || eventID == MouseEvent.MOUSE_DRAGGED || eventID == MouseEvent.MOUSE_ENTERED || eventID == MouseEvent.MOUSE_EXITED) {
    generateEnterExitEvents(awtMouseEvent,destPickInfo);
  }
  if (destPickInfo == null || destPickInfo.size() <= 0) {
    logger.finest("String_Node_Str");
    logger.finest("String_Node_Str");
    logger.finest("String_Node_Str" + awtMouseEvent);
    swingPickInfos.add(new PickInfoQueueEntry(null,awtMouseEvent));
    generateSwingEnterExitEvents(null);
    return null;
  }
  MouseEvent3D event=(MouseEvent3D)createWonderlandEvent(awtMouseEvent);
  boolean propagatesToUnder=true;
  PickDetails pickDetails=destPickInfo.get(0);
  logger.fine("String_Node_Str" + pickDetails);
  int idx=0;
  while (pickDetails != null && idx < destPickInfo.size() && propagatesToUnder) {
    Entity entity=pickDetails.getEntity();
    logger.fine("String_Node_Str" + entity);
    if (entity == null) {
      idx++;
      if (idx < destPickInfo.size()) {
        pickDetails=destPickInfo.get(idx);
      }
 else {
        pickDetails=null;
      }
      continue;
    }
    boolean consumesEvent=false;
    propagatesToUnder=false;
    EventListenerCollection listeners=(EventListenerCollection)entity.getComponent(EventListenerCollection.class);
    if (listeners == null) {
      consumesEvent=false;
      propagatesToUnder=false;
    }
 else {
      event.setPickDetails(pickDetails);
      if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null) {
        MouseDraggedEvent3D de3d=(MouseDraggedEvent3D)event;
        if (idx < hitPickInfo.size()) {
          de3d.setHitPickDetails(hitPickInfo.get(idx));
        }
      }
      Iterator<EventListener> it=listeners.iterator();
      while (it.hasNext()) {
        EventListener listener=it.next();
        if (listener.isEnabled()) {
          Event distribEvent=EventDistributor.createEventForEntity(event,entity);
          logger.finest("String_Node_Str");
          logger.finest("String_Node_Str" + listener);
          logger.finest("String_Node_Str" + distribEvent);
          consumesEvent|=listener.consumesEvent(distribEvent);
          logger.finest("String_Node_Str" + consumesEvent);
        }
      }
    }
    logger.finest("String_Node_Str" + isWindowSwingEntity(entity));
    if (consumesEvent && isWindowSwingEntity(entity)) {
      logger.fine("String_Node_Str");
      generateSwingEnterExitEvents(entity);
      cleanupGrab(awtMouseEvent);
      if (eventID == MouseEvent.MOUSE_DRAGGED && hitPickInfo != null && idx < hitPickInfo.size()) {
        return new InputManager.PickEventReturn(entity,pickDetails,hitPickInfo.get(idx));
      }
 else {
        return new InputManager.PickEventReturn(entity,pickDetails,null);
      }
    }
    if (propagatesToUnder) {
      idx++;
      if (idx < destPickInfo.size()) {
        pickDetails=destPickInfo.get(idx);
      }
 else {
        pickDetails=null;
      }
    }
  }
  logger.finest("String_Node_Str");
  logger.finest("String_Node_Str" + awtMouseEvent);
  logger.finest("String_Node_Str" + hitPickInfo);
  logger.finest("String_Node_Str" + destPickInfo);
  swingPickInfos.add(new PickInfoQueueEntry(hitPickInfo,awtMouseEvent));
  generateSwingEnterExitEvents(null);
  return null;
}