Package adams.data.spectrum
Class Spectrum
- java.lang.Object
-
- adams.data.container.AbstractDataContainer<SpectrumPoint>
-
- adams.data.spectrum.Spectrum
-
- All Implemented Interfaces:
adams.core.CloneHandler,adams.core.Mergeable<adams.data.container.DataContainer>,adams.core.UniqueIDHandler,adams.data.container.DataContainer<SpectrumPoint>,adams.data.container.DataPoint,adams.data.DatabaseNotesHandler,adams.data.id.DatabaseIDHandler,adams.data.id.IDHandler,adams.data.id.MutableDatabaseIDHandler,adams.data.id.MutableIDHandler,adams.data.NotesHandler,adams.data.report.MutableReportHandler<SampleData>,adams.data.report.ReportHandler<SampleData>,adams.data.spreadsheet.SpreadSheetSupporter,adams.data.statistics.InformativeStatisticSupporter<SpectrumStatistic>,Serializable,Comparable,Iterable<SpectrumPoint>,Collection<SpectrumPoint>
public class Spectrum extends adams.data.container.AbstractDataContainer<SpectrumPoint> implements adams.data.container.DataPoint, adams.data.DatabaseNotesHandler, adams.data.id.MutableDatabaseIDHandler, adams.data.report.MutableReportHandler<SampleData>, adams.data.spreadsheet.SpreadSheetSupporter, adams.data.statistics.InformativeStatisticSupporter<SpectrumStatistic>
Abstract superclass for containers for sequence points.- Version:
- $Revision: 12579 $
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_EXTENSIONthe file extension.protected static adams.data.container.DataPointComparator<SpectrumPoint>m_Comparatorthe default comparator.protected intm_DatabaseIDthe database ID.protected SpectrumPointm_MaxAmplitudepoint of greatest amplitude.protected SpectrumPointm_MaxWaveNumberpoint of greatest wave number.protected SpectrumPointm_MinAmplitudepoint of smallest amplitude.protected SpectrumPointm_MinWaveNumberpoint of smallest wave number.protected adams.data.Notesm_Notesthe notes for the chromatogram.protected adams.data.container.DataContainerm_Parentthe parent.protected SampleDatam_SampleDataSample Data.static StringSEPARATORthe separator for multiple spectra in a single file.
-
Constructor Summary
Constructors Constructor Description Spectrum()Initializes the container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassign(adams.data.container.DataContainer<SpectrumPoint> other)Obtains the stored variables from the other data point, but not the actual data points.voidassign(adams.data.container.DataPoint other)Obtains the stored variables from the other data point.intcompareToHeader(Object o)Compares this object with the specified object for order.SpectrumPointfind(float waveno)Returns the SpectrumPoint with the exact wave number, null if not found.SpectrumPointfindClosest(float waveno)Returns the SpectrumPoint with a wave number closest to the one provided.adams.data.container.DataPointComparator<SpectrumPoint>getComparator()Returns the comparator in use.intgetDatabaseID()Returns the database ID of the sequence.StringgetFileHeader()Returns the file header.StringgetFormat()Returns the data format.SpectrumgetHeader()Returns a spectrum with just the header information, but no spectrum points.SpectrumPointgetMaxAmplitude()Get point with greatest amplitude.SpectrumPointgetMaxWaveNumber()Get point with greatest wave number.SpectrumPointgetMinAmplitude()Get point with smallest amplitude.SpectrumPointgetMinWaveNumber()Get point with smallest wave number.adams.data.NotesgetNotes()Returns the currently stored notes.adams.data.container.DataContainergetParent()Returns the container this point belongs to.SampleDatagetReport()get sample data.StringgetType()Returns the sample type.inthashCode()Returns the hash code for this DataContainer.booleanhasParent()Returns whether the point belongs to a container.booleanhasReport()Returns whether sample data is present.protected voidinvalidateMinMax()Invalidates the min/max amplitude/wavenumber points.protected booleanmodifiedListener(boolean modified)Method that gets notified about changes in the collection of data points.adams.data.container.DataPointComparator<SpectrumPoint>newComparator()Returns a new instance of the default comparator.SpectrumPointnewPoint()Returns a new instance of a sequence point.voidsetDatabaseID(int value)Sets the database ID of the sequence.voidsetFormat(String value)Sets the data format (always converted to upper case).voidsetID(String value)Sets the ID of the spectrum.voidsetParent(adams.data.container.DataContainer value)Sets the container this point belongs to.voidsetReport(SampleData value)Set sample data.voidsetType(String value)Sets the sample type.adams.data.spreadsheet.SpreadSheettoSpreadSheet()Returns the content as spreadsheet.SpectrumStatistictoStatistic()Returns a statistic object of this spectrum.StringtoString()Returns a string representation of the sequence.protected voidvalidateMinMax()Initializes the min/max amplitude/wavenumber points.booleanwrite(BufferedWriter writer)Writes its content with the given writer.booleanwrite(BufferedWriter writer, boolean report)Writes its content with the given writer.booleanwrite(String filename)Writes its content to the given file.booleanwrite(String filename, boolean report)Writes its content to the given file.-
Methods inherited from class adams.data.container.AbstractDataContainer
add, addAll, clear, compareTo, compareToData, contains, containsAll, ensureCapacity, equals, equalsData, equalsHeader, getClone, getID, getUniqueID, isEmpty, iterator, mergeWith, newInstance, remove, removeAll, retainAll, size, toArray, toArray, toList, toList, toTreeSet, toTreeSet, trimToSize
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
Methods inherited from interface java.lang.Comparable
compareTo
-
-
-
-
Field Detail
-
FILE_EXTENSION
public static final String FILE_EXTENSION
the file extension.- See Also:
- Constant Field Values
-
SEPARATOR
public static final String SEPARATOR
the separator for multiple spectra in a single file.- See Also:
- Constant Field Values
-
m_DatabaseID
protected int m_DatabaseID
the database ID.
-
m_SampleData
protected SampleData m_SampleData
Sample Data.
-
m_Notes
protected adams.data.Notes m_Notes
the notes for the chromatogram.
-
m_MaxAmplitude
protected SpectrumPoint m_MaxAmplitude
point of greatest amplitude.
-
m_MinAmplitude
protected SpectrumPoint m_MinAmplitude
point of smallest amplitude.
-
m_MaxWaveNumber
protected SpectrumPoint m_MaxWaveNumber
point of greatest wave number.
-
m_MinWaveNumber
protected SpectrumPoint m_MinWaveNumber
point of smallest wave number.
-
m_Parent
protected adams.data.container.DataContainer m_Parent
the parent.
-
m_Comparator
protected static adams.data.container.DataPointComparator<SpectrumPoint> m_Comparator
the default comparator.
-
-
Method Detail
-
hashCode
public int hashCode()
Returns the hash code for this DataContainer.- Specified by:
hashCodein interfaceCollection<SpectrumPoint>- Overrides:
hashCodein classadams.data.container.AbstractDataContainer<SpectrumPoint>- Returns:
- the hash code
-
modifiedListener
protected boolean modifiedListener(boolean modified)
Method that gets notified about changes in the collection of data points. Just passes the modified state through.- Overrides:
modifiedListenerin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Parameters:
modified- whether the action modified the collection- Returns:
- the same as the input
-
newComparator
public adams.data.container.DataPointComparator<SpectrumPoint> newComparator()
Returns a new instance of the default comparator.- Specified by:
newComparatorin interfaceadams.data.container.DataContainer<SpectrumPoint>- Returns:
- the comparator instance
-
getComparator
public adams.data.container.DataPointComparator<SpectrumPoint> getComparator()
Returns the comparator in use.- Specified by:
getComparatorin interfaceadams.data.container.DataContainer<SpectrumPoint>- Returns:
- the comparator in use
-
setParent
public void setParent(adams.data.container.DataContainer value)
Sets the container this point belongs to.- Specified by:
setParentin interfaceadams.data.container.DataPoint- Parameters:
value- the container
-
getParent
public adams.data.container.DataContainer getParent()
Returns the container this point belongs to.- Specified by:
getParentin interfaceadams.data.container.DataPoint- Returns:
- the container, can be null
-
hasParent
public boolean hasParent()
Returns whether the point belongs to a container.- Specified by:
hasParentin interfaceadams.data.container.DataPoint- Returns:
- true if the point belongs to a container
-
invalidateMinMax
protected void invalidateMinMax()
Invalidates the min/max amplitude/wavenumber points.
-
validateMinMax
protected void validateMinMax()
Initializes the min/max amplitude/wavenumber points.
-
getMaxAmplitude
public SpectrumPoint getMaxAmplitude()
Get point with greatest amplitude.- Returns:
- the spectrum point
-
getMinAmplitude
public SpectrumPoint getMinAmplitude()
Get point with smallest amplitude.- Returns:
- the spectrum point
-
getMaxWaveNumber
public SpectrumPoint getMaxWaveNumber()
Get point with greatest wave number.- Returns:
- the spectrum point
-
getMinWaveNumber
public SpectrumPoint getMinWaveNumber()
Get point with smallest wave number.- Returns:
- the spectrum point
-
hasReport
public boolean hasReport()
Returns whether sample data is present.- Specified by:
hasReportin interfaceadams.data.report.ReportHandler<SampleData>- Returns:
- true if sample data present
-
setReport
public void setReport(SampleData value)
Set sample data. Also sets the database ID and sample ID in the sample data (without "'").- Specified by:
setReportin interfaceadams.data.report.MutableReportHandler<SampleData>- Parameters:
value- the sample data
-
getReport
public SampleData getReport()
get sample data.- Specified by:
getReportin interfaceadams.data.report.ReportHandler<SampleData>- Returns:
- the sample data
-
setDatabaseID
public void setDatabaseID(int value)
Sets the database ID of the sequence.- Specified by:
setDatabaseIDin interfaceadams.data.id.MutableDatabaseIDHandler- Parameters:
value- the new database ID
-
getDatabaseID
public int getDatabaseID()
Returns the database ID of the sequence.- Specified by:
getDatabaseIDin interfaceadams.data.id.DatabaseIDHandler- Returns:
- the database ID
-
setID
public void setID(String value)
Sets the ID of the spectrum.- Specified by:
setIDin interfaceadams.data.id.MutableIDHandler- Overrides:
setIDin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Parameters:
value- the new ID
-
getNotes
public adams.data.Notes getNotes()
Returns the currently stored notes.- Specified by:
getNotesin interfaceadams.data.NotesHandler- Returns:
- the current notes
-
setFormat
public void setFormat(String value)
Sets the data format (always converted to upper case). Use null to set default format.- Parameters:
value- the data format
-
getFormat
public String getFormat()
Returns the data format.- Returns:
- the data format
-
setType
public void setType(String value)
Sets the sample type.- Parameters:
value- the type
-
getType
public String getType()
Returns the sample type.- Returns:
- the type
-
assign
public void assign(adams.data.container.DataContainer<SpectrumPoint> other)
Obtains the stored variables from the other data point, but not the actual data points.- Specified by:
assignin interfaceadams.data.container.DataContainer<SpectrumPoint>- Overrides:
assignin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Parameters:
other- the data point to get the values from
-
assign
public void assign(adams.data.container.DataPoint other)
Obtains the stored variables from the other data point.- Specified by:
assignin interfaceadams.data.container.DataPoint- Parameters:
other- the data point to get the values from
-
getHeader
public Spectrum getHeader()
Returns a spectrum with just the header information, but no spectrum points.- Specified by:
getHeaderin interfaceadams.data.container.DataContainer<SpectrumPoint>- Overrides:
getHeaderin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Returns:
- the new header
-
compareToHeader
public int compareToHeader(Object o)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.- Specified by:
compareToHeaderin interfaceadams.data.container.DataContainer<SpectrumPoint>- Overrides:
compareToHeaderin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Parameters:
o- the object to be compared.- Returns:
- a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.
- Throws:
ClassCastException- if the specified object's type prevents it from being compared to this object.
-
toStatistic
public SpectrumStatistic toStatistic()
Returns a statistic object of this spectrum.- Specified by:
toStatisticin interfaceadams.data.statistics.InformativeStatisticSupporter<SpectrumStatistic>- Returns:
- statistics about this spectrum
-
newPoint
public SpectrumPoint newPoint()
Returns a new instance of a sequence point.- Specified by:
newPointin interfaceadams.data.container.DataContainer<SpectrumPoint>- Returns:
- the new sequence point
-
getFileHeader
public String getFileHeader()
Returns the file header.- Returns:
- the header
-
write
public boolean write(String filename)
Writes its content to the given file. Does not output the report.- Parameters:
filename- the file to write to- Returns:
- true if successfully written
-
write
public boolean write(String filename, boolean report)
Writes its content to the given file.- Parameters:
filename- the file to write toreport- whether to output the report as well- Returns:
- true if successfully written
-
write
public boolean write(BufferedWriter writer)
Writes its content with the given writer. Does not output the report.- Parameters:
writer- the writer to use- Returns:
- true if successfully written
-
write
public boolean write(BufferedWriter writer, boolean report)
Writes its content with the given writer.- Parameters:
writer- the writer to usereport- whether to output the report as well- Returns:
- true if successfully written
-
find
public SpectrumPoint find(float waveno)
Returns the SpectrumPoint with the exact wave number, null if not found.- Parameters:
waveno- the wave number to look for- Returns:
- the SpectrumPoint or null if not found
-
findClosest
public SpectrumPoint findClosest(float waveno)
Returns the SpectrumPoint with a wave number closest to the one provided.- Parameters:
waveno- the wave number to look for- Returns:
- the SpectrumPoint
-
toSpreadSheet
public adams.data.spreadsheet.SpreadSheet toSpreadSheet()
Returns the content as spreadsheet.- Specified by:
toSpreadSheetin interfaceadams.data.spreadsheet.SpreadSheetSupporter- Returns:
- the content
-
toString
public String toString()
Returns a string representation of the sequence.- Overrides:
toStringin classadams.data.container.AbstractDataContainer<SpectrumPoint>- Returns:
- the string representation
-
-