Modified code to remove duplicates as well as to generate similar possible interactions when user touches either object in a group.
Code changes occur in the functions panGesturePerformed and getPossibleInteractions. There are some variable declarations in the beginning as well.