001package icy.sequence.edit; 002 003import icy.roi.ROI; 004import icy.sequence.Sequence; 005 006import javax.swing.undo.CannotRedoException; 007import javax.swing.undo.CannotUndoException; 008 009/** 010 * ROI replace Sequence edit event. 011 * 012 * @author Stephane 013 */ 014public class ROIReplaceSequenceEdit extends AbstractROISequenceEdit 015{ 016 final ROI oldRoi; 017 018 public ROIReplaceSequenceEdit(Sequence sequence, ROI oldRoi, ROI newRoi, String name) 019 { 020 super(sequence, newRoi, name); 021 022 this.oldRoi = oldRoi; 023 } 024 025 public ROIReplaceSequenceEdit(Sequence sequence, ROI oldRoi, ROI newRoi) 026 { 027 this(sequence, oldRoi, newRoi, "ROI replaced"); 028 } 029 030 @Override 031 public void undo() throws CannotUndoException 032 { 033 super.undo(); 034 035 final Sequence seq = getSequence(); 036 037 seq.removeROI(getROI(), false); 038 seq.addROI(oldRoi, false); 039 } 040 041 @Override 042 public void redo() throws CannotRedoException 043 { 044 super.redo(); 045 046 final Sequence seq = getSequence(); 047 048 seq.removeROI(oldRoi, false); 049 seq.addROI(getROI(), false); 050 } 051}