Class 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 Detail

      • 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.
    • Constructor Detail

      • Spectrum

        public Spectrum()
        Initializes the container.
    • Method Detail

      • hashCode

        public int hashCode()
        Returns the hash code for this DataContainer.
        Specified by:
        hashCode in interface Collection<SpectrumPoint>
        Overrides:
        hashCode in class adams.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 class adams.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 interface adams.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 interface adams.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 interface adams.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 interface adams.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 interface adams.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 interface adams.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 interface adams.data.report.MutableReportHandler<SampleData>
        Parameters:
        value - the sample data
      • getReport

        public SampleData getReport()
        get sample data.
        Specified by:
        getReport in interface adams.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 interface adams.data.id.MutableDatabaseIDHandler
        Parameters:
        value - the new database ID
      • getDatabaseID

        public int getDatabaseID()
        Returns the database ID of the sequence.
        Specified by:
        getDatabaseID in interface adams.data.id.DatabaseIDHandler
        Returns:
        the database ID
      • setID

        public void setID​(String value)
        Sets the ID of the spectrum.
        Specified by:
        setID in interface adams.data.id.MutableIDHandler
        Overrides:
        setID in class adams.data.container.AbstractDataContainer<SpectrumPoint>
        Parameters:
        value - the new ID
      • getNotes

        public adams.data.Notes getNotes()
        Returns the currently stored notes.
        Specified by:
        getNotes in interface adams.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 interface adams.data.container.DataContainer<SpectrumPoint>
        Overrides:
        assign in class adams.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 interface adams.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 interface adams.data.container.DataContainer<SpectrumPoint>
        Overrides:
        getHeader in class adams.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 interface adams.data.container.DataContainer<SpectrumPoint>
        Overrides:
        compareToHeader in class adams.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 interface adams.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 interface adams.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 to
        report - 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 use
        report - 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 interface adams.data.spreadsheet.SpreadSheetSupporter
        Returns:
        the content
      • toString

        public String toString()
        Returns a string representation of the sequence.
        Overrides:
        toString in class adams.data.container.AbstractDataContainer<SpectrumPoint>
        Returns:
        the string representation