Class RectangularROI
java.lang.Object
org.eclipse.dawnsci.analysis.dataset.roi.ROIBase
org.eclipse.dawnsci.analysis.dataset.roi.OrientableROIBase
org.eclipse.dawnsci.analysis.dataset.roi.RectangularROI
- All Implemented Interfaces:
Serializable,IOrientableROI,IRectangularROI,IROI,org.eclipse.january.INameable
- Direct Known Subclasses:
GridROI,PerimeterBoxROI,SurfacePlotROI,XAxisBoxROI,XAxisLineBoxROI,YAxisBoxROI,YAxisLineBoxROI
Class for rectangular region of interest
- See Also:
-
Field Summary
FieldsFields inherited from class org.eclipse.dawnsci.analysis.dataset.roi.OrientableROIBase
ang, cang, sang -
Constructor Summary
ConstructorsConstructorDescriptionDefault square of 100 pixelsRectangularROI(double[] spt, double[] ept) RectangularROI(double width, double angle) Square constructorRectangularROI(double width, double height, double angle) RectangularROI(double ptx, double pty, double width, double height, double angle) RectangularROI(double ptx, double pty, double width, double height, double angle, boolean clip) RectangularROI(RectangularROI orig) Copy constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAngle(double angle) Add an offset to anglevoidaddToLengths(double x, double y) voidadjustKeepDiagonalPoint(double[] cpt, double[] ept, double[] pt, boolean first) Adjust ROI whilst keeping a diagonal point in placevoidadjustKeepDiagonalPoint(int[] cpt, double[] ept, int[] pt, boolean first) Adjust ROI whilst keeping a diagonal point in placeReturn a new bounds with encompasses this roi and the bounds of the roi passed in.booleancontainsPoint(double x, double y) copy()voiddownsample(double subFactor) To account for a down-sampling of the dataset, change ROIbooleandouble[]findHorizontalIntersections(double y) Calculate x values at which ROI will intersect horizontal line of given ydoublegetAngle()doublegetAngleRelativeToMidPoint(double[] pt) doublegetAngleRelativeToMidPoint(int[] pt) doublegetAngleRelativeToPoint(double fx, double fy, double[] pt) doublegetAngleRelativeToPoint(double fx, double fy, int[] pt) double[]End point of rectangleintgetIntLength(int index) int[]int[]getIntPoint(double fx, double fy) Return point from normalized coordinates within rectangledoublegetLength(int index) double[]double[]double[]getPoint(double fx, double fy) Return point from normalized coordinates within rectangleinthashCode()booleanbooleanisNearOutline(double x, double y, double distance) voidsetAngledegrees(double angle) For JythonvoidsetClippingCompensation(boolean clippingCompensation) voidsetEndPoint(double[] pt) Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengthsvoidsetEndPoint(double[] pt, boolean moveX, boolean moveY) Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengthsvoidsetEndPoint(int[] pt) voidsetEndPoint(int[] pt, boolean moveX, boolean moveY) Start a rotated rectangle with predefined starting point and given end point and determine new starting point and lengthsvoidsetEndPointKeepLengths(double[] pt) Start a rotated rectangle with predefined starting point and given end point and determine new starting pointvoidsetLengths(double[] len) voidsetLengths(double major, double minor) voidsetMidPoint(double[] mpt) Change rectangle to have specified mid pointvoidsetPointKeepEndPoint(double[] dpt, boolean moveX, boolean moveY) Set start point whilst keeping end pointvoidsetPointKeepEndPoint(int[] dpt, boolean moveX, boolean moveY) Set start point whilst keeping end pointvoidsubPoint(int[] pt) Subtract an offset from starting pointtoString()voidtranslate(double fx, double fy) Translate by normalized coordinates (in rotated frame)Methods inherited from class org.eclipse.dawnsci.analysis.dataset.roi.OrientableROIBase
checkAngle, getAngleDegrees, sanifyAngle, sanifyAngles, setAngle, setAngleDegrees, transformToOriginal, transformToRotated, transformXToOriginalMethods inherited from class org.eclipse.dawnsci.analysis.dataset.roi.ROIBase
addPoint, addPoint, addPoint, closelyEq, closelyEq, closelyEqOrGt, closelyEqOrLt, containsPoint, getIntPoint, getName, getPoint, getPointRef, getPointX, getPointY, getValue, intersectHorizontal, isFixed, isNearOutline, isPlot, notClose, setDirty, setFixed, setName, setPlot, setPoint, setPoint, setPoint, setPoint, setValueMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.january.INameable
getName, setNameMethods inherited from interface org.eclipse.dawnsci.analysis.api.roi.IOrientableROI
getAngleDegrees, setAngle, setAngleDegrees
-
Field Details
-
len
protected double[] len
-
-
Constructor Details
-
RectangularROI
public RectangularROI()Default square of 100 pixels -
RectangularROI
Copy constructor- Parameters:
orig-
-
RectangularROI
Square constructor- Parameters:
width- A Non-Negative value for the widthangle-- Throws:
IllegalArgumentException- if the width is negative (Not allowed to have negative width or height)
-
RectangularROI
- Parameters:
width- A Non-Negative value for the widthheight- A Non-Negative value for the heightangle-- 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 widthheight- A Non-Negative value for the heightangle-- 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 widthheight- A Non-Negative value for the heightangle-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 pointept- end point
-
RectangularROI
- 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
- 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
- Parameters:
major- (width) A Non-Negative value for the widthminor- (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
- 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:IRectangularROIEnd point of rectangle- Specified by:
getEndPointin interfaceIRectangularROI- 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:
getLengthin interfaceIRectangularROI- Parameters:
index- (0 for width, 1 for height)- Returns:
- length
-
getIntLength
public int getIntLength(int index) - Specified by:
getIntLengthin interfaceIRectangularROI- Parameters:
index-- Returns:
- length
-
getLengths
public double[] getLengths()- Returns:
- reference to the lengths
-
getIntLengths
public int[] getIntLengths()- Specified by:
getIntLengthsin interfaceIRectangularROI- Returns:
- integer lengths
-
getAngle
public double getAngle()- Specified by:
getAnglein interfaceIOrientableROI- Overrides:
getAnglein classOrientableROIBase- Returns:
- Returns the angle
-
setAngledegrees
public void setAngledegrees(double angle) For Jython- Parameters:
angle- The angle in degrees to set
-
copy
- Specified by:
copyin interfaceIOrientableROI- Specified by:
copyin interfaceIRectangularROI- Specified by:
copyin interfaceIROI- Overrides:
copyin classOrientableROIBase- 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 pointmoveX-moveY-
-
setPointKeepEndPoint
public void setPointKeepEndPoint(double[] dpt, boolean moveX, boolean moveY) Set start point whilst keeping end point- Parameters:
dpt- change in start pointmoveX-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
-
containsPoint
public boolean containsPoint(double x, double y) - Specified by:
containsPointin interfaceIROI- Overrides:
containsPointin classROIBase- Parameters:
x-y-- Returns:
- true if given point is in ROI
-
isNearOutline
public boolean isNearOutline(double x, double y, double distance) - Specified by:
isNearOutlinein interfaceIROI- Overrides:
isNearOutlinein classROIBase- 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:IROITo account for a down-sampling of the dataset, change ROI- Specified by:
downsamplein interfaceIROI- Overrides:
downsamplein classROIBase- Parameters:
subFactor-
-
toString
-
findHorizontalIntersections
public double[] findHorizontalIntersections(double y) Description copied from interface:IROICalculate x values at which ROI will intersect horizontal line of given y- Specified by:
findHorizontalIntersectionsin interfaceIROI- Overrides:
findHorizontalIntersectionsin classROIBase- Parameters:
y-- Returns:
- x values in ascending order, is null in the non-intersecting case
-
hashCode
public int hashCode()- Overrides:
hashCodein classOrientableROIBase
-
equals
- Overrides:
equalsin classOrientableROIBase
-
bounds
Description copied from interface:IRectangularROIReturn a new bounds with encompasses this roi and the bounds of the roi passed in.- Specified by:
boundsin interfaceIRectangularROI- Parameters:
roi-
-