Class ResourceManager

java.lang.Object
noaa.coastwatch.tools.ResourceManager

public class ResourceManager extends Object
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 Details

    • ResourceManager

      public ResourceManager()
  • Method Details

    • setupPalettes

      public static void setupPalettes(boolean create) throws IOException
      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

      public static void setupPalettes() throws IOException
      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

      public static String checkResources() throws IOException
      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

      public static void restoreOverlays() throws IOException
      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

      public static void setupOverlays() throws IOException
      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

      public static OverlayGroupManager 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

      public static void setupPreferences() throws IOException
      Sets up the user-specified preferences.
      Throws:
      IOException - if an error occurred setting up the preferences.
    • setupOpendap

      public static void setupOpendap() throws IOException
      Sets up the user-specified OPeNDAP servers.
      Throws:
      IOException - if an error occurred setting up the servers.
    • getOpendapList

      public static List 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

      public static void setOpendapList(List opendapList)
      Sets the OPeNDAP server list using the specified list of ServerTableModel.Entry objects. Subsequent calls to getOpendapList() 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

      public static void setPreferences(Preferences preferences)
      Sets the preferences using the specified object. Subsequent calls to getPreferences() 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

      public static Preferences 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

      public static void showResourcesDirectory() throws IOException
      Shows the user resources directory in the OS native file explorer.
      Throws:
      IOException
      Since:
      3.8.1