Package adams.gui.visualization.spectrum
Class SpectrumContainerManager
- java.lang.Object
-
- adams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
-
- adams.gui.visualization.spectrum.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!).
-
Constructor Summary
Constructors Constructor Description SpectrumContainerManager(SpectrumPanel owner, adams.db.AbstractDatabaseConnection dbcon)
Initializes the manager.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
Clears the container list.int
countVisible()
Returns the number of visible containers.List<SpectrumContainer>
getAllVisible()
Returns (a copy of) all currently stored containers.Color
getColor(SpectrumContainer cont)
Returns the color for the container.adams.gui.visualization.core.ColorProvider
getColorProvider()
Returns the color provider to use.adams.db.AbstractDatabaseConnection
getDatabaseConnection()
Returns the currently used database connection object, can be null.protected HashSet<String>
getIDs()
Returns a hashset with all the IDs of the currently stored containers.SpectrumPanel
getOwner()
Returns the owning panel.String
getUniqueName(HashSet<String> ids, String id)
Creates a unique ID from of the given one, if necessary, testing against the specified IDs.SpectrumContainer
getVisible(int index)
Returns the nth visible container.int[]
getVisibleIndices()
Returns the indices of all visible containers.int
indexOf(String id)
Determines the index of the spectrum with the specified ID.protected boolean
isMatch(SpectrumContainer cont, String search, boolean regExp)
Returns whether the container matches the current search.boolean
isReloadable()
Returns whether the spectrums can be reloaded from the database or not.boolean
isVisible(int index)
Returns whether the container at the specified position is visible.SpectrumContainer
newContainer(Comparable o)
Returns a new container containing the given payload.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.protected SpectrumContainer
preAdd(SpectrumContainer c)
A pre-hook for the add method, before a container gets added to the internal list.protected SpectrumContainer
preSet(int index, SpectrumContainer c)
A pre-hook for the set method, before the container replaces the item currently occupying the position.SpectrumContainer
remove(int index)
Removes the container at the specified position.void
setColorProvider(adams.gui.visualization.core.ColorProvider value)
Sets the color provider to use.void
setDatabaseConnection(adams.db.AbstractDatabaseConnection value)
Sets the database connection object to use.void
setReloadable(boolean value)
Sets whether the spectrums are reloadable (from the database) or not.void
setVisible(int index, boolean visible)
Sets the specified container's visibility.SpectrumContainer
updateName(SpectrumContainer c, SpectrumContainer old)
Updates the ID of the container, i.e., gives it a unique ID.-
Methods inherited from class adams.gui.visualization.container.AbstractContainerManager
add, addAll, addDataChangeListener, clearSearch, contains, count, countFiltered, finishUpdate, finishUpdate, get, getAll, getAllowRemoval, getFiltered, getFilteredIndices, indexOf, indexOfFiltered, isFiltered, isFiltered, isUpdating, notifyDataChangeListeners, postSet, removeDataChangeListener, search, set, setAllowRemoval, startUpdate, toString, updateSearch, updateSearchOnUpdate
-
-
-
-
Field Detail
-
m_Owner
protected SpectrumPanel m_Owner
the owning panel.
-
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 paneldbcon
- 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 interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 classadams.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 classadams.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 classadams.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 interfaceadams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>
- Parameters:
ids
- the IDs to test uniqueness againstid
- 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 interfaceadams.gui.visualization.container.NamedContainerManagerWithUniqueNames<SpectrumContainer>
- Parameters:
c
- the container to processold
- 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 classadams.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 classadams.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 classadams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
- Parameters:
index
- the position to place the containerc
- 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 interfaceadams.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 interfaceadams.gui.visualization.container.VisibilityContainerManager<SpectrumContainer>
- Parameters:
index
- the index of the containervisible
- if true then the container will be made visible
-
getVisible
public SpectrumContainer getVisible(int index)
Returns the nth visible container.- Specified by:
getVisible
in interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 interfaceadams.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 classadams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>
- Parameters:
cont
- the container to checksearch
- the search stringregExp
- whether to perform regular expression matching
-
-