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

📄 manipulate.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: Manipulate.java * Technology Editor, editing technology libraries * Written by Steven M. Rubin, Sun Microsystems. * * Copyright (c) 2005 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.user.tecEdit;import com.sun.electric.database.geometry.EGraphics;import com.sun.electric.database.geometry.ERectangle;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.EDatabase;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.id.CellId;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.Layer;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.Technology;import com.sun.electric.technology.Xml;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.erc.ERC;import com.sun.electric.tool.user.Highlighter;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.ComponentMenu;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.PromptAt;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Color;import java.awt.Component;import java.awt.Dimension;import java.awt.Graphics;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.Point;import java.awt.Rectangle;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseEvent;import java.awt.event.MouseListener;import java.awt.event.MouseMotionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import java.util.StringTokenizer;import javax.swing.DefaultListModel;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JOptionPane;import javax.swing.JScrollPane;import javax.swing.JTextField;import javax.swing.ListCellRenderer;import javax.swing.ListSelectionModel;/** * This class manipulates technology libraries. */public class Manipulate{	/**	 * Method to update tables to reflect that cell "oldName" is now called "newName".	 * If "newName" is not valid, any rule that refers to "oldName" is removed.	 */	public static void renamedCell(String oldName, String newName)	{		// if this is a layer, rename the layer sequence array		if (oldName.startsWith("layer-") && newName.startsWith("layer-"))		{			renameSequence(Info.LAYERSEQUENCE_KEY, oldName.substring(6), newName.substring(6));		}		// if this is an arc, rename the arc sequence array		if (oldName.startsWith("arc-") && newName.startsWith("arc-"))		{			renameSequence(Info.ARCSEQUENCE_KEY, oldName.substring(4), newName.substring(4));		}		// if this is a node, rename the node sequence array		if (oldName.startsWith("node-") && newName.startsWith("node-"))		{			renameSequence(Info.NODESEQUENCE_KEY, oldName.substring(5), newName.substring(5));		}//		// see if there are design rules in the current library//		var = getval((INTBIG)el_curlib, VLIBRARY, VSTRING|VISARRAY, x_("EDTEC_DRC"));//		if (var == NOVARIABLE) return;////		// examine the rules and convert the name//		len = getlength(var);//		sa = newstringarray(us_tool.cluster);//		for(i=0; i<len; i++)//		{//			// parse the DRC rule//			str = ((CHAR **)var.addr)[i];//			origstr = str;//			firstkeyword = getkeyword(&str, x_(" "));//			if (firstkeyword == NOSTRING) return;////			// pass wide wire limitation through//			if (*firstkeyword == 'l')//			{//				addtostringarray(sa, origstr);//				continue;//			}////			// rename nodes in the minimum node size rule//			if (*firstkeyword == 'n')//			{//				if (namesamen(oldName, x_("node-"), 5) == 0 &&//					namesame(&oldName[5], &firstkeyword[1]) == 0)//				{//					// substitute the new name//					if (namesamen(newName, x_("node-"), 5) == 0)//					{//						infstr = initinfstr();//						addstringtoinfstr(infstr, x_("n"));//						addstringtoinfstr(infstr, &newName[5]);//						addstringtoinfstr(infstr, str);//						addtostringarray(sa, returninfstr(infstr));//					}//					continue;//				}//				addtostringarray(sa, origstr);//				continue;//			}////			// rename layers in the minimum layer size rule//			if (*firstkeyword == 's')//			{//				valid = TRUE;//				infstr = initinfstr();//				formatinfstr(infstr, x_("%s "), firstkeyword);//				keyword = getkeyword(&str, x_(" "));//				if (keyword == NOSTRING) return;//				if (namesamen(oldName, x_("layer-"), 6) == 0 &&//					namesame(&oldName[6], keyword) == 0)//				{//					if (namesamen(newName, x_("layer-"), 6) != 0) valid = FALSE; else//						addstringtoinfstr(infstr, &newName[6]);//				} else//					addstringtoinfstr(infstr, keyword);//				addstringtoinfstr(infstr, str);//				str = returninfstr(infstr);//				if (valid) addtostringarray(sa, str);//				continue;//			}////			// layer width rule: substitute layer names//			infstr = initinfstr();//			formatinfstr(infstr, x_("%s "), firstkeyword);//			valid = TRUE;////			// get the first layer name and convert it//			keyword = getkeyword(&str, x_(" "));//			if (keyword == NOSTRING) return;//			if (namesamen(oldName, x_("layer-"), 6) == 0 &&//				namesame(&oldName[6], keyword) == 0)//			{//				// substitute the new name//				if (namesamen(newName, x_("layer-"), 6) != 0) valid = FALSE; else//					addstringtoinfstr(infstr, &newName[6]);//			} else//				addstringtoinfstr(infstr, keyword);//			addtoinfstr(infstr, ' ');////			// get the second layer name and convert it//			keyword = getkeyword(&str, x_(" "));//			if (keyword == NOSTRING) return;//			if (namesamen(oldName, x_("layer-"), 6) == 0 &&//				namesame(&oldName[6], keyword) == 0)//			{//				// substitute the new name//				if (namesamen(newName, x_("layer-"), 6) != 0) valid = FALSE; else//					addstringtoinfstr(infstr, &newName[6]);//			} else//				addstringtoinfstr(infstr, keyword);////			addstringtoinfstr(infstr, str);//			str = returninfstr(infstr);//			if (valid) addtostringarray(sa, str);//		}//		strings = getstringarray(sa, &count);//		setval((INTBIG)el_curlib, VLIBRARY, x_("EDTEC_DRC"), (INTBIG)strings,//			VSTRING|VISARRAY|(count<<VLENGTHSH));//		killstringarray(sa);	}	/**	 * Method called when a cell has been deleted.	 */	public static void deletedCell(Cell np)	{		if (np.getName().startsWith("layer-"))		{			// may have deleted layer cell in technology library			String layerName = np.getName().substring(6);			StringBuffer warning = null;			for(Iterator<Cell> it = np.getLibrary().getCells(); it.hasNext(); )			{				Cell oNp = it.next();				boolean isNode = false;				if (oNp.getName().startsWith("node-")) isNode = true; else					if (!oNp.getName().startsWith("arc-")) continue;				for(Iterator<NodeInst> nIt = oNp.getNodes(); nIt.hasNext(); )				{					NodeInst ni = nIt.next();					Variable var = ni.getVar(Info.LAYER_KEY);					if (var == null) continue;					CellId cID = (CellId)var.getObject();					Cell varCell = EDatabase.serverDatabase().getCell(cID);					if (varCell == np)					{						if (warning != null) warning.append(","); else						{							warning = new StringBuffer();							warning.append("Warning: layer " + layerName + " is used in");						}						if (isNode) warning.append(" node " + oNp.getName().substring(5)); else							warning.append(" arc " + oNp.getName().substring(4));						break;					}				}			}			if (warning != null) System.out.println(warning.toString());			// see if this layer is mentioned in the design rules			renamedCell(np.getName(), "");		} else if (np.getName().startsWith("node-"))		{			// see if this node is mentioned in the design rules			renamedCell(np.getName(), "");		}	}	/**	 * Method to rename the layer/arc/node sequence arrays to account for a name change.	 * The sequence array is in variable "varName", and the item has changed from "oldName" to	 * "newName".	 */	private static void renameSequence(Variable.Key varName, String oldName, String newName)	{		Library lib = Library.getCurrent();		Variable var = lib.getVar(varName);		if (var == null) return;		String [] strings = (String [])var.getObject();		for(int i=0; i<strings.length; i++)			if (strings[i].equals(oldName)) strings[i] = newName;		lib.newVar(varName, strings);	}	/**	 * Method to determine whether it is legal to place an instance in a technology-edit cell.	 * @param np the type of node to create.	 * @param cell the cell in which to place it.	 * @return true if the creation is invalid (and prints an error message).	 */	public static boolean invalidCreation(NodeProto np, Cell cell)	{		// make sure the cell is right		if (!cell.getName().startsWith("node-") && !cell.getName().startsWith("arc-"))		{			System.out.println("Must be editing a node or arc to place geometry");			return true;		}		if (np == Generic.tech().portNode && !cell.getName().startsWith("node-"))		{			System.out.println("Can only place ports in node descriptions");			return true;		}		return false;	}	/**	 * Make a new technology-edit cell of a given type.	 * @param type 1=layer, 2=arc, 3=node, 4=factors	 */	public static void makeCell(int type)	{		Library lib = Library.getCurrent();		String cellName = null;		switch (type)		{			case 1:		// layer				String layerName = JOptionPane.showInputDialog("Name of new layer:", "");				if (layerName == null) return;				cellName = "layer-" + layerName + "{lay}";				break;			case 2:		// arc				String arcName = JOptionPane.showInputDialog("Name of new arc:", "");				if (arcName == null) return;				cellName = "arc-" + arcName + "{lay}";				break;			case 3:		// node				String nodeName = JOptionPane.showInputDialog("Name of new node:", "");				if (nodeName == null) return;				cellName = "node-" + nodeName + "{lay}";				break;			case 4:		// factors				cellName = "factors";				break;		}		// see if the cell exists		Cell cell = lib.findNodeProto(cellName);		if (cell != null)		{			// cell exists: put it in the current window			WindowFrame wf = WindowFrame.getCurrentWindowFrame();			if (wf != null) wf.setCellWindow(cell, null);			return;		}		// create the cell		new MakeOneCellJob(lib, cellName, type);	}	/**	 * Class to create a single cell in a technology-library.	 */	private static class MakeOneCellJob extends Job	{		private Library lib;		private String name;		private int type;		private Cell newCell;		private MakeOneCellJob(Library lib, String name, int type)		{			super("Make Cell in Technology-Library", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.lib = lib;			this.name = name;			this.type = type;			startJob();		}		public boolean doIt() throws JobException		{			newCell = Cell.makeInstance(lib, name);			if (newCell == null) return false;			newCell.setInTechnologyLibrary();			newCell.setTechnology(Artwork.tech());			// specialty initialization			switch (type)			{				case 1:					LayerInfo li = new LayerInfo();					li.generate(newCell);					break;				case 2:					ArcInfo aIn = new ArcInfo();					aIn.generate(newCell);

⌨️ 快捷键说明

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