Class SpectrumContainerManager

  • All Implemented Interfaces:
    adams.db.DatabaseConnectionHandler, adams.db.DatabaseConnectionProvider, adams.db.DatabaseConnectionUser, adams.gui.visualization.container.ColorContainerManager<SpectrumContainer>, adams.gui.visualization.container.DatabaseContainerManager<SpectrumContainer>, adams.gui.visualization.container.NamedContainerManager, adams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>, adams.gui.visualization.container.ReloadableContainerManager, adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>, Serializable

    public class SpectrumContainerManager
    extends adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
    implements adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>, adams.gui.visualization.container.ColorContainerManager<SpectrumContainer>, adams.gui.visualization.container.ReloadableContainerManager, adams.gui.visualization.container.DatabaseContainerManager<SpectrumContainer>, adams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>
    A handler for the spectrum containers.
    Version:
    $Revision: 2242 $
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected adams.gui.visualization.core.ColorProvider m_ColorProvider
      the color provider for managing the colors.
      protected adams.db.AbstractDatabaseConnection m_DatabaseConnection
      the database connection.
      protected SpectrumPanel m_Owner
      the owning panel.
      protected boolean m_Reloadable
      whether the spectrums can be reloaded from the database (fake ones can't be reloaded!).
      • Fields inherited from class adams.gui.visualization.container.AbstractContainerManager

        m_AllowRemoval, m_DataChangeListeners, m_FilteredList, m_List, m_SearchRegexp, m_SearchString, m_UpdateList, m_Updating
    • Field Detail

      • m_Reloadable

        protected boolean m_Reloadable
        whether the spectrums can be reloaded from the database (fake ones can't be reloaded!).
      • m_ColorProvider

        protected adams.gui.visualization.core.ColorProvider m_ColorProvider
        the color provider for managing the colors.
      • m_DatabaseConnection

        protected adams.db.AbstractDatabaseConnection m_DatabaseConnection
        the database connection.
    • Constructor Detail

      • SpectrumContainerManager

        public SpectrumContainerManager​(SpectrumPanel owner,
                                        adams.db.AbstractDatabaseConnection dbcon)
        Initializes the manager.
        Parameters:
        owner - the owning panel
        dbcon - the database context
    • Method Detail

      • getOwner

        public SpectrumPanel getOwner()
        Returns the owning panel.
        Returns:
        the owner
      • getDatabaseConnection

        public adams.db.AbstractDatabaseConnection getDatabaseConnection()
        Returns the currently used database connection object, can be null.
        Specified by:
        getDatabaseConnection in interface adams.db.DatabaseConnectionProvider
        Returns:
        the current object
      • setDatabaseConnection

        public void setDatabaseConnection​(adams.db.AbstractDatabaseConnection value)
        Sets the database connection object to use.
        Specified by:
        setDatabaseConnection in interface adams.db.DatabaseConnectionHandler
        Parameters:
        value - the object to use
      • setReloadable

        public void setReloadable​(boolean value)
        Sets whether the spectrums are reloadable (from the database) or not.
        Specified by:
        setReloadable in interface adams.gui.visualization.container.ReloadableContainerManager
        Parameters:
        value - true if the spectrums can be reloaded
      • isReloadable

        public boolean isReloadable()
        Returns whether the spectrums can be reloaded from the database or not.
        Specified by:
        isReloadable in interface adams.gui.visualization.container.ReloadableContainerManager
        Returns:
        true if the spectrums can be reloaded
      • setColorProvider

        public void setColorProvider​(adams.gui.visualization.core.ColorProvider value)
        Sets the color provider to use.
        Specified by:
        setColorProvider in interface adams.gui.visualization.container.ColorContainerManager<SpectrumContainer>
        Parameters:
        value - the color provider
      • getColorProvider

        public adams.gui.visualization.core.ColorProvider getColorProvider()
        Returns the color provider to use.
        Specified by:
        getColorProvider in interface adams.gui.visualization.container.ColorContainerManager<SpectrumContainer>
        Returns:
        the color provider in use
      • getColor

        public Color getColor​(SpectrumContainer cont)
        Returns the color for the container.
        Specified by:
        getColor in interface adams.gui.visualization.container.ColorContainerManager<SpectrumContainer>
        Parameters:
        cont - the container to get the color for
        Returns:
        the color
      • clear

        public void clear()
        Clears the container list.
        Overrides:
        clear in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
      • postAdd

        public void postAdd​(SpectrumContainer c)
        A post-hook for the add-method, after the container got added to the internal list and the notifications got sent.

        Updates the color, if WHITE.
        Overrides:
        postAdd in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        c - the container that got added
      • remove

        public SpectrumContainer remove​(int index)
        Removes the container at the specified position.
        Overrides:
        remove in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        index - the index of the container to remove
        Returns:
        the container that got removed
      • getIDs

        protected HashSet<String> getIDs()
        Returns a hashset with all the IDs of the currently stored containers.
        Returns:
        the IDs
      • getUniqueName

        public String getUniqueName​(HashSet<String> ids,
                                    String id)
        Creates a unique ID from of the given one, if necessary, testing against the specified IDs.
        Specified by:
        getUniqueName in interface adams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>
        Parameters:
        ids - the IDs to test uniqueness against
        id - the ID to make unique
        Returns:
        the unique ID
      • updateName

        public SpectrumContainer updateName​(SpectrumContainer c,
                                            SpectrumContainer old)
        Updates the ID of the container, i.e., gives it a unique ID.
        Specified by:
        updateName in interface adams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>
        Parameters:
        c - the container to process
        old - the old container this one is replacing, can be null
        Returns:
        the updated container (for convenience)
      • newContainer

        public SpectrumContainer newContainer​(Comparable o)
        Returns a new container containing the given payload.
        Specified by:
        newContainer in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        o - the payload to encapsulate
        Returns:
        the new container
      • preAdd

        protected SpectrumContainer preAdd​(SpectrumContainer c)
        A pre-hook for the add method, before a container gets added to the internal list.
        Overrides:
        preAdd in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        c - the container to process
        Returns:
        the processed container
      • preSet

        protected SpectrumContainer preSet​(int index,
                                           SpectrumContainer c)
        A pre-hook for the set method, before the container replaces the item currently occupying the position.
        Overrides:
        preSet in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        index - the position to place the container
        c - the container to set
        Returns:
        the processed container
      • isVisible

        public boolean isVisible​(int index)
        Returns whether the container at the specified position is visible.
        Specified by:
        isVisible in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Parameters:
        index - the container's position
        Returns:
        true if the container is visible
      • setVisible

        public void setVisible​(int index,
                               boolean visible)
        Sets the specified container's visibility. Uses the scripting engine.
        Specified by:
        setVisible in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Parameters:
        index - the index of the container
        visible - if true then the container will be made visible
      • getVisible

        public SpectrumContainer getVisible​(int index)
        Returns the nth visible container.
        Specified by:
        getVisible in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Parameters:
        index - the index (relates only to the visible containers!)
        Returns:
        the container, null if index out of range
      • countVisible

        public int countVisible()
        Returns the number of visible containers.
        Specified by:
        countVisible in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Returns:
        the number of visible containers
      • indexOf

        public int indexOf​(String id)
        Determines the index of the spectrum with the specified ID.
        Specified by:
        indexOf in interface adams.gui.visualization.container.NamedContainerManager
        Parameters:
        id - the ID of the spectrum
        Returns:
        the index of the spectrum or -1 if not found
      • getVisibleIndices

        public int[] getVisibleIndices()
        Returns the indices of all visible containers.
        Specified by:
        getVisibleIndices in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Returns:
        all containers
      • getAllVisible

        public List<SpectrumContainer> getAllVisible()
        Returns (a copy of) all currently stored containers. Those containers have no manager.
        Specified by:
        getAllVisible in interface adams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
        Returns:
        all containers
      • isMatch

        protected boolean isMatch​(SpectrumContainer cont,
                                  String search,
                                  boolean regExp)
        Returns whether the container matches the current search.
        Specified by:
        isMatch in class adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
        Parameters:
        cont - the container to check
        search - the search string
        regExp - whether to perform regular expression matching