Class TimeseriesContainerManager<C extends TimeseriesContainer>
- java.lang.Object
-
- adams.gui.visualization.container.AbstractContainerManager<C>
-
- adams.gui.visualization.timeseries.TimeseriesContainerManager<C>
-
- All Implemented Interfaces:
DatabaseConnectionHandler,DatabaseConnectionProvider,DatabaseConnectionUser,ColorContainerManager<TimeseriesContainer>,DatabaseContainerManager<C>,NamedContainerManager,NamedContainerManagerWithUniqueNames<C>,VisibilityContainerManager<C>,Serializable
public class TimeseriesContainerManager<C extends TimeseriesContainer> extends AbstractContainerManager<C> implements VisibilityContainerManager<C>, ColorContainerManager<TimeseriesContainer>, DatabaseContainerManager<C>, NamedContainerManagerWithUniqueNames<C>
A handler for the Timeseries containers.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ColorProviderm_ColorProviderthe color provider for managing the colors.protected AbstractDatabaseConnectionm_DatabaseConnectionthe database connection.protected TimeseriesPanelm_Ownerthe owning panel.protected booleanm_Reloadablewhether the profiles 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
-
-
Constructor Summary
Constructors Constructor Description TimeseriesContainerManager(TimeseriesPanel owner, 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<C>getAllVisible()Returns (a copy of) all currently stored containers.ColorgetColor(TimeseriesContainer cont)Returns the color for the container.ColorProvidergetColorProvider()Returns the color provider to use.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.TimeseriesPanelgetOwner()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.CgetVisible(int index)Returns the nth visible container.int[]getVisibleIndices()Returns the indices of all visible containers.intindexOf(String id)Determines the index of the timeseries with the specified ID.protected booleanisMatch(C cont, String search, boolean regExp)Returns whether the container matches the current search.booleanisReloadable()Returns whether the timeseries can be reloaded from the database or not.booleanisVisible(int index)Returns whether the container at the specified position is visible.CnewContainer(Comparable o)Returns a new container containing the given payload.voidpostAdd(TimeseriesContainer c)A post-hook for the add-method, after the container got added to the internal list and the notifications got sent.protected TimeseriesContainerpreAdd(TimeseriesContainer c)A pre-hook for the add method, before a container gets added to the internal list.protected TimeseriesContainerpreSet(int index, TimeseriesContainer c)A pre-hook for the set method, before the container replaces the item currently occupying the position.Cremove(int index)Removes the container at the specified position.voidsetColorProvider(ColorProvider value)Sets the color provider to use.voidsetDatabaseConnection(AbstractDatabaseConnection value)Sets the database connection object to use.voidsetReloadable(boolean value)Sets whether the timeseries are reloadable (from the database) or not.voidsetVisible(int index, boolean visible)Sets the specified container's visibility.TimeseriesContainerupdateName(TimeseriesContainer c, TimeseriesContainer 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 TimeseriesPanel m_Owner
the owning panel.
-
m_Reloadable
protected boolean m_Reloadable
whether the profiles can be reloaded from the database (fake ones can't be reloaded!).
-
m_ColorProvider
protected ColorProvider m_ColorProvider
the color provider for managing the colors.
-
m_DatabaseConnection
protected AbstractDatabaseConnection m_DatabaseConnection
the database connection.
-
-
Constructor Detail
-
TimeseriesContainerManager
public TimeseriesContainerManager(TimeseriesPanel owner, AbstractDatabaseConnection dbcon)
Initializes the manager.- Parameters:
owner- the owning paneldbcon- the database context
-
-
Method Detail
-
getOwner
public TimeseriesPanel getOwner()
Returns the owning panel.- Returns:
- the owner
-
getDatabaseConnection
public AbstractDatabaseConnection getDatabaseConnection()
Returns the currently used database connection object, can be null.- Specified by:
getDatabaseConnectionin interfaceDatabaseConnectionProvider- Returns:
- the current object
-
setDatabaseConnection
public void setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.- Specified by:
setDatabaseConnectionin interfaceDatabaseConnectionHandler- Parameters:
value- the object to use
-
setReloadable
public void setReloadable(boolean value)
Sets whether the timeseries are reloadable (from the database) or not.- Parameters:
value- true if the timeseries can be reloaded
-
isReloadable
public boolean isReloadable()
Returns whether the timeseries can be reloaded from the database or not.- Returns:
- true if the timeseries can be reloaded
-
setColorProvider
public void setColorProvider(ColorProvider value)
Sets the color provider to use.- Specified by:
setColorProviderin interfaceColorContainerManager<C extends TimeseriesContainer>- Parameters:
value- the color provider
-
getColorProvider
public ColorProvider getColorProvider()
Returns the color provider to use.- Specified by:
getColorProviderin interfaceColorContainerManager<C extends TimeseriesContainer>- Returns:
- the color provider in use
-
getColor
public Color getColor(TimeseriesContainer cont)
Returns the color for the container.- Specified by:
getColorin interfaceColorContainerManager<C extends TimeseriesContainer>- Parameters:
cont- the container to get the color for- Returns:
- the color
-
clear
public void clear()
Clears the container list.- Overrides:
clearin classAbstractContainerManager<C extends TimeseriesContainer>
-
postAdd
public void postAdd(TimeseriesContainer 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 classAbstractContainerManager<C extends TimeseriesContainer>- Parameters:
c- the container that got added
-
remove
public C remove(int index)
Removes the container at the specified position.- Overrides:
removein classAbstractContainerManager<C extends TimeseriesContainer>- 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 interfaceNamedContainerManagerWithUniqueNames<C extends TimeseriesContainer>- Parameters:
ids- the IDs to test uniqueness againstid- the ID to make unique- Returns:
- the unique ID
-
updateName
public TimeseriesContainer updateName(TimeseriesContainer c, TimeseriesContainer old)
Updates the ID of the container, i.e., gives it a unique ID.- Specified by:
updateNamein interfaceNamedContainerManagerWithUniqueNames<C extends TimeseriesContainer>- Parameters:
c- the container to processold- the old container this one is replacing, can be null- Returns:
- the updated container (for convenience)
-
newContainer
public C newContainer(Comparable o)
Returns a new container containing the given payload.- Specified by:
newContainerin classAbstractContainerManager<C extends TimeseriesContainer>- Parameters:
o- the payload to encapsulate- Returns:
- the new container
-
preAdd
protected TimeseriesContainer preAdd(TimeseriesContainer c)
A pre-hook for the add method, before a container gets added to the internal list.- Overrides:
preAddin classAbstractContainerManager<C extends TimeseriesContainer>- Parameters:
c- the container to process- Returns:
- the processed container
-
preSet
protected TimeseriesContainer preSet(int index, TimeseriesContainer c)
A pre-hook for the set method, before the container replaces the item currently occupying the position.- Overrides:
preSetin classAbstractContainerManager<C extends TimeseriesContainer>- 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 interfaceVisibilityContainerManager<C extends TimeseriesContainer>- 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 interfaceVisibilityContainerManager<C extends TimeseriesContainer>- Parameters:
index- the index of the containervisible- if true then the container will be made visible
-
getVisible
public C getVisible(int index)
Returns the nth visible container.- Specified by:
getVisiblein interfaceVisibilityContainerManager<C extends TimeseriesContainer>- 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 interfaceVisibilityContainerManager<C extends TimeseriesContainer>- Returns:
- the number of visible containers
-
indexOf
public int indexOf(String id)
Determines the index of the timeseries with the specified ID.- Specified by:
indexOfin interfaceNamedContainerManager- Parameters:
id- the ID of the timeseries- Returns:
- the index of the timeseries or -1 if not found
-
getVisibleIndices
public int[] getVisibleIndices()
Returns the indices of all visible containers.- Specified by:
getVisibleIndicesin interfaceVisibilityContainerManager<C extends TimeseriesContainer>- Returns:
- all containers
-
getAllVisible
public List<C> getAllVisible()
Returns (a copy of) all currently stored containers. Those containers have no manager.- Specified by:
getAllVisiblein interfaceVisibilityContainerManager<C extends TimeseriesContainer>- Returns:
- all containers
-
isMatch
protected boolean isMatch(C cont, String search, boolean regExp)
Returns whether the container matches the current search.- Specified by:
isMatchin classAbstractContainerManager<C extends TimeseriesContainer>- Parameters:
cont- the container to checksearch- the search stringregExp- whether to perform regular expression matching
-
-