001/** 002 * 003 */ 004package plugins.kernel.roi.descriptor.property; 005 006import icy.roi.ROI; 007import icy.roi.ROIDescriptor; 008import icy.sequence.Sequence; 009import icy.type.point.Point5D; 010 011/** 012 * Position X ROI descriptor class (see {@link ROIDescriptor}) 013 * 014 * @author Stephane 015 */ 016public class ROIPositionXDescriptor extends ROIDescriptor 017{ 018 public static final String ID = "Position X"; 019 020 public ROIPositionXDescriptor() 021 { 022 super(ID, "Position X", Double.class); 023 } 024 025 @Override 026 public String getDescription() 027 { 028 return "Position X (bounding box)"; 029 } 030 031 @Override 032 public Object compute(ROI roi, Sequence sequence) throws UnsupportedOperationException 033 { 034 return Double.valueOf(getPositionX(roi.getPosition5D())); 035 } 036 037 /** 038 * Returns position X of specified Point5D object 039 */ 040 public static double getPositionX(Point5D point) 041 { 042 if (point == null) 043 return Double.NaN; 044 045 return point.getX(); 046 } 047}