public void mergeClips(Collection<SpriteClip> mergeClips) {

        if (mergeClips == null || mergeClips.size() == 0) {
            return;
        }

        if (mergeClips.size() == 1) {
            /**
             * If only 1 clip is selected, then find overlapping clips and merge them.
             */
            SpriteClip selectedClip = mergeClips.iterator().next();

            Collection<SpriteClip> overlappingSprites = new HashSet();
            overlappingSprites.add(selectedClip);
            for (SpriteClip currentClip : clips) {
                if (selectedClip != currentClip &&
                    currentClip.getBoundingBox().intersects(selectedClip.getBoundingBox())) {
                    overlappingSprites.add(currentClip);
                }
            }
            /* Once done, only merge if 2 sprites overlap */
            if (overlappingSprites.size() >= 2) {
                clips.removeAll(overlappingSprites);
                SpriteClip newMergedClip = SpriteClip.makeMergedClip(overlappingSprites);
                clips.add(newMergedClip);
            }
        } else {    // merge the selected clips
            clips.removeAll(mergeClips);
            SpriteClip newMergedClip = SpriteClip.makeMergedClip(mergeClips);
            clips.add(newMergedClip);
        }
    }