001/** 002 * 003 */ 004package plugins.kernel.roi.descriptor.property; 005 006import icy.roi.ROI; 007import icy.roi.ROIDescriptor; 008import icy.roi.ROIEvent; 009import icy.roi.ROIEvent.ROIEventType; 010import icy.sequence.Sequence; 011import icy.util.StringUtil; 012 013/** 014 * Read-Only descriptor class (see {@link ROIDescriptor}) 015 * 016 * @author Stephane 017 */ 018public class ROIReadOnlyDescriptor extends ROIDescriptor 019{ 020 public static final String ID = "Read only"; 021 022 public ROIReadOnlyDescriptor() 023 { 024 super(ID, "Read Only", Boolean.class); 025 } 026 027 @Override 028 public String getDescription() 029 { 030 return "Read only state"; 031 } 032 033 @Override 034 public boolean needRecompute(ROIEvent change) 035 { 036 return (change.getType() == ROIEventType.PROPERTY_CHANGED) 037 && (StringUtil.equals(change.getPropertyName(), ROI.PROPERTY_READONLY)); 038 } 039 040 041 @Override 042 public Object compute(ROI roi, Sequence sequence) throws UnsupportedOperationException 043 { 044 return Boolean.valueOf(getReadOnly(roi)); 045 } 046 047 /** 048 * Returns ROI read only state 049 */ 050 public static boolean getReadOnly(ROI roi) 051 { 052 if (roi == null) 053 return false; 054 055 return roi.isReadOnly(); 056 } 057}