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 ColorProvider
m_ColorProvider
the color provider for managing the colors.protected AbstractDatabaseConnection
m_DatabaseConnection
the database connection.protected TimeseriesPanel
m_Owner
the owning panel.protected boolean
m_Reloadable
whether 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 void
clear()
Clears the container list.int
countVisible()
Returns the number of visible containers.List<C>
getAllVisible()
Returns (a copy of) all currently stored containers.Color
getColor(TimeseriesContainer cont)
Returns the color for the container.ColorProvider
getColorProvider()
Returns the color provider to use.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.TimeseriesPanel
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.C
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 timeseries with the specified ID.protected boolean
isMatch(C cont, String search, boolean regExp)
Returns whether the container matches the current search.boolean
isReloadable()
Returns whether the timeseries can be reloaded from the database or not.boolean
isVisible(int index)
Returns whether the container at the specified position is visible.C
newContainer(Comparable o)
Returns a new container containing the given payload.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.protected TimeseriesContainer
preAdd(TimeseriesContainer c)
A pre-hook for the add method, before a container gets added to the internal list.protected TimeseriesContainer
preSet(int index, TimeseriesContainer c)
A pre-hook for the set method, before the container replaces the item currently occupying the position.C
remove(int index)
Removes the container at the specified position.void
setColorProvider(ColorProvider value)
Sets the color provider to use.void
setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.void
setReloadable(boolean value)
Sets whether the timeseries are reloadable (from the database) or not.void
setVisible(int index, boolean visible)
Sets the specified container's visibility.TimeseriesContainer
updateName(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:
getDatabaseConnection
in interfaceDatabaseConnectionProvider
- Returns:
- the current object
-
setDatabaseConnection
public void setDatabaseConnection(AbstractDatabaseConnection value)
Sets the database connection object to use.- Specified by:
setDatabaseConnection
in 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:
setColorProvider
in interfaceColorContainerManager<C extends TimeseriesContainer>
- Parameters:
value
- the color provider
-
getColorProvider
public ColorProvider getColorProvider()
Returns the color provider to use.- Specified by:
getColorProvider
in interfaceColorContainerManager<C extends TimeseriesContainer>
- Returns:
- the color provider in use
-
getColor
public Color getColor(TimeseriesContainer cont)
Returns the color for the container.- Specified by:
getColor
in 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:
clear
in 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:
postAdd
in 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:
remove
in 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:
getUniqueName
in 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:
updateName
in 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:
newContainer
in 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:
preAdd
in 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:
preSet
in 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:
isVisible
in 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:
setVisible
in 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:
getVisible
in 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:
countVisible
in 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:
indexOf
in 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:
getVisibleIndices
in 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:
getAllVisible
in 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:
isMatch
in classAbstractContainerManager<C extends TimeseriesContainer>
- Parameters:
cont
- the container to checksearch
- the search stringregExp
- whether to perform regular expression matching
-
-