Package jspecview.common
Class Coordinate
java.lang.Object
jspecview.common.Coordinate
- Direct Known Subclasses:
Annotation
The
Coordinate class stores the x and y values of a coordinate.- Author:
- Debbie-Ann Facey, Khari A. Bryan, Prof Robert J. Lancashire
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyScale(Coordinate[] xyCoords, double xScale, double yScale) Apply the scale factor to the coordinatescopy()Returns a new coordinate that has the same x and y values of this coordinatestatic doubledeltaX(double last, double first, int numPoints) Returns the Delta X valuebooleanequals(Coordinate coord) Indicates whether some other Coordinate is equal to this onestatic doublefindXForPeakNearest(Coordinate[] xyCoords, double x, boolean isMin) static doubleReturns the maximum x value value from an array of arrays ofCoordinates.static doublegetMaxX(Coordinate[] coords, int start, int end) Returns the minimum x value of an array ofCoordinatesstatic doublegetMaxY(Coordinate[] coords, int start, int end) Returns the maximum y value of an array ofCoordinatesstatic doublegetMaxYUser(Lst<Spectrum> spectra, ViewData vd) Returns the maximum y value value from an array of arrays ofCoordinates.static doubleReturns the minimum x value value from an array of arrays ofCoordinates.static doublegetMinX(Coordinate[] coords, int start, int end) Returns the minimum x value of an array ofCoordinatesstatic doublegetMinY(Coordinate[] coords, int start, int end) Returns the minimum y value of an array ofCoordinatesstatic doublegetMinYUser(Lst<Spectrum> spectra, ViewData vd) Returns the minimum y value value from an array of arrays ofCoordinates.static intgetNearestIndexForX(Coordinate[] xyCoords, double xPt) static doublegetNearestXWithYAbove(Coordinate[] xyCoords, double x, double y, boolean inverted, boolean andGreaterThanX) discovers nearest peak left or right of x that is above threshold ydoublegetXVal()Returns the x value of the coordinatedoublegetYVal()Returns the y value of the coordinatestatic doublegetYValueAt(Coordinate[] xyCoords, double xPt) static booleanisYInRange(Coordinate[] xyCoords, double min, double max) Determines if the y values of a spectrum are in a certain rangestatic Coordinate[]normalise(Coordinate[] xyCoords, double min, double max) Normalises the y values of a spectrum to a certain rangestatic doubleparabolicInterpolation(Coordinate[] xyCoords, int pt) see https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation_Spectral_Peaks.htmlstatic Coordinate[]Parses data stored in x, y formatstatic voidremoveScale(Coordinate[] xyCoords, double xScale, double yScale) Removes the scale factor from the coordinatesstatic Coordinate[]reverse(Coordinate[] x) set(double x, double y) ConstructorvoidsetXVal(double val) Sets the x value of the coordinatevoidsetYVal(double val) Sets the y value of the coordinatestatic voidshiftX(Coordinate[] xyCoords, double dx) toString()Overides Objects toString() method
-
Constructor Details
-
Coordinate
public Coordinate()Constructor
-
-
Method Details
-
set
Constructor- Parameters:
x- the x valuey- the y value- Returns:
- this
-
getXVal
public double getXVal()Returns the x value of the coordinate- Returns:
- the x value of the coordinate
-
getYVal
public double getYVal()Returns the y value of the coordinate- Returns:
- the y value of the coordinate
-
setXVal
public void setXVal(double val) Sets the x value of the coordinate- Parameters:
val- the x value
-
setYVal
public void setYVal(double val) Sets the y value of the coordinate- Parameters:
val- the y value
-
copy
Returns a new coordinate that has the same x and y values of this coordinate- Returns:
- Returns a new coordinate that has the same x and y values of this coordinate
-
equals
Indicates whether some other Coordinate is equal to this one- Parameters:
coord- the reference coordinate- Returns:
- true if the coordinates are equal, false otherwise
-
toString
Overides Objects toString() method -
isYInRange
Determines if the y values of a spectrum are in a certain range- Parameters:
xyCoords-min-max-- Returns:
- true is in range, otherwise false
-
normalise
Normalises the y values of a spectrum to a certain range- Parameters:
xyCoords-min-max-- Returns:
- array of normalised coordinates
-
reverse
-
parseDSV
Parses data stored in x, y format- Parameters:
dataPoints- the data as stringxFactor- the factor to apply to x valuesyFactor- the factor to apply to y values- Returns:
- an array of
Coordinates
-
deltaX
public static double deltaX(double last, double first, int numPoints) Returns the Delta X value- Parameters:
last- the last x valuefirst- the first x valuenumPoints- the number of data points- Returns:
- the Delta X value
-
removeScale
Removes the scale factor from the coordinates- Parameters:
xyCoords- the array of coordinatesxScale- the scale for the x valuesyScale- the scale for the y values
-
applyScale
Apply the scale factor to the coordinates- Parameters:
xyCoords- the array of coordinatesxScale- the scale for the x valuesyScale- the scale for the y values
-
getMinX
Returns the minimum x value of an array ofCoordinates- Parameters:
coords- the coordinatesstart- the starting indexend- the ending index- Returns:
- the maximum x value of an array of
Coordinates
-
getMinX
Returns the minimum x value value from an array of arrays ofCoordinates.- Parameters:
spectra-vd-- Returns:
- the minimum x value value from an array of arrays of
Coordinates
-
getMaxX
Returns the minimum x value of an array ofCoordinates- Parameters:
coords- the coordinatesstart- the starting indexend- the ending index- Returns:
- the minimum x value of an array of
Coordinates
-
getMaxX
Returns the maximum x value value from an array of arrays ofCoordinates.- Parameters:
spectra-vd-- Returns:
- the maximum x value value from an array of arrays of
Coordinates
-
getMinY
Returns the minimum y value of an array ofCoordinates- Parameters:
coords- the coordinatesstart- the starting indexend- the ending index- Returns:
- the minimum y value of an array of
Coordinates
-
getMinYUser
Returns the minimum y value value from an array of arrays ofCoordinates.- Parameters:
spectra-vd-- Returns:
- the minimum y value value from an array of arrays of
Coordinates
-
getMaxY
Returns the maximum y value of an array ofCoordinates- Parameters:
coords- the coordinatesstart- the starting indexend- the ending index- Returns:
- the maximum y value of an array of
Coordinates
-
getMaxYUser
Returns the maximum y value value from an array of arrays ofCoordinates.- Parameters:
spectra-vd-- Returns:
- the maximum y value value from an array of arrays of
Coordinates
-
getYValueAt
-
getNearestIndexForX
-
findXForPeakNearest
-
parabolicInterpolation
see https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation_Spectral_Peaks.html- Parameters:
xyCoords-pt-- Returns:
- center
-
shiftX
-
getNearestXWithYAbove
public static double getNearestXWithYAbove(Coordinate[] xyCoords, double x, double y, boolean inverted, boolean andGreaterThanX) discovers nearest peak left or right of x that is above threshold y- Parameters:
xyCoords-x-y-inverted-andGreaterThanX-- Returns:
- interpolated x value or NaN
-