com.sun.electric.database.text
Class Pref

java.lang.Object
  extended by com.sun.electric.database.text.Pref

public class Pref
extends java.lang.Object

This class manages appearance options. There are two types of options: appearance and meaning. Appearance options affect the way that the design is presented to the user. Examples are grid dot spacing, layer stipple patterns, etc. Meaning options affect the way that a design is produced (for fabrication, simulation, and other outputs). Examples are CIF layer names, technology options, etc.) Meaning options are managed by Setting class now.

Some Prefs can be used in server Jobs, other are client only. Server Prefs are created by special factory methods during Electric initialization. They can't be created later.

All options are saved in a machine-specific way by the Java Preferences class. In addition, "meaning" options are stored in libraries. When the libraries are read back into Electric, the stored meaning options are checked against the current meaning options, the two are reconciled.

Where are these options stored? It varies with each operating system.


Nested Class Summary
static class Pref.Group
           
 
Field Summary
static boolean FROM_THREAD_ENVIRONMENT
           
 
Constructor Summary
protected Pref(Pref.Group group, java.lang.String name, boolean serverAccessible, java.lang.Object factoryObj)
          The constructor for the Pref.
 
Method Summary
static void delayPrefFlushing()
          Method to delay the saving of preferences to disk.
static void exportPrefs(java.lang.String fileName)
          Method to export the preferences to an XML file.
static void exportPrefs(java.lang.String fileName, java.util.prefs.Preferences prefRoot)
          Method to export the preferences to an XML file.
 void factoryReset()
          Method to reset Pref value to factory default.
static void flushAll()
          Method to immediately flush all Electric preferences to disk.
static void forbidPreferences()
           
static java.util.Collection<Pref.Group> getAllGroups()
           
 boolean getBoolean()
          Method to get the boolean value on this Pref object.
 boolean getBoolean(java.util.prefs.Preferences prefRoot)
          Method to get the boolean value on this Pref object.
 boolean getBooleanFactoryValue()
          Method to get the factory-default boolean value of this Pref object.
 double getDouble()
          Method to get the double value on this Pref object.
 double getDouble(java.util.prefs.Preferences prefRoot)
          Method to get the double value on this Pref object.
 double getDoubleFactoryValue()
          Method to get the factory-default double value of this Pref object.
static java.util.prefs.Preferences getFactoryPrefRoot()
          Returns the root of dummy Preferences subtree with factory default Electric options.
 java.lang.Object getFactoryValue()
          Method to get the factory-default value of this Pref object.
 int getInt()
          Method to get the integer value on this Pref object.
 int getInt(java.util.prefs.Preferences prefRoot)
          Method to get the integer value on this Pref object.
 int getIntFactoryValue()
          Method to get the factory-default integer value of this Pref object.
static java.util.prefs.Preferences getLibraryPreferences(LibId libId)
          Returns the root of Preferences subtree with Electric options for a specified LibId.
 long getLong()
          Method to get the long value on this Pref object.
 long getLong(java.util.prefs.Preferences prefRoot)
          Method to get the long value on this Pref object.
 long getLongFactoryValue()
          Method to get the factory-default long value of this Pref object.
 java.lang.String getPrefName()
          Method to get the name of this Pref object.
 java.lang.String getPrefPath()
          Method to get the pref name of this Pref object.
static java.util.prefs.Preferences getPrefRoot()
          Returns the root of Preferences subtree with Electric options.
 java.lang.String getString()
          Method to get the string value on this Pref object.
 java.lang.String getString(java.util.prefs.Preferences prefRoot)
          Method to get the string value on this Pref object.
 java.lang.String getStringFactoryValue()
          Method to get the factory-default String value of this Pref object.
 java.lang.Object getValue()
          Method to get the value of this Pref object as an Object.
 java.lang.Object getValue(java.util.prefs.Preferences prefRoot)
           
static Pref.Group groupForPackage(java.lang.Class classFromPackage)
           
static Pref.Group groupForPackage(java.lang.String relativePath)
           
static void importPrefs(java.net.URL fileURL)
           
static void lockCreation()
          Currently Setting can be created only at initialization phase.
static Pref makeBooleanPref(java.lang.String name, Pref.Group group, boolean factory)
          Factory methods to create a boolean Pref objects.
static Pref makeBooleanServerPref(java.lang.String name, Pref.Group group, boolean factory)
          Factory methods to create a boolean Pref objects.
static Pref makeDoublePref(java.lang.String name, Pref.Group group, double factory)
          Factory methods to create a double Pref objects.
static Pref makeIntPref(java.lang.String name, Pref.Group group, int factory)
          Factory methods to create an integer Pref objects.
static Pref makeIntServerPref(java.lang.String name, Pref.Group group, int factory)
          Factory methods to create an integer Pref objects.
static Pref makeLongPref(java.lang.String name, Pref.Group group, long factory)
          Factory methods to create a long Pref objects.
static Pref makeStringPref(java.lang.String name, Pref.Group group, java.lang.String factory)
          Factory methods to create a string Pref objects.
static Pref makeStringServerPref(java.lang.String name, Pref.Group group, java.lang.String factory)
          Factory methods to create a string Pref objects.
 void putBoolean(java.util.prefs.Preferences prefRoot, boolean removeDefaults, boolean v)
          Method to set a new boolean value on this Pref object.
 void putDouble(java.util.prefs.Preferences prefRoot, boolean removeDefaults, double v)
          Method to set a new double value on this Pref object.
 void putInt(java.util.prefs.Preferences prefRoot, boolean removeDefaults, int v)
          Method to set a new integer value on this Pref object.
 void putLong(java.util.prefs.Preferences prefRoot, boolean removeDefaults, long v)
          Method to set a new long value on this Pref object.
 void putString(java.util.prefs.Preferences prefRoot, boolean removeDefaults, java.lang.String str)
          Method to set a new string value on this Pref object.
static void resumePrefFlushing()
          Method to resume the saving of preferences to disk.
 void setBoolean(boolean v)
          Method to set a new boolean value on this Pref object.
static void setCachedObjsFromPreferences()
           
 void setDouble(double v)
          Method to set a new double value on this Pref object.
 void setInt(int v)
          Method to set a new integer value on this Pref object.
 void setLong(long v)
          Method to set a new long value on this Pref object.
 void setString(java.lang.String str)
          Method to set a new string value on this Pref object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FROM_THREAD_ENVIRONMENT

public static final boolean FROM_THREAD_ENVIRONMENT
See Also:
Constant Field Values
Constructor Detail

Pref

protected Pref(Pref.Group group,
               java.lang.String name,
               boolean serverAccessible,
               java.lang.Object factoryObj)
The constructor for the Pref.

Parameters:
name - the name of this Pref.
Method Detail

groupForPackage

public static Pref.Group groupForPackage(java.lang.Class classFromPackage)

groupForPackage

public static Pref.Group groupForPackage(java.lang.String relativePath)

lockCreation

public static void lockCreation()
Currently Setting can be created only at initialization phase. This method forbids further cration of Settings.


forbidPreferences

public static void forbidPreferences()

setCachedObjsFromPreferences

public static void setCachedObjsFromPreferences()

importPrefs

public static void importPrefs(java.net.URL fileURL)

exportPrefs

public static void exportPrefs(java.lang.String fileName)
Method to export the preferences to an XML file. This function is public due to the regressions.

Parameters:
fileName - the file to write.

exportPrefs

public static void exportPrefs(java.lang.String fileName,
                               java.util.prefs.Preferences prefRoot)
Method to export the preferences to an XML file. This function is public due to the regressions.

Parameters:
fileName - the file to write.

makeBooleanPref

public static Pref makeBooleanPref(java.lang.String name,
                                   Pref.Group group,
                                   boolean factory)
Factory methods to create a boolean Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeIntPref

public static Pref makeIntPref(java.lang.String name,
                               Pref.Group group,
                               int factory)
Factory methods to create an integer Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeLongPref

public static Pref makeLongPref(java.lang.String name,
                                Pref.Group group,
                                long factory)
Factory methods to create a long Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeDoublePref

public static Pref makeDoublePref(java.lang.String name,
                                  Pref.Group group,
                                  double factory)
Factory methods to create a double Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeStringPref

public static Pref makeStringPref(java.lang.String name,
                                  Pref.Group group,
                                  java.lang.String factory)
Factory methods to create a string Pref objects.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeBooleanServerPref

public static Pref makeBooleanServerPref(java.lang.String name,
                                         Pref.Group group,
                                         boolean factory)
Factory methods to create a boolean Pref objects. The Pref is accessible from server Jobs.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeIntServerPref

public static Pref makeIntServerPref(java.lang.String name,
                                     Pref.Group group,
                                     int factory)
Factory methods to create an integer Pref objects. The Pref is accessible from server Jobs.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

makeStringServerPref

public static Pref makeStringServerPref(java.lang.String name,
                                        Pref.Group group,
                                        java.lang.String factory)
Factory methods to create a string Pref objects. The Pref is accessible from server Jobs.

Parameters:
name - the name of this Pref.
group - group of preferences to which a new Pref belongs
factory - the "factory" default value (if nothing is stored).

getBoolean

public boolean getBoolean()
Method to get the boolean value on this Pref object. The object must have been created as "boolean".

Returns:
the boolean value on this Pref object.

getInt

public int getInt()
Method to get the integer value on this Pref object. The object must have been created as "integer".

Returns:
the integer value on this Pref object.

getLong

public long getLong()
Method to get the long value on this Pref object. The object must have been created as "long".

Returns:
the long value on this Pref object.

getDouble

public double getDouble()
Method to get the double value on this Pref object. The object must have been created as "double".

Returns:
the double value on this Pref object.

getString

public java.lang.String getString()
Method to get the string value on this Pref object. The object must have been created as "string".

Returns:
the string value on this Pref object.

getBoolean

public boolean getBoolean(java.util.prefs.Preferences prefRoot)
Method to get the boolean value on this Pref object. The object must have been created as "boolean".

Parameters:
prefRoot - root Preferences node
Returns:
the boolean value on this Pref object.

getInt

public int getInt(java.util.prefs.Preferences prefRoot)
Method to get the integer value on this Pref object. The object must have been created as "integer".

Parameters:
prefRoot - root Preferences node
Returns:
the integer value on this Pref object.

getLong

public long getLong(java.util.prefs.Preferences prefRoot)
Method to get the long value on this Pref object. The object must have been created as "long".

Parameters:
prefRoot - root Preferences node
Returns:
the long value on this Pref object.

getDouble

public double getDouble(java.util.prefs.Preferences prefRoot)
Method to get the double value on this Pref object. The object must have been created as "double".

Parameters:
prefRoot - root Preferences node
Returns:
the double value on this Pref object.

getString

public java.lang.String getString(java.util.prefs.Preferences prefRoot)
Method to get the string value on this Pref object. The object must have been created as "string".

Parameters:
prefRoot - root Preferences node
Returns:
the string value on this Pref object.

getFactoryValue

public java.lang.Object getFactoryValue()
Method to get the factory-default value of this Pref object.

Returns:
the factory-default value of this Pref object.

getBooleanFactoryValue

public boolean getBooleanFactoryValue()
Method to get the factory-default boolean value of this Pref object.

Returns:
the factory-default boolean value of this Pref object.

getIntFactoryValue

public int getIntFactoryValue()
Method to get the factory-default integer value of this Pref object.

Returns:
the factory-default integer value of this Pref object.

getLongFactoryValue

public long getLongFactoryValue()
Method to get the factory-default long value of this Pref object.

Returns:
the factory-default long value of this Pref object.

getDoubleFactoryValue

public double getDoubleFactoryValue()
Method to get the factory-default double value of this Pref object.

Returns:
the factory-default double value of this Pref object.

getStringFactoryValue

public java.lang.String getStringFactoryValue()
Method to get the factory-default String value of this Pref object.

Returns:
the factory-default String value of this Pref object.

getPrefName

public java.lang.String getPrefName()
Method to get the name of this Pref object.

Returns:
the name of this Pref object.

getPrefPath

public java.lang.String getPrefPath()
Method to get the pref name of this Pref object.

Returns:
the name of this Setting object.

getValue

public java.lang.Object getValue()
Method to get the value of this Pref object as an Object. The proper way to get the current value is to use one of the type-specific methods such as getInt(), getBoolean(), etc.

Returns:
the Object value of this Pref object.

getValue

public java.lang.Object getValue(java.util.prefs.Preferences prefRoot)

delayPrefFlushing

public static void delayPrefFlushing()
Method to delay the saving of preferences to disk. Since individual saving is time-consuming, batches of preference changes are wrapped with this, and "resumePrefFlushing()".


resumePrefFlushing

public static void resumePrefFlushing()
Method to resume the saving of preferences to disk. Since individual saving is time-consuming, batches of preference changes are wrapped with this, and "resumePrefFlushing()". Besides resuming saving, this method also saves anything queued while saving was delayed.


getPrefRoot

public static java.util.prefs.Preferences getPrefRoot()
Returns the root of Preferences subtree with Electric options. Currently this is "/com/sun/electric/" subtree.

Returns:
the root of Preferences subtree with Electric options.

getLibraryPreferences

public static java.util.prefs.Preferences getLibraryPreferences(LibId libId)
Returns the root of Preferences subtree with Electric options for a specified LibId.

Parameters:
libId - specified LibId
Returns:
the root of Preferences subtree with Electric options for a spiceified LibId.

getFactoryPrefRoot

public static java.util.prefs.Preferences getFactoryPrefRoot()
Returns the root of dummy Preferences subtree with factory default Electric options.

Returns:
the root of Preferences subtree with factory default Electric options.

flushAll

public static void flushAll()
Method to immediately flush all Electric preferences to disk.


setBoolean

public void setBoolean(boolean v)
Method to set a new boolean value on this Pref object.

Parameters:
v - the new boolean value of this Pref object.

setInt

public void setInt(int v)
Method to set a new integer value on this Pref object.

Parameters:
v - the new integer value of this Pref object.

setLong

public void setLong(long v)
Method to set a new long value on this Pref object.

Parameters:
v - the new long value of this Pref object.

setDouble

public void setDouble(double v)
Method to set a new double value on this Pref object.

Parameters:
v - the new double value of this Pref object.

setString

public void setString(java.lang.String str)
Method to set a new string value on this Pref object.

Parameters:
str - the new string value of this Pref object.

putBoolean

public void putBoolean(java.util.prefs.Preferences prefRoot,
                       boolean removeDefaults,
                       boolean v)
Method to set a new boolean value on this Pref object.

Parameters:
v - the new boolean value of this Pref object.

putInt

public void putInt(java.util.prefs.Preferences prefRoot,
                   boolean removeDefaults,
                   int v)
Method to set a new integer value on this Pref object.

Parameters:
v - the new integer value of this Pref object.

putLong

public void putLong(java.util.prefs.Preferences prefRoot,
                    boolean removeDefaults,
                    long v)
Method to set a new long value on this Pref object.

Parameters:
v - the new long value of this Pref object.

putDouble

public void putDouble(java.util.prefs.Preferences prefRoot,
                      boolean removeDefaults,
                      double v)
Method to set a new double value on this Pref object.

Parameters:
v - the new double value of this Pref object.

putString

public void putString(java.util.prefs.Preferences prefRoot,
                      boolean removeDefaults,
                      java.lang.String str)
Method to set a new string value on this Pref object.

Parameters:
str - the new string value of this Pref object.

factoryReset

public void factoryReset()
Method to reset Pref value to factory default.


getAllGroups

public static java.util.Collection<Pref.Group> getAllGroups()