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 void
applyScale
(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 double
deltaX
(double last, double first, int numPoints) Returns the Delta X valueboolean
equals
(Coordinate coord) Indicates whether some other Coordinate is equal to this onestatic double
findXForPeakNearest
(Coordinate[] xyCoords, double x, boolean isMin) static double
Returns the maximum x value value from an array of arrays ofCoordinate
s.static double
getMaxX
(Coordinate[] coords, int start, int end) Returns the minimum x value of an array ofCoordinate
sstatic double
getMaxY
(Coordinate[] coords, int start, int end) Returns the maximum y value of an array ofCoordinate
sstatic double
getMaxYUser
(Lst<Spectrum> spectra, ViewData vd) Returns the maximum y value value from an array of arrays ofCoordinate
s.static double
Returns the minimum x value value from an array of arrays ofCoordinate
s.static double
getMinX
(Coordinate[] coords, int start, int end) Returns the minimum x value of an array ofCoordinate
sstatic double
getMinY
(Coordinate[] coords, int start, int end) Returns the minimum y value of an array ofCoordinate
sstatic double
getMinYUser
(Lst<Spectrum> spectra, ViewData vd) Returns the minimum y value value from an array of arrays ofCoordinate
s.static int
getNearestIndexForX
(Coordinate[] xyCoords, double xPt) 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 ydouble
getXVal()
Returns the x value of the coordinatedouble
getYVal()
Returns the y value of the coordinatestatic double
getYValueAt
(Coordinate[] xyCoords, double xPt) static boolean
isYInRange
(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 double
parabolicInterpolation
(Coordinate[] xyCoords, int pt) see https://ccrma.stanford.edu/~jos/sasp/Quadratic_Interpolation_Spectral_Peaks.htmlstatic Coordinate[]
Parses data stored in x, y formatstatic void
removeScale
(Coordinate[] xyCoords, double xScale, double yScale) Removes the scale factor from the coordinatesstatic Coordinate[]
reverse
(Coordinate[] x) set
(double x, double y) Constructorvoid
setXVal
(double val) Sets the x value of the coordinatevoid
setYVal
(double val) Sets the y value of the coordinatestatic void
shiftX
(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
Coordinate
s
-
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 ofCoordinate
s- Parameters:
coords
- the coordinatesstart
- the starting indexend
- the ending index- Returns:
- the maximum x value of an array of
Coordinate
s
-
getMinX
Returns the minimum x value value from an array of arrays ofCoordinate
s.- Parameters:
spectra
-vd
-- Returns:
- the minimum x value value from an array of arrays of
Coordinate
s
-
getMaxX
Returns the minimum x value of an array ofCoordinate
s- Parameters:
coords
- the coordinatesstart
- the starting indexend
- the ending index- Returns:
- the minimum x value of an array of
Coordinate
s
-
getMaxX
Returns the maximum x value value from an array of arrays ofCoordinate
s.- Parameters:
spectra
-vd
-- Returns:
- the maximum x value value from an array of arrays of
Coordinate
s
-
getMinY
Returns the minimum y value of an array ofCoordinate
s- Parameters:
coords
- the coordinatesstart
- the starting indexend
- the ending index- Returns:
- the minimum y value of an array of
Coordinate
s
-
getMinYUser
Returns the minimum y value value from an array of arrays ofCoordinate
s.- Parameters:
spectra
-vd
-- Returns:
- the minimum y value value from an array of arrays of
Coordinate
s
-
getMaxY
Returns the maximum y value of an array ofCoordinate
s- Parameters:
coords
- the coordinatesstart
- the starting indexend
- the ending index- Returns:
- the maximum y value of an array of
Coordinate
s
-
getMaxYUser
Returns the maximum y value value from an array of arrays ofCoordinate
s.- Parameters:
spectra
-vd
-- Returns:
- the maximum y value value from an array of arrays of
Coordinate
s
-
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
-