# Class Spectrum

java.lang.Object
jspecview.source.JDXHeader
jspecview.source.JDXDataObject
jspecview.common.Spectrum

public class Spectrum extends JDXDataObject
`JDXSpectrum` implements the Interface Spectrum for the display of JDX Files.

Author:
  Bob Hanson, Debbie-Ann Facey, Khari A. Bryan, Prof Robert J. Lancashire

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`Spectrum.IRMode`

### Nested classes/interfaces inherited from class JDXHeader

`JDXHeader.DataLDRTable`

## Field Summary

Fields
Modifier and Type
Field
Description
`String`
`id`
`static final double`
`MAXABS`

### Fields inherited from class JDXDataObject

`blockID, ERROR, fileFirstX, fileLastX, fileNPoints, freq2dX, freq2dY, isSimulation, nucleusX, nucleusY, parent, REF_TYPE_BRUKER, REF_TYPE_STANDARD, REF_TYPE_UNSPECIFIED, REF_TYPE_VARIAN, sourceID, xFactor, xLabel, xUnits, xyCoords, y2DUnits, yFactor, yLabel, yUnits`

### Fields inherited from class JDXHeader

`dataClass, dataType, date, headerTable, jcampdx, longDate, origin, owner, time, title`

## Constructor Summary

Constructors
Constructor
Description
`Spectrum()`
Constructor

## Method Summary

Modifier and Type
Method
Description
`double`
`addSpecShift(double dx)`
`boolean`
`addSubSpectrum(Spectrum spectrum, boolean forceSub)`
adds an nD subspectrum and titles it "Subspectrum <n>" These spectra can be iterated over using the UP and DOWN keys.
`int`
`advanceSubSpectrum(int dir)`
`static boolean`
`allowSubSpec(Spectrum s1, Spectrum s2)`
`static boolean`
`areLinkableX(Spectrum s1, Spectrum s2)`
`static boolean`
`areLinkableY(Spectrum s1, Spectrum s2)`
`static boolean`
`areXScalesCompatible(Spectrum s1, Spectrum s2, boolean isSubspecCheck, boolean isLinkCheck)`
`Spectrum`
`copy()`
specifically for Abs/Trans conversion.
`void`
`dispose()`
`PeakInfo`
`findMatchingPeakInfo(PeakInfo pi)`
`PeakInfo`
`findPeakByCoord(int xPixel, Coordinate coord)`
`double`
`findXForPeakNearest(double x)`
`PeakInfo`
`getAssociatedPeakInfo(int xPixel, Coordinate coord)`
`String`
`getAxisLabel(boolean isX)`
checks in order: (1) Peaks tag attribute xUnits/yUnits, then (2) ##XLABEL/##YLABEL, then (3) ##XUNITS/##YUNITS
`PeakInfo`
`getBasePeakInfo()`
`Spectrum`
`getConvertedSpectrum()`
`Spectrum`
`getCurrentSubSpectrum()`
`Map<String,Object>`
`getInfo(String key)`
`PeakInfo`
`getModelPeakInfoForAutoSelectOnLoad()`
`Lst<PeakInfo>`
`getPeakList()`
`String`
`getPeakTitle()`
`float`
`getPeakWidth()`
`double`
`getPercentYValueAt(double x)`
`PeakInfo`
`getSelectedPeak()`
`int`
`getSubIndex()`
`Lst<Spectrum>`
`getSubSpectra()`
`String`
`getTitleLabel()`
`double`
`getUserYFactor()`
`Coordinate[]`
`getXYCoords()`
Returns the array of coordinates
`double`
`getYValueAt(double x)`
`boolean`
`isExportXAxisLeftToRight()`
`boolean`
`isForcedSubset()`
`boolean`
`matchesPeakTypeModel(String type, String model)`
Find a matching spectrum by type (IR, 1HNMR,...) and model name
`static Spectrum`
`newSpectrum(Spectrum spectrum, Coordinate[] newXYCoords, String units)`
copy spectrum with new coordinates
`static boolean`
`process(Lst<Spectrum> specs, Spectrum.IRMode irMode)`
`PeakInfo`
`selectPeakByFileIndex(String filePath, String index, String atomKey)`
`PeakInfo`
`selectPeakByFilePathTypeModel(String filePath, String type, String model)`
`void`
`setConvertedSpectrum(Spectrum spectrum)`
`int`
`setCurrentSubSpectrum(int n)`
`void`
`setExportXAxisDirection(boolean leftToRight)`
`void`
`setFillColor(GenericColor color)`
`void`
`setHighlightedPeak(PeakInfo peak)`
`void`
`setId(String id)`
`int`
`setNextPeak(Coordinate coord, int istep)`
`int`
`setPeakList(Lst<PeakInfo> list, String peakXLabel, String peakYLabel)`
`void`
`setSelectedPeak(PeakInfo peak)`
`void`
`setSimulated(String filePath)`
`void`
`setUserYFactor(double userYFactor)`
Set by JSViewer
`static Spectrum`
`taConvert(Spectrum spectrum, Spectrum.IRMode mode)`
`String`
`toString()`

### Methods inherited from class JDXDataObject

`canConvertTransAbs, canIntegrate, canSaveAsJDX, canShowSolutionColor, checkJDXRequiredTokens, copyTo, getDefaultAnnotationInfo, getDefaultUnitPrecision, getDeltaX, getFilePath, getFilePathForwardSlash, getFirstX, getFirstY, getGyromagneticRatio, getHeaderRowDataAsArray, getHydrogenCount, getInlineData, getLastX, getLastY, getMaxX, getMaxY, getMinX, getMinY, getNominalSpecFreq, getNumDim, getObservedFreq, getObservedNucleus, getPeakListArray, getSpecFreq, getTypeLabel, getXFactor, getXUnits, getY2D, getY2DPPM, getYFactor, getYRef, getYUnits, invertYAxis, is1D, isAbsorbance, isAutoOverlayFromJmolClick, isContinuous, isGC, isHNMR, isHZtoPPM, isImaginary, isInverted, isMS, isNMR, isScalable, isStackable, isTransmittance, isXIncreasing, normalizeSimulation, setBlockID, setContinuous, setFilePath, setHydrogenCount, setHZtoPPM, setIncreasing, setInlineData, setMeasurementText, setNucleusAndFreq, setNumDim, setObservedFreq, setObservedNucleus, setVarName, setXFactor, setXLabel, setXUnits, setXYCoords, setY2D, setY2DUnits, setYFactor, setYLabel, setYUnits, shouldDisplayXAxisIncreasing`

### Methods inherited from class JDXHeader

`getDataClass, getDataType, getDate, getHeaderRowDataAsArray, getHeaderTable, getJcampdx, getLongDate, getOrigin, getOwner, getQualifiedDataType, getTime, getTitle, setDataClass, setDataType, setDate, setHeaderTable, setJcampdx, setLongDate, setOrigin, setOwner, setTime, setTitle`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Field Details

### id

public String id

### MAXABS

public static final double MAXABS

See Also:
  - Constant Field Values

## Constructor Details

### Spectrum

public Spectrum()
Constructor

## Method Details

### dispose

public void dispose()

### isForcedSubset

public boolean isForcedSubset()

### setId

public void setId(String id)

### copy

public Spectrum copy()
specifically for Abs/Trans conversion. Note that we do NOT carry over piUnitsY

Returns:
  a copy of this `JDXSpectrum`

### getXYCoords

public Coordinate[] getXYCoords()
Returns the array of coordinates

Returns:
  the array of coordinates

### getPeakList

public Lst<PeakInfo> getPeakList()

### setPeakList

public int setPeakList(Lst<PeakInfo> list, String peakXLabel, String peakYLabel)

### selectPeakByFileIndex

public PeakInfo selectPeakByFileIndex(String filePath, String index, String atomKey)

### selectPeakByFilePathTypeModel

public PeakInfo selectPeakByFilePathTypeModel(String filePath, String type, String model)

### matchesPeakTypeModel

public boolean matchesPeakTypeModel(String type, String model)
Find a matching spectrum by type (IR, 1HNMR,...) and model name

Parameters:
  `type` - if null, then model is a sourceID to match
  `model` -
Returns:
  true for match

### setSelectedPeak

public void setSelectedPeak(PeakInfo peak)

### setHighlightedPeak

public void setHighlightedPeak(PeakInfo peak)

### getSelectedPeak

public PeakInfo getSelectedPeak()

### getModelPeakInfoForAutoSelectOnLoad

public PeakInfo getModelPeakInfoForAutoSelectOnLoad()

### getAssociatedPeakInfo

public PeakInfo getAssociatedPeakInfo(int xPixel, Coordinate coord)

### findPeakByCoord

public PeakInfo findPeakByCoord(int xPixel, Coordinate coord)

### getPeakTitle

public String getPeakTitle()

### getTitleLabel

public String getTitleLabel()

### setNextPeak

public int setNextPeak(Coordinate coord, int istep)

### getPercentYValueAt

public double getPercentYValueAt(double x)

### getYValueAt

public double getYValueAt(double x)

### setUserYFactor

public void setUserYFactor(double userYFactor)
Set by JSViewer

Parameters:
  `userYFactor` -

### getUserYFactor

public double getUserYFactor()

### getConvertedSpectrum

public Spectrum getConvertedSpectrum()

### setConvertedSpectrum

public void setConvertedSpectrum(Spectrum spectrum)

### taConvert

public static Spectrum taConvert(Spectrum spectrum, Spectrum.IRMode mode)

### newSpectrum

public static Spectrum newSpectrum(Spectrum spectrum, Coordinate[] newXYCoords, String units)
copy spectrum with new coordinates

Parameters:
  `spectrum` -
  `newXYCoords` -
  `units` -
Returns:
  new spectrum

### process

public static boolean process(Lst<Spectrum> specs, Spectrum.IRMode irMode)

### getSubSpectra

public Lst<Spectrum> getSubSpectra()

### getCurrentSubSpectrum

public Spectrum getCurrentSubSpectrum()

### advanceSubSpectrum

public int advanceSubSpectrum(int dir)

### setCurrentSubSpectrum

public int setCurrentSubSpectrum(int n)

### addSubSpectrum

public boolean addSubSpectrum(Spectrum spectrum, boolean forceSub)
adds an nD subspectrum and titles it "Subspectrum <n>" These spectra can be iterated over using the UP and DOWN keys.

Parameters:
  `spectrum` -
  `forceSub` -
Returns:
  true if was possible

### getSubIndex

public int getSubIndex()

### setExportXAxisDirection

public void setExportXAxisDirection(boolean leftToRight)

### isExportXAxisLeftToRight

public boolean isExportXAxisLeftToRight()

### getInfo

public Map<String,Object> getInfo(String key)

### findMatchingPeakInfo

public PeakInfo findMatchingPeakInfo(PeakInfo pi)

### getBasePeakInfo

public PeakInfo getBasePeakInfo()

### getAxisLabel

public String getAxisLabel(boolean isX)
checks in order: (1) Peaks tag attribute xUnits/yUnits, then (2) ##XLABEL/##YLABEL, then (3) ##XUNITS/##YUNITS

Parameters:
  `isX` -
Returns:
  suitable label or ""

### findXForPeakNearest

public double findXForPeakNearest(double x)

### addSpecShift

public double addSpecShift(double dx)

### allowSubSpec

public static boolean allowSubSpec(Spectrum s1, Spectrum s2)

### areXScalesCompatible

public static boolean areXScalesCompatible(Spectrum s1, Spectrum s2, boolean isSubspecCheck, boolean isLinkCheck)

### areLinkableX

public static boolean areLinkableX(Spectrum s1, Spectrum s2)

### areLinkableY

public static boolean areLinkableY(Spectrum s1, Spectrum s2)

### getPeakWidth

public float getPeakWidth()

### setSimulated

public void setSimulated(String filePath)

### setFillColor

public void setFillColor(GenericColor color)

### toString

public String toString()

Overrides:
  `toString` in class `Object`