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 * Name descriptor class (see {@link ROIDescriptor}) 015 * 016 * @author Stephane 017 */ 018public class ROINameDescriptor extends ROIDescriptor 019{ 020 public static final String ID = "Name"; 021 022 public ROINameDescriptor() 023 { 024 super(ID, "Name", String.class); 025 } 026 027 @Override 028 public String getDescription() 029 { 030 return "Name of the ROI"; 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_NAME)); 038 } 039 040 @Override 041 public Object compute(ROI roi, Sequence sequence) throws UnsupportedOperationException 042 { 043 return getName(roi); 044 } 045 046 /** 047 * Returns ROI name 048 */ 049 public static String getName(ROI roi) 050 { 051 if (roi == null) 052 return ""; 053 054 return roi.getName(); 055 } 056}