Package noaa.coastwatch.tools
Class ResourceManager
java.lang.Object
noaa.coastwatch.tools.ResourceManager
The
ResourceManager
class stores and retrieves
user-specific resources related to configuration settings,
palettes, overlays, and so on.- Since:
- 3.1.7
- Author:
- Peter Hollemans
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Checks any existing resources for recoverable problems.static void
copyStream
(InputStream input, OutputStream output, boolean doClose) Copies data from an input stream to an output stream.static List
Gets the list of OPeNDAP servers from the user-specified resources.static OverlayGroupManager
Gets an overlay group manager instance that reads overlays from the user-specific resources.static Preferences
Gets a preferences instance from the user-specific resources.static void
setOpendapList
(List opendapList) Sets the OPeNDAP server list using the specified list ofServerTableModel.Entry
objects.static void
setPreferences
(Preferences preferences) Sets the preferences using the specified object.static void
Sets up the user-specified OPeNDAP servers.static void
Sets up the user-specified overlays.static void
Sets up the user-specified palettes.static void
setupPalettes
(boolean create) Sets up the user-specified palettes.static void
Sets up the user-specified preferences.
-
Constructor Details
-
ResourceManager
public ResourceManager()
-
-
Method Details
-
setupPalettes
Sets up the user-specified palettes. If the palette resource directory does not exist, it is created depending on the specified creation flag. If the directory already exists and contains user-defined palettes, they are added to the palatte factory.- Parameters:
create
- true to create the diretory if it doesn't exist, or false to not create the directory.- Throws:
IOException
- if an error occurred setting up the palettes.- Since:
- 3.4.1
- See Also:
-
setupPalettes
Sets up the user-specified palettes. If the palette resource directory does not exist, it is created. Any user-defined palettes found in the directory are added to the palatte factory.- Throws:
IOException
- if an error occurred setting up the palettes.- See Also:
-
copyStream
public static void copyStream(InputStream input, OutputStream output, boolean doClose) throws IOException Copies data from an input stream to an output stream.- Parameters:
input
- the input stream to read.output
- the output stream to write.doClose
- true to close input and output after copying.- Throws:
IOException
- if an error occurred reading or writing data.
-
checkResources
Checks any existing resources for recoverable problems. If changes were made to the resources, a message is returned stating the changes, otherwise null is returned.- Returns:
- the result message or null for no results.
- Throws:
IOException
- if an error occurred checking the resources.
-
setupOverlays
Sets up the user-specified overlays. If the overlay resource directory does not exist, it is created and populated with default initial overlays.- Throws:
IOException
- if an error occurred setting up the overlays.
-
getOverlayManager
Gets an overlay group manager instance that reads overlays from the user-specific resources. User objects can keep up to date on the current list of groups by listening for change events from the overlay manager. -
setupPreferences
Sets up the user-specified preferences.- Throws:
IOException
- if an error occurred setting up the preferences.
-
setupOpendap
Sets up the user-specified OPeNDAP servers.- Throws:
IOException
- if an error occurred setting up the servers.
-
getOpendapList
Gets the list of OPeNDAP servers from the user-specified resources.- Returns:
- the list of
ServerTableModel.Entry
objects. - Throws:
RuntimeException
- if an error occurred setting up the initial list, or reading the list from disk.
-
setOpendapList
Sets the OPeNDAP server list using the specified list ofServerTableModel.Entry
objects. Subsequent calls togetOpendapList()
will return the new list. The list is also saved to the user-specified resources.- Throws:
RuntimeException
- if an error occurred writing the list to disk.
-
setPreferences
Sets the preferences using the specified object. Subsequent calls togetPreferences()
will return the new preferences. The preferences are also saved to the user-specified resources.- Throws:
RuntimeException
- if an error occurred writing the preferences to disk.
-
getPreferences
Gets a preferences instance from the user-specific resources. The same preferences will be returned each time this method is invoked so that user objects may share the preferences.- Throws:
RuntimeException
- if an error occurred setting up the initial preferences, or reading the preferences from disk.
-