public class GJDefaults
extends java.lang.Object
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.
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.
|
public static GJDefaults getInstance()
public static void setDeserializing(java.lang.Boolean flag)
public static boolean getDeserializing()
public static java.lang.Class getDataClass()
public static void setDataClass(java.lang.Class aDataClass)
aDataClass
- the dataClass to setpublic static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap()
public static void setMap(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
input
- the LinkedHashMappublic static void copyEntries(java.util.LinkedHashMap<java.lang.String,java.lang.Object> input)
input
- a LinkedHashMappublic static java.util.LinkedHashMap<java.lang.String,java.lang.Object> getMap2()
public static java.lang.String getPreferencesFolder()
public static void editDefaults()