overlayGroups.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
MergedTracks mergedTracks = new MergedTracks(UUID.randomUUID().toString(), "Overlay", dataTrackList);
Track firstTrack = tracks.iterator().next();
TrackPanel panel = TrackPanel.getParentPanel(firstTrack);
panel.addTrack(mergedTracks);
panel.moveSelectedTracksTo(Arrays.asList(mergedTracks), firstTrack, false);
panel.removeTracks(tracks);
}
});
int numDataTracks = dataTrackList.size();
overlayGroups.setEnabled(numDataTracks >= 2 && numDataTracks == tracks.size());
menu.add(overlayGroups);
// Enable "separateTracks" menu if selection is a single track, and that track is merged.
JMenuItem unmergeItem = new JMenuItem("Separate Tracks");
menu.add(unmergeItem);
Track firstTrack = tracks.iterator().next();
if(tracks.size() == 1 && firstTrack instanceof MergedTracks) {
unmergeItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Track firstTrack = tracks.iterator().next();
TrackPanel panel = TrackPanel.getParentPanel(firstTrack);
final MergedTracks mergedTracks = (MergedTracks) firstTrack;
mergedTracks.setTrackAlphas(255);
panel.addTracks(mergedTracks.getMemberTracks());
panel.moveSelectedTracksTo(mergedTracks.getMemberTracks(), mergedTracks, true);
IGV.getInstance().removeTracks(Arrays.asList(mergedTracks));
}
});
}
else {