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

📄 iotool.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: IOTool.java * * Copyright (c) 2003 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.tool.io;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.text.Pref;import com.sun.electric.database.text.Setting;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.variable.Variable;import com.sun.electric.tool.Tool;import java.lang.reflect.Method;import java.net.URL;import java.util.Date;/** * This class manages reading files in different formats. * The class is subclassed by the different file readers. */public class IOTool extends Tool{	/** the IO tool. */										private static IOTool tool = new IOTool();	/** Varible key for true library of fake cell. */		public static final Variable.Key IO_TRUE_LIBRARY = Variable.newKey("IO_true_library");	// ---------------------- private and protected methods -----------------	/**	 * The constructor sets up the I/O tool.	 */	protected IOTool()	{		super("io");	}	/**	 * Method to retrieve the singleton associated with the IOTool tool.	 * @return the IOTool tool.	 */	public static IOTool getIOTool() { return tool; }	/****************************** SKILL FORMAT INTERFACE ******************************/	private static boolean skillChecked = false;	private static Class<?> skillClass = null;	private static Method skillOutputMethod;	/**	 * Method to tell whether Skill output is available.	 * Skill is a proprietary format of Cadence, and only valid licensees are given this module.	 * This method dynamically figures out whether the Skill module is present by using reflection.	 * @return true if the Skill output module is available.	 */	public static boolean hasSkill()	{		if (!skillChecked)		{			skillChecked = true;			// find the Skill class			try			{				skillClass = Class.forName("com.sun.electric.plugins.skill.Skill");			} catch (ClassNotFoundException e)			{				skillClass = null;				return false;			}			// find the necessary method on the Skill class			try			{				skillOutputMethod = skillClass.getMethod("writeSkillFile", new Class[] {Cell.class, String.class, Boolean.class});			} catch (NoSuchMethodException e)			{				skillClass = null;				return false;			}		}		// if already initialized, return		if (skillClass == null) return false;	 	return true;	}	/**	 * Method to invoke the Skill output module via reflection.	 * @param cell the Cell to write in Skill.	 * @param fileName the name of the file to write.	 */	public static void writeSkill(Cell cell, String fileName, boolean exportsOnly)	{		if (!hasSkill()) return;		try		{			skillOutputMethod.invoke(skillClass, new Object[] {cell, fileName, Boolean.valueOf(exportsOnly)});		} catch (Exception e)		{			System.out.println("Unable to run the Skill output module");			e.printStackTrace(System.out);		}	}	/****************************** DAIS FORMAT INTERFACE ******************************/	private static boolean daisChecked = false;	private static Class<?> daisClass = null;	private static Method daisInputMethod;	/**	 * Method to tell whether Dais input is available.	 * Dais is a proprietary format of Sun Microsystems.	 * This method dynamically figures out whether the Dais module is present by using reflection.	 * @return true if the Dais input module is available.	 */	public static boolean hasDais()	{		if (!daisChecked)		{			daisChecked = true;			// find the Dais class			try			{				daisClass = Class.forName("com.sun.electric.plugins.dais.Dais");			} catch (ClassNotFoundException e)			{				daisClass = null;				return false;			}			// find the necessary method on the Dais class			try			{				daisInputMethod = daisClass.getMethod("readDaisFile", new Class[] {URL.class, Library.class, boolean.class});			} catch (NoSuchMethodException e)			{				daisClass = null;				return false;			}		}		// if already initialized, return		if (daisClass == null) return false;	 	return true;	}	/**	 * Method to invoke the Dais input module via reflection.	 * @param lib the Library to read.	 */	public static void readDais(URL url, Library lib, boolean newLib)	{		if (!hasDais()) return;		try		{			daisInputMethod.invoke(daisClass, new Object[] {url, lib, Boolean.valueOf(newLib)});		} catch (Exception e)		{			System.out.println("Unable to run the Dais input module (" + e.getClass() + ")");			e.printStackTrace(System.out);		}	}	@Override	protected void initProjectSettings() {		initGeneralOutputProjectSettings();		initCIFProjectSettings();		initGDSProjectSettings();		initDXFProjectSettings();	}	/****************************** GENERAL IO PREFERENCES ******************************/	private static Pref cacheBackupRedundancy = Pref.makeIntPref("OutputBackupRedundancy", IOTool.tool.prefs, 0);	/**	 * Method to tell what kind of redundancy to apply when writing library files.	 * The value is:	 * 0 for no backup (just overwrite the old file) [the default];	 * 1 for 1-level backup (rename the old file to have a "~" at the end);	 * 2 for full history backup (rename the old file to have date information in it).	 * @return the level of redundancy to apply when writing library files.	 */	public static int getBackupRedundancy() { return cacheBackupRedundancy.getInt(); }	/**	 * Method to set the level of redundancy to apply when writing library files.	 * The value is:	 * 0 for no backup (just overwrite the old file);	 * 1 for 1-level backup (rename the old file to have a "~" at the end);	 * 2 for full history backup (rename the old file to have date information in it).	 * @param r the level of redundancy to apply when writing library files.	 */	public static void setBackupRedundancy(int r) { cacheBackupRedundancy.setInt(r); }	/**	 * Method to tell what kind of redundancy to apply when writing library files, by default.	 * The value is:	 * 0 for no backup (just overwrite the old file) [the default];	 * 1 for 1-level backup (rename the old file to have a "~" at the end);	 * 2 for full history backup (rename the old file to have date information in it).	 * @return the level of redundancy to apply when writing library files, by default.	 */	public static int getFactoryBackupRedundancy() { return cacheBackupRedundancy.getIntFactoryValue(); }	/****************************** GENERAL OUTPUT PREFERENCES ******************************/	/**	 * Method to tell whether to add the copyright message to output decks.	 * The default is "false".	 * @return true to add the copyright message to output decks.	 */	public static boolean isUseCopyrightMessage() { return tool.cacheUseCopyrightMessage.getBoolean(); }	/**	 * Returns project Setting to tell whether to add the copyright message to output decks.	 * @return project Setting to tell whether to add the copyright message to output decks.	 */	public static Setting getUseCopyrightMessageSetting() { return tool.cacheUseCopyrightMessage; }	/**	 * Method to tell the copyright message that will be added to output decks.	 * The default is "".	 * @return the copyright message that will be added to output decks.	 */	public static String getCopyrightMessage() { return tool.cacheCopyrightMessage.getString(); }	/**	 * Returns project Setting to tell the copyright message that will be added to output decks.	 * @return project Setting to tell the copyright message that will be added to output decks.	 */	public static Setting getCopyrightMessageSetting() { return tool.cacheCopyrightMessage; }	private Setting cacheUseCopyrightMessage;	private Setting cacheCopyrightMessage;	private void initGeneralOutputProjectSettings() {		makeBooleanSetting("UseCopyrightMessage", "Netlists tab", "Use copyright message", false);		makeStringSetting("CopyrightMessage", "Netlists tab", "Copyright message", "");	}	private static Pref cachePlotArea = Pref.makeIntPref("PlotArea", IOTool.tool.prefs, 0);	/**	 * Method to tell the area of the screen to plot for printing/PostScript/HPGL.	 * @return the area of the screen to plot for printing/PostScript/HPGL:	 * 0=plot the entire cell (the default);	 * 1=plot only the highlighted area;	 * 2=plot only the displayed window.	 */	public static int getPlotArea() { return cachePlotArea.getInt(); }	/**	 * Method to set the area of the screen to plot for printing/PostScript/HPGL.	 * @param pa the area of the screen to plot for printing/PostScript/HPGL.	 * 0=plot the entire cell;	 * 1=plot only the highlighted area;	 * 2=plot only the displayed window.	 */	public static void setPlotArea(int pa) { cachePlotArea.setInt(pa); }	/**	 * Method to tell the area of the screen to plot for printing/PostScript/HPGL, by default.	 * @return the area of the screen to plot for printing/PostScript/HPGL, by default:	 * 0=plot the entire cell;	 * 1=plot only the highlighted area;	 * 2=plot only the displayed window.	 */	public static int getFactoryPlotArea() { return cachePlotArea.getIntFactoryValue(); }	private static Pref cachePlotDate = Pref.makeBooleanPref("PlotDate", IOTool.tool.prefs, false);	/**	 * Method to tell whether to plot the date in PostScript output.	 * The default is "false".	 * @return whether to plot the date in PostScript output.	 */	public static boolean isPlotDate() { return cachePlotDate.getBoolean(); }	/**

⌨️ 快捷键说明

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