Class RectangularROI

All Implemented Interfaces:
Serializable, IOrientableROI, IRectangularROI, IROI, org.eclipse.january.INameable
Direct Known Subclasses:
GridROI, PerimeterBoxROI, SurfacePlotROI, XAxisBoxROI, XAxisLineBoxROI, YAxisBoxROI, YAxisLineBoxROI

public class RectangularROI extends OrientableROIBase implements IRectangularROI, Serializable
Class for rectangular region of interest
See Also:
  • Field Details

    • len

      protected double[] len
  • Constructor Details

    • RectangularROI

      public RectangularROI()
      Default square of 100 pixels
    • RectangularROI

      public RectangularROI(RectangularROI orig)
      Copy constructor
      Parameters:
      orig -
    • RectangularROI

      public RectangularROI(double width, double angle) throws IllegalArgumentException
      Square constructor
      Parameters:
      width - A Non-Negative value for the width
      angle -
      Throws:
      IllegalArgumentException - if the width is negative (Not allowed to have negative width or height)
    • RectangularROI

      public RectangularROI(double width, double height, double angle) throws IllegalArgumentException
      Parameters:
      width - A Non-Negative value for the width
      height - A Non-Negative value for the height
      angle -
      Throws:
      IllegalArgumentException - if the width or height is negative (Not allowed to have negative width or height)
    • RectangularROI

      public RectangularROI(double ptx, double pty, double width, double height, double angle) throws IllegalArgumentException
      Parameters:
      ptx -
      pty -
      width - A Non-Negative value for the width
      height - A Non-Negative value for the height
      angle -
      Throws:
      IllegalArgumentException - if the width or height is negative (Not allowed to have negative width or height)
    • RectangularROI

      public RectangularROI(double ptx, double pty, double width, double height, double angle, boolean clip) throws IllegalArgumentException
      Parameters:
      ptx -
      pty -
      width - A Non-Negative value for the width
      height - A Non-Negative value for the height
      angle -
      clip -
      Throws:
      IllegalArgumentException - if the width or height is negative (Not allowed to have negative width or height)
    • RectangularROI

      public RectangularROI(double[] spt, double[] ept)
      Parameters:
      spt - start point
      ept - end point
    • RectangularROI

      public RectangularROI(IRectangularROI r)
      Parameters:
      r -
  • Method Details

    • setClippingCompensation

      public void setClippingCompensation(boolean clippingCompensation)
      Parameters:
      clippingCompensation - The clippingCompensation to set.
    • isClippingCompensation

      public boolean isClippingCompensation()
      Returns:
      Returns the clippingCompensation.
    • setLengths

      public void setLengths(double[] len) throws IllegalArgumentException
      Parameters:
      len - (width, height) Non-Negative numbers for the width and height
      Throws:
      IllegalArgumentException - if the width or height is negative (Not allowed to have negative width or height)
    • setLengths

      public void setLengths(double major, double minor) throws IllegalArgumentException
      Parameters:
      major - (width) A Non-Negative value for the width
      minor - (height) A Non-Negative value for the height
      Throws:
      IllegalArgumentException - if the width or height is negative (Not allowed to have negative width or height)
    • addToLengths

      public void addToLengths(double x, double y) throws IllegalArgumentException
      Parameters:
      x - (width)
      y - (height)
      Throws:
      IllegalArgumentException - if the width or height is negative as a result (Not allowed to have negative width or height)
    • getPoint

      public double[] getPoint(double fx, double fy)
      Return point from normalized coordinates within rectangle
      Parameters:
      fx -
      fy -
      Returns:
      point
    • getIntPoint

      public int[] getIntPoint(double fx, double fy)
      Return point from normalized coordinates within rectangle
      Parameters:
      fx -
      fy -
      Returns:
      point
    • getEndPoint

      public double[] getEndPoint()
      Description copied from interface: IRectangularROI
      End point of rectangle
      Specified by:
      getEndPoint in interface IRectangularROI
      Returns:
      end
    • getMidPoint

      public double[] getMidPoint()
      Returns:
      mid point
    • setMidPoint

      public void setMidPoint(double[] mpt)
      Change rectangle to have specified mid point
      Parameters:
      mpt -
    • getLength

      public double getLength(int index)
      Specified by:
      getLength in interface IRectangularROI
      Parameters:
      index - (0 for width, 1 for height)
      Returns:
      length
    • getIntLength

      public int getIntLength(int index)
      Specified by:
      getIntLength in interface IRectangularROI
      Parameters:
      index -
      Returns:
      length
    • getLengths

      public double[] getLengths()
      Returns:
      reference to the lengths
    • getIntLengths

      public int[] getIntLengths()
      Specified by:
      getIntLengths in interface IRectangularROI
      Returns:
      integer lengths
    • getAngle

      public double getAngle()
      Specified by:
      getAngle in interface IOrientableROI
      Overrides:
      getAngle in class OrientableROIBase
      Returns:
      Returns the angle
    • setAngledegrees

      public void setAngledegrees(double angle)
      For Jython
      Parameters:
      angle - The angle in degrees to set
    • copy

      public RectangularROI copy()
      Specified by:
      copy in interface IOrientableROI
      Specified by:
      copy in interface IRectangularROI
      Specified by:
      copy in interface IROI
      Overrides:
      copy in class OrientableROIBase
      Returns:
      a copy of ROI
    • getAngleRelativeToMidPoint

      public double getAngleRelativeToMidPoint(int[] pt)
      Parameters:
      pt -
      Returns:
      angle as measured from midpoint to given point
    • getAngleRelativeToMidPoint

      public double getAngleRelativeToMidPoint(double[] pt)
      Parameters:
      pt -
      Returns:
      angle as measured from midpoint to given point
    • getAngleRelativeToPoint

      public double getAngleRelativeToPoint(double fx, double fy, int[] pt)
      Parameters:
      fx -
      fy -
      pt -
      Returns:
      angle as measured from normalized coordinates within rectangle to given point
    • getAngleRelativeToPoint

      public double getAngleRelativeToPoint(double fx, double fy, double[] pt)
      Parameters:
      fx -
      fy -
      pt -
      Returns:
      angle as measured from normalized coordinates within rectangle to given point
    • setEndPointKeepLengths

      public void setEndPointKeepLengths(double[] pt)
      Start a rotated rectangle with predefined starting point and given end point and determine new starting point
      Parameters:
      pt -
    • setEndPoint

      public void setEndPoint(int[] pt)
      Parameters:
      pt -
    • setEndPoint

      public void setEndPoint(double[] pt)
      Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengths
      Parameters:
      pt -
    • setEndPoint

      public void setEndPoint(int[] pt, boolean moveX, boolean moveY)
      Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengths
      Parameters:
      pt -
      moveX -
      moveY -
    • setEndPoint

      public void setEndPoint(double[] pt, boolean moveX, boolean moveY)
      Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengths
      Parameters:
      pt -
      moveX -
      moveY -
    • addAngle

      public void addAngle(double angle)
      Add an offset to angle
      Parameters:
      angle -
    • subPoint

      public void subPoint(int[] pt)
      Subtract an offset from starting point
      Parameters:
      pt -
    • translate

      public void translate(double fx, double fy)
      Translate by normalized coordinates (in rotated frame)
      Parameters:
      fx -
      fy -
    • setPointKeepEndPoint

      public void setPointKeepEndPoint(int[] dpt, boolean moveX, boolean moveY)
      Set start point whilst keeping end point
      Parameters:
      dpt - change in start point
      moveX -
      moveY -
    • setPointKeepEndPoint

      public void setPointKeepEndPoint(double[] dpt, boolean moveX, boolean moveY)
      Set start point whilst keeping end point
      Parameters:
      dpt - change in start point
      moveX -
      moveY -
    • adjustKeepDiagonalPoint

      public void adjustKeepDiagonalPoint(int[] cpt, double[] ept, int[] pt, boolean first)
      Adjust ROI whilst keeping a diagonal point in place
      Parameters:
      cpt -
      ept -
      pt -
      first -
    • adjustKeepDiagonalPoint

      public void adjustKeepDiagonalPoint(double[] cpt, double[] ept, double[] pt, boolean first)
      Adjust ROI whilst keeping a diagonal point in place
      Parameters:
      cpt -
      ept -
      pt -
      first -
    • getBounds

      public RectangularROI getBounds()
      Specified by:
      getBounds in interface IROI
      Overrides:
      getBounds in class ROIBase
      Returns:
      bounding box as rectangular ROI
    • containsPoint

      public boolean containsPoint(double x, double y)
      Specified by:
      containsPoint in interface IROI
      Overrides:
      containsPoint in class ROIBase
      Parameters:
      x -
      y -
      Returns:
      true if given point is in ROI
    • isNearOutline

      public boolean isNearOutline(double x, double y, double distance)
      Specified by:
      isNearOutline in interface IROI
      Overrides:
      isNearOutline in class ROIBase
      Parameters:
      x -
      y -
      distance -
      Returns:
      true if given point within distance of outline of ROI
    • downsample

      public void downsample(double subFactor)
      Description copied from interface: IROI
      To account for a down-sampling of the dataset, change ROI
      Specified by:
      downsample in interface IROI
      Overrides:
      downsample in class ROIBase
      Parameters:
      subFactor -
    • toString

      public String toString()
      Overrides:
      toString in class ROIBase
    • findHorizontalIntersections

      public double[] findHorizontalIntersections(double y)
      Description copied from interface: IROI
      Calculate x values at which ROI will intersect horizontal line of given y
      Specified by:
      findHorizontalIntersections in interface IROI
      Overrides:
      findHorizontalIntersections in class ROIBase
      Parameters:
      y -
      Returns:
      x values in ascending order, is null in the non-intersecting case
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class OrientableROIBase
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class OrientableROIBase
    • bounds

      public IRectangularROI bounds(IROI roi)
      Description copied from interface: IRectangularROI
      Return a new bounds with encompasses this roi and the bounds of the roi passed in.
      Specified by:
      bounds in interface IRectangularROI
      Parameters:
      roi -