Class ViewerPropertiesManager


  • public final class ViewerPropertiesManager
    extends Object

    This class provides a wrapper for persisting the viewer ri's settings. The class also provides mechanisms for loading default properties. The class is divided into two sub concepts; the first being local properties (not sticky) that are only persisted by command and the second being a preferences object that automatically saves values (sticky).

    Local Properties The SwingViewBuilder uses local properties to build the AWT Viewer. The viewer will always have a default state which can be altered with the checkAndStore*Property() methods. A given viewer configuration state can be persisted to the preference object with a call to saveStoreProperties(). Once local properties are persisted the only way to restore the default state is to call clearPreferences() or configure a customer ICEpdfDefault.properties file.

    Preferences The preferences object can be directly accessed via the accessor to directly access the preference api.

    Default Properties The default viewer ri ships with a ICEpdfDefault.properties file that can be used to load default viewer properties for custom builds. This mechanism can be easier to implement then manually manipulating the PropertyManagers before the a swing view is created.

    Since:
    6.3
    • Method Detail

      • getInstance

        public static ViewerPropertiesManager getInstance()
        Gets singleton instance of the Properties manager instance.
        Returns:
        singleton instance.
      • printAllProperties

        public static void printAllProperties()
        Prints all the preferences and properties. Can be used to see discrepancies.
      • getPreferences

        public Preferences getPreferences()
        Gets the Preferences backing store for persisting static properties and settings.
        Returns:
        reference to the application preferences backing store.
      • set

        public void set​(String propertyName,
                        String value)
        Sets the local property over writing any previous value stored in the default properties file.
        Parameters:
        propertyName - name of property to write.
        value - property value.
      • remove

        public void remove​(String propertyName)
        Removes the
      • saveLocalProperties

        public static void saveLocalProperties()
        All of the properties that are stored in the local properties can be persisted to the backing store via this method call. The local properties are stored via the checkAndStore*() method calls and should only be used when configuring the viewer components functionality. Once these properties have been persisted they are now sticky and will persist for all viewer instances.
      • setDouble

        public void setDouble​(String propertyName,
                              double value)
        Sets the local double property over writing any previous value stored in the default properties file.
        Parameters:
        propertyName - name of property to write.
        value - property value.
      • setFloat

        public void setFloat​(String propertyName,
                             float value)
        Sets the local float property over writing any previous value stored in the default properties file.
        Parameters:
        propertyName - name of property to write.
        value - property value.
      • setInt

        public void setInt​(String propertyName,
                           int value)
        Sets the local integer property over writing any previous value stored in the default properties file.
        Parameters:
        propertyName - name of property to write.
        value - property value.
      • setBoolean

        public void setBoolean​(String propertyName,
                               boolean value)
        Sets the local boolean property over writing any previous value stored in the default properties file.
        Parameters:
        propertyName - name of property to write.
        value - property value.
      • checkAndStoreStringProperty

        public String checkAndStoreStringProperty​(String propertyName,
                                                  String defaultVal)
        Method to check the value of a string property This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        String value for the propertyName or defaultVal if none exists.
      • checkAndStoreBooleanProperty

        public boolean checkAndStoreBooleanProperty​(String propertyName)
      • checkAndStoreBooleanProperty

        public boolean checkAndStoreBooleanProperty​(String propertyName,
                                                    boolean defaultVal)
        Method to check the value of a boolean property This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        true if property is true, otherwise false
      • checkAndStoreDoubleProperty

        public double checkAndStoreDoubleProperty​(String propertyName)
      • checkAndStoreDoubleProperty

        public double checkAndStoreDoubleProperty​(String propertyName,
                                                  double defaultVal)
        Method to check the value of a double property This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        double property value
      • checkAndStoreIntProperty

        public int checkAndStoreIntProperty​(String propertyName)
      • checkAndStoreIntProperty

        public int checkAndStoreIntProperty​(String propertyName,
                                            int defaultVal)
        Method to check the value of an int property This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        int value of property
      • checkAndStoreFloatProperty

        public float checkAndStoreFloatProperty​(String propertyName)
      • checkAndStoreFloatProperty

        public float checkAndStoreFloatProperty​(String propertyName,
                                                float defaultVal)
        Method to check the value of an int property This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        int value of property
      • checkAndStoreFloatArrayProperty

        public float[] checkAndStoreFloatArrayProperty​(String propertyName,
                                                       float[] defaultVal)
        Method to check the value of a comma separate list of floats property For example we will convert "0.4f, 0.5f, 0.6f" to a size 3 array with the values as floats This is meant to be used for configuration via the properties file After the property has been checked, it will be stored back into the Properties object (using a default value if none was found)
        Parameters:
        propertyName - to check for
        defaultVal - to default to if no value is found on a property
        Returns:
        array of floats from the property
      • getLookAndFeel

        public String getLookAndFeel​(String propertyName,
                                     String defaultValue,
                                     ResourceBundle messageBundle)
        Allows users to set the default look and feel of the
        Parameters:
        propertyName - look and feel class and package name.
        defaultValue - default value
        messageBundle - message bundle.
        Returns:
        class name used to set the look and feel
      • clearPreferences

        public void clearPreferences()
        This utility method removes all entries in the preferences backing store. This method does not remove the preferences node and thus the font manager font cache is unaffected.
      • importPreferences

        public static boolean importPreferences​(File xml)
      • exportPreferences

        public static boolean exportPreferences​(File xml)
      • importProperties

        public static boolean importProperties​(File file)
      • exportProperties

        public static boolean exportProperties​(File file)