⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setting.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: Setting.java * * Copyright (c) 2007 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.database.text;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.hierarchy.EDatabase;import com.sun.electric.tool.user.projectSettings.ProjSettings;import java.io.PrintStream;import java.io.Serializable;import java.util.Collection;import java.util.Comparator;import java.util.HashMap;import java.util.HashSet;import java.util.Map;import java.util.TreeMap;import java.util.prefs.Preferences;/** * */public class Setting {    private static final HashMap<String,Setting> allSettingsByXmlPath = new HashMap<String,Setting>();    private static final HashMap<String,Setting> allSettingsByPrefPath = new HashMap<String,Setting>();//    private final ProjSettingsNode xmlNode;//    private final String xmlName;    private final String xmlPath;	private final Object factoryObj;    private Object currentObj;    private final Preferences prefs;    private final String prefName;    private final String prefPath;    private boolean valid;    private final String description, location;    private String [] trueMeaning;    /** Creates a new instance of Setting */    public Setting(String prefName, Pref.Group group, String xmlNode, String xmlName, String location, String description, Object factoryObj) {        EDatabase.serverDatabase().checkChanging();        if (xmlNode == null)            throw new NullPointerException();//        this.xmlNode = xmlNode;        if (xmlName == null)            xmlName = prefName;//        this.xmlName = xmlName;        xmlPath = xmlNode + xmlName;        assert !allSettingsByXmlPath.containsKey(xmlPath);        this.factoryObj = factoryObj;        currentObj = factoryObj;        this.prefName = prefName;        prefs = group.preferences;        prefPath = prefs.absolutePath() + "/" + prefName;        assert !allSettingsByPrefPath.containsKey(prefPath);        allSettingsByXmlPath.put(xmlPath, this);        allSettingsByPrefPath.put(prefPath, this);        assert allSettingsByXmlPath.size() == allSettingsByPrefPath.size();        valid = true;        this.description = description;        this.location = location;        setCachedObjFromPreferences();        ProjSettings.putValue(this);//        xmlNode.putValue(xmlName, this);    }    /**     * Method to get the boolean value on this Setting object.     * The object must have been created as "boolean".     * @return the boolean value on this TechSetting object.     */    public boolean getBoolean() { return ((Boolean)getValue()).booleanValue(); }    /**     * Method to get the integer value on this Setting object.     * The object must have been created as "integer".     * @return the integer value on this TechSetting object.     */    public int getInt() { return ((Integer)getValue()).intValue(); }    /**     * Method to get the long value on this Setting object.     * The object must have been created as "long".     * @return the long value on this TechSetting object.     */    public long getLong() { return ((Long)getValue()).longValue(); }    /**     * Method to get the double value on this Setting object.     * The object must have been created as "double".     * @return the double value on this TechSetting object.     */    public double getDouble() { return ((Double)getValue()).doubleValue(); }    /**     * Method to get the string value on this Setting object.     * The object must have been created as "string".     * @return the string value on this TechSetting object.     */    public String getString() { return (String)getValue(); }    public void set(Object v) {//        if (changeBatch != null) {//            if (SwingUtilities.isEventDispatchThread()) {//                if (!v.equals(getValue()))//                    changeBatch.add(this, v);//                return;//            }//            changeBatch = null;//        }        EDatabase.serverDatabase().checkChanging();        if (getValue().equals(v)) return;        if (v.getClass() != factoryObj.getClass())            throw new ClassCastException();        currentObj = factoryObj.equals(v) ? factoryObj : v;        saveToPreferences(v);        setSideEffect();    }    /**	 * Method called when this Pref is changed.	 * This method is overridden in subclasses that want notification.	 */    protected void setSideEffect() {    }     /**     * Method to get the xml name of this Setting object.     * @return the xml name of this Setting object.     */    public String getXmlPath() { return xmlPath; }   /**     * Method to get the name of this Setting object.     * @return the name of this Setting object.     */    public String getPrefName() { return prefName; }	/**	 * Method to get the value of this Setting 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.	 * @return the Object value of this Setting object.	 */	public Object getValue() {//        if (changeBatch != null) {//            if (SwingUtilities.isEventDispatchThread()) {//                Object pendingChange = changeBatch.changesForSettings.get(this);//                if (pendingChange != null)//                    return pendingChange;//            }//        }        return currentObj;    }    /**     * Method to return the user-command that can affect this Meaning option.     * @return the user-command that can affect this Meaning option.     */    public String getLocation() { return location; }    /**     * Method to return the description of this Meaning option.     * @return the Pref description of this Meaning option.     */    public String getDescription() { return description; }    /**     * Method to set whether this Meaning option is valid and should be reconciled.     * Some should not, for example, the scale value on technologies that     * don't use scaling (such as Schematics, Artwork, etc.)     * @param valid true if this Meaning option is valid and should be reconciled.     */    public void setValidOption(boolean valid) { this.valid = valid; }    /**     * Method to tell whether this Meaning option is valid and should be reconciled.     * Some should not, for example, the scale value on technologies that     * don't use scaling (such as Schematics, Artwork, etc.)     * @return true if this Meaning option is valid and should be reconciled.     */    public boolean isValidOption() { return valid; }    /**     * Method to associate an array of strings to be used for integer Meaning options.     * @param trueMeaning the array of strings that should be used for this integer Meaning option.     * Some options are multiple-choice, for example the MOSIS CMOS rule set which can be     * 0, 1, or 2 depending on whether the set is SCMOS, Submicron, or Deep.     * By giving an array of 3 strings to this method, a proper description of the option     * can be given to the user.     */    public void setTrueMeaning(String [] trueMeaning) { this.trueMeaning = trueMeaning; }    /**     * Method to return an array of strings to be used for integer Meaning options.     * Some options are multiple-choice, for example the MOSIS CMOS rule set which can be     * 0, 1, or 2 depending on whether the set is SCMOS, Submicron, or Deep.     * By giving an array of 3 strings to this method, a proper description of the option     * can be given to the user.     * @return the array of strings that should be used for this integer Meaning option.     */    public String [] getTrueMeaning() { return trueMeaning; }	/**	 * Method to get the factory-default value of this Pref object.	 * @return the factory-default value of this Pref object.	 */	public Object getFactoryValue() { return factoryObj; }	/**	 * Method to get the factory-default double value of this Pref object.	 * @return the factory-default double value of this Pref object.	 */	public double getDoubleFactoryValue() { return ((Double)factoryObj).doubleValue(); }	/**	 * Factory methods to create a boolean project setting objects.	 * @param name the name of this Pref.	 * @param group group of preferences to which a new Pref belongs	 * @param location the user-command that can affect this meaning option.	 * @param description the description of this meaning option.	 * @param factory the "factory" default value (if nothing is stored).	 */    public static Setting makeBooleanSetting(String name, Pref.Group group,                                          String xmlNode, String xmlName,                                          String location, String description, boolean factory) {        Setting setting = Setting.getSetting(xmlNode + xmlName);        if (setting != null) return setting;        return new Setting(name, group, xmlNode, xmlName, location, description, Boolean.valueOf(factory));    }	/**	 * Factory methods to create an integerproject setting objects.	 * @param name the name of this Pref.	 * @param group group of preferences to which a new Pref belongs	 * @param location the user-command that can affect this meaning option.	 * @param description the description of this meaning option.	 * @param factory the "factory" default value (if nothing is stored).	 */    public static Setting makeIntSetting(String name, Pref.Group group,                                      String xmlNode, String xmlName,                                      String location, String description, int factory) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -