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.ColorProviderm_ColorProviderthe color provider for managing the colors.protected adams.db.AbstractDatabaseConnectionm_DatabaseConnectionthe database connection.protected SpectrumPanelm_Ownerthe owning panel.protected booleanm_Reloadablewhether the spectra 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 voidclear()Clears the container list.intcountVisible()Returns the number of visible containers.List<SpectrumContainer>getAllVisible()Returns (a copy of) all currently stored containers.ColorgetColor(SpectrumContainer cont)Returns the color for the container.adams.gui.visualization.core.ColorProvidergetColorProvider()Returns the color provider to use.adams.db.AbstractDatabaseConnectiongetDatabaseConnection()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.SpectrumPanelgetOwner()Returns the owning panel.StringgetUniqueName(HashSet<String> ids, String id)Creates a unique ID from of the given one, if necessary, testing against the specified IDs.SpectrumContainergetVisible(int index)Returns the nth visible container.int[]getVisibleIndices()Returns the indices of all visible containers.intindexOf(String id)Determines the index of the spectrum with the specified ID.protected booleanisMatch(SpectrumContainer cont, String search, boolean regExp)Returns whether the container matches the current search.booleanisReloadable()Returns whether the spectra can be reloaded from the database or not.booleanisVisible(int index)Returns whether the container at the specified position is visible.SpectrumContainernewContainer(Comparable o)Returns a new container containing the given payload.voidpostAdd(SpectrumContainer c)A post-hook for the add-method, after the container got added to the internal list and the notifications got sent.protected SpectrumContainerpreAdd(SpectrumContainer c)A pre-hook for the add method, before a container gets added to the internal list.protected SpectrumContainerpreSet(int index, SpectrumContainer c)A pre-hook for the set method, before the container replaces the item currently occupying the position.SpectrumContainerremove(int index)Removes the container at the specified position.voidsetColorProvider(adams.gui.visualization.core.ColorProvider value)Sets the color provider to use.voidsetDatabaseConnection(adams.db.AbstractDatabaseConnection value)Sets the database connection object to use.voidsetReloadable(boolean value)Sets whether the spectra are reloadable (from the database) or not.voidsetVisible(int index, boolean visible)Sets the specified container's visibility.SpectrumContainerupdateName(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 spectra 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:
getDatabaseConnectionin interfaceadams.db.DatabaseConnectionProvider- Returns:
- the current object
-
setDatabaseConnection
public void setDatabaseConnection(adams.db.AbstractDatabaseConnection value)
Sets the database connection object to use.- Specified by:
setDatabaseConnectionin interfaceadams.db.DatabaseConnectionHandler- Parameters:
value- the object to use
-
setReloadable
public void setReloadable(boolean value)
Sets whether the spectra are reloadable (from the database) or not.- Specified by:
setReloadablein interfaceadams.gui.visualization.container.ReloadableContainerManager- Parameters:
value- true if the spectra can be reloaded
-
isReloadable
public boolean isReloadable()
Returns whether the spectra can be reloaded from the database or not.- Specified by:
isReloadablein interfaceadams.gui.visualization.container.ReloadableContainerManager- Returns:
- true if the spectra can be reloaded
-
setColorProvider
public void setColorProvider(adams.gui.visualization.core.ColorProvider value)
Sets the color provider to use.- Specified by:
setColorProviderin 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:
getColorProviderin 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:
getColorin 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:
clearin 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:
postAddin 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:
removein 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:
getUniqueNamein 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:
updateNamein 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:
newContainerin 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:
preAddin 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:
preSetin 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:
isVisiblein 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:
setVisiblein 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:
getVisiblein 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:
countVisiblein 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:
indexOfin 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:
getVisibleIndicesin 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:
getAllVisiblein 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:
isMatchin classadams.gui.visualization.container.AbstractContainerManager<SpectrumContainer>- Parameters:
cont- the container to checksearch- the search stringregExp- whether to perform regular expression matching
-
-