Documentation of 'kcl.waterloo.defaults.GJDefaults' Java class
GJDefaults
kcl.waterloo.defaults

Class GJDefaults



  • public class GJDefaults
    extends java.lang.Object
    This class provides default values used during construction of Waterloo graphics objects. It is a singleton instance class.

    IMPORTANT: Relevant default values are saved in Waterloo XML files and the singleton instance of GJDefaults class is used as the owner of the XML encoder/decoder. The XML persistence delegate for this class ensures that values in the singleton instance are temporarily altered during de-serialization to reflect the map being used when a file was created. Care should be taken not to break the serialization/de-serialization code and to maintain backwards file compatibility when the key set or classes of the values for the key/value pairs is changed. Generally, that would require changes to the code in the relevant constructors and/or changes to the XML code.

    You can safely edit the default settings using the supplied GUIs.

    setMap and getMap methods use defensive copying and do not leak references to the internal hash maps.

    Note that these default entries will be used by reference so, generally, only immutable objects should be included here. Where exceptions to this rule are made remember that editing the object in one graph will affect all graphs. Mutable objects - such as number formatters - are included where that is likely to be the desired behaviour. To set mutable objects that affect only one Waterloo object, replace the default object with a new instance by calling the appropriate setter method on that instance after constructing the Waterloo object instance.

    The relevant values are:

    dataClass - This value is used when a plot data model is created. During serialization, the value is retrieved from the saved data rather than from the defaults table so the default value may be altered during a JVM session. The class must implement the <@code GJDataVectorInterface>.

    map - contains default values for various settings as a LinkedHashMap. The entire map is saved during serialization. On de-serialization - values from the map on file are temporarily copied into the default map.

    map2 - contains default values as a LinkedHashMap that are not serialized because they are not required or are not serializable or are platform/JVM-version specific and therefore not portable.

    De-serializing - Atomic boolean flag set true during de-serialization.

    Getters and setters for these are synchronized on the singleton instance of GJDefaults. The LinkedHashMap is copied and returned as a LinkedHashMap by getMap. Similarly, setMap requires a LinkedHashMap as input and will create a new LinkedHashMap from it. To replace entries in the current LinkedHashMap, use copyEntries which call putAll on the map.

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method and Description
      static void copyEntries(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
      Copies the value fields from the input to the internal map.
      static void editDefaults() 
      static java.lang.Class getDataClass()
      Provides a synchronized getter for the private static dataClass field
      static boolean getDeserializing() 
      static GJDefaults getInstance()
      Returns the singleton instance.
      static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap()
      Returns a copy of the defaults map.
      static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap2()
      Returns a copy of map2.
      static java.lang.String getPreferencesFolder() 
      static void setDataClass(java.lang.Class aDataClass)
      Provides a synchronized setter for the private static dataClass field
      static void setDeserializing(java.lang.Boolean flag) 
      static void setMap(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
      Replaces the internal map with a shallow copy of the input map.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getInstance

        public static GJDefaults getInstance()
        Returns the singleton instance. This is used in serialization to alter the state of the dataClass static field. The instance is used as the "owner" of the XML encoder/decoder.
        Returns:
        the singleton instance
      • setDeserializing

        public static void setDeserializing(java.lang.Boolean flag)
      • getDeserializing

        public static boolean getDeserializing()
      • getDataClass

        public static java.lang.Class getDataClass()
        Provides a synchronized getter for the private static dataClass field
        Returns:
        the dataClass
      • setDataClass

        public static void setDataClass(java.lang.Class aDataClass)
        Provides a synchronized setter for the private static dataClass field
        Parameters:
        aDataClass - the dataClass to set
      • getMap

        public static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap()
        Returns a copy of the defaults map.
        Returns:
        a LinkedHashMap
      • setMap

        public static void setMap(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
        Replaces the internal map with a shallow copy of the input map.
        Parameters:
        input - the LinkedHashMap to use.
      • copyEntries

        public static void copyEntries(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
        Copies the value fields from the input to the internal map. Key/value pairs present in the input but not the internal map will be duplicated in the internal map. When keys are present in both input and internal maps, the value in the input will replace the value in the internal map if, but only if, the class of the value in the internal map is assignable from the class of the value in the input.
        Parameters:
        input - a LinkedHashMap
      • getMap2

        public static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap2()
        Returns a copy of map2.
        Returns:
        copy of map2.
      • getPreferencesFolder

        public static java.lang.String getPreferencesFolder()
      • editDefaults

        public static void editDefaults()

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.