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 String
FILE_EXTENSION
the file extension.protected static adams.data.container.DataPointComparator<SpectrumPoint>
m_Comparator
the default comparator.protected int
m_DatabaseID
the database ID.protected SpectrumPoint
m_MaxAmplitude
point of greatest amplitude.protected SpectrumPoint
m_MaxWaveNumber
point of greatest wave number.protected SpectrumPoint
m_MinAmplitude
point of smallest amplitude.protected SpectrumPoint
m_MinWaveNumber
point of smallest wave number.protected adams.data.Notes
m_Notes
the notes for the chromatogram.protected adams.data.container.DataContainer
m_Parent
the parent.protected SampleData
m_SampleData
Sample Data.static String
SEPARATOR
the 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 void
assign(adams.data.container.DataContainer<SpectrumPoint> other)
Obtains the stored variables from the other data point, but not the actual data points.void
assign(adams.data.container.DataPoint other)
Obtains the stored variables from the other data point.int
compareToHeader(Object o)
Compares this object with the specified object for order.SpectrumPoint
find(float waveno)
Returns the SpectrumPoint with the exact wave number, null if not found.SpectrumPoint
findClosest(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.int
getDatabaseID()
Returns the database ID of the sequence.String
getFileHeader()
Returns the file header.String
getFormat()
Returns the data format.Spectrum
getHeader()
Returns a spectrum with just the header information, but no spectrum points.SpectrumPoint
getMaxAmplitude()
Get point with greatest amplitude.SpectrumPoint
getMaxWaveNumber()
Get point with greatest wave number.SpectrumPoint
getMinAmplitude()
Get point with smallest amplitude.SpectrumPoint
getMinWaveNumber()
Get point with smallest wave number.adams.data.Notes
getNotes()
Returns the currently stored notes.adams.data.container.DataContainer
getParent()
Returns the container this point belongs to.SampleData
getReport()
get sample data.String
getType()
Returns the sample type.int
hashCode()
Returns the hash code for this DataContainer.boolean
hasParent()
Returns whether the point belongs to a container.boolean
hasReport()
Returns whether sample data is present.protected void
invalidateMinMax()
Invalidates the min/max amplitude/wavenumber points.protected boolean
modifiedListener(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.SpectrumPoint
newPoint()
Returns a new instance of a sequence point.void
setDatabaseID(int value)
Sets the database ID of the sequence.void
setFormat(String value)
Sets the data format (always converted to upper case).void
setID(String value)
Sets the ID of the spectrum.void
setParent(adams.data.container.DataContainer value)
Sets the container this point belongs to.void
setReport(SampleData value)
Set sample data.void
setType(String value)
Sets the sample type.adams.data.spreadsheet.SpreadSheet
toSpreadSheet()
Returns the content as spreadsheet.SpectrumStatistic
toStatistic()
Returns a statistic object of this spectrum.String
toString()
Returns a string representation of the sequence.protected void
validateMinMax()
Initializes the min/max amplitude/wavenumber points.boolean
write(BufferedWriter writer)
Writes its content with the given writer.boolean
write(BufferedWriter writer, boolean report)
Writes its content with the given writer.boolean
write(String filename)
Writes its content to the given file.boolean
write(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:
hashCode
in interfaceCollection<SpectrumPoint>
- Overrides:
hashCode
in 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:
modifiedListener
in 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:
newComparator
in interfaceadams.data.container.DataContainer<SpectrumPoint>
- Returns:
- the comparator instance
-
getComparator
public adams.data.container.DataPointComparator<SpectrumPoint> getComparator()
Returns the comparator in use.- Specified by:
getComparator
in 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:
setParent
in interfaceadams.data.container.DataPoint
- Parameters:
value
- the container
-
getParent
public adams.data.container.DataContainer getParent()
Returns the container this point belongs to.- Specified by:
getParent
in interfaceadams.data.container.DataPoint
- Returns:
- the container, can be null
-
hasParent
public boolean hasParent()
Returns whether the point belongs to a container.- Specified by:
hasParent
in 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:
hasReport
in 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:
setReport
in interfaceadams.data.report.MutableReportHandler<SampleData>
- Parameters:
value
- the sample data
-
getReport
public SampleData getReport()
get sample data.- Specified by:
getReport
in interfaceadams.data.report.ReportHandler<SampleData>
- Returns:
- the sample data
-
setDatabaseID
public void setDatabaseID(int value)
Sets the database ID of the sequence.- Specified by:
setDatabaseID
in interfaceadams.data.id.MutableDatabaseIDHandler
- Parameters:
value
- the new database ID
-
getDatabaseID
public int getDatabaseID()
Returns the database ID of the sequence.- Specified by:
getDatabaseID
in interfaceadams.data.id.DatabaseIDHandler
- Returns:
- the database ID
-
setID
public void setID(String value)
Sets the ID of the spectrum.- Specified by:
setID
in interfaceadams.data.id.MutableIDHandler
- Overrides:
setID
in classadams.data.container.AbstractDataContainer<SpectrumPoint>
- Parameters:
value
- the new ID
-
getNotes
public adams.data.Notes getNotes()
Returns the currently stored notes.- Specified by:
getNotes
in 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:
assign
in interfaceadams.data.container.DataContainer<SpectrumPoint>
- Overrides:
assign
in 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:
assign
in 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:
getHeader
in interfaceadams.data.container.DataContainer<SpectrumPoint>
- Overrides:
getHeader
in 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:
compareToHeader
in interfaceadams.data.container.DataContainer<SpectrumPoint>
- Overrides:
compareToHeader
in 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:
toStatistic
in interfaceadams.data.statistics.InformativeStatisticSupporter<SpectrumStatistic>
- Returns:
- statistics about this spectrum
-
newPoint
public SpectrumPoint newPoint()
Returns a new instance of a sequence point.- Specified by:
newPoint
in 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:
toSpreadSheet
in interfaceadams.data.spreadsheet.SpreadSheetSupporter
- Returns:
- the content
-
toString
public String toString()
Returns a string representation of the sequence.- Overrides:
toString
in classadams.data.container.AbstractDataContainer<SpectrumPoint>
- Returns:
- the string representation
-
-