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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringChecks any existing resources for recoverable problems.static voidcopyStream(InputStream input, OutputStream output, boolean doClose) Copies data from an input stream to an output stream.static ListGets the list of OPeNDAP servers from the user-specified resources.static OverlayGroupManagerGets an overlay group manager instance that reads overlays from the user-specific resources.static PreferencesGets a preferences instance from the user-specific resources.static voidRestores the default initial overlays.static voidsetOpendapList(List opendapList) Sets the OPeNDAP server list using the specified list ofServerTableModel.Entryobjects.static voidsetPreferences(Preferences preferences) Sets the preferences using the specified object.static voidSets up the user-specified OPeNDAP servers.static voidSets up the user-specified overlays.static voidSets up the user-specified palettes.static voidsetupPalettes(boolean create) Sets up the user-specified palettes.static voidSets up the user-specified preferences.static voidShows the user resources directory in the OS native file explorer.
-
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.
-
restoreOverlays
Restores the default initial overlays. The user resource directory must already exist.- Throws:
IOException- if an error occurred restoring the overlays.- Since:
- 3.8.1
-
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.Entryobjects. - 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.Entryobjects. 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.
-
showResourcesDirectory
Shows the user resources directory in the OS native file explorer.- Throws:
IOException- Since:
- 3.8.1
-