001/**
002 * 
003 */
004package icy.roi.edit;
005
006import icy.main.Icy;
007import icy.roi.ROI;
008import icy.sequence.Sequence;
009import icy.undo.AbstractIcyUndoableEdit;
010
011import java.util.HashSet;
012import java.util.List;
013import java.util.Set;
014
015/**
016 * Base multiple ROI undoable edit.
017 * 
018 * @author Stephane
019 */
020public abstract class AbstractROIsEdit extends AbstractIcyUndoableEdit
021{
022    public AbstractROIsEdit(List<? extends ROI> rois, String name)
023    {
024        super(rois, name);
025    }
026
027    public AbstractROIsEdit(List<? extends ROI> rois)
028    {
029        this(rois, (rois.size() > 1) ? "ROIs changed" : "ROI changed");
030    }
031
032    @SuppressWarnings("unchecked")
033    public List<? extends ROI> getROIs()
034    {
035        return (List<? extends ROI>) getSource();
036    }
037
038    protected Set<Sequence> getSequences()
039    {
040        final Set<Sequence> result = new HashSet<Sequence>();
041
042        for (ROI roi : getROIs())
043            result.addAll(Icy.getMainInterface().getSequencesContaining(roi));
044
045        return result;
046    }
047}