📄 libtotech.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: LibToTech.java * Technology Editor, conversion of technology libraries to technologies * 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.DBMath;import com.sun.electric.database.geometry.EPoint;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.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.DRCTemplate;import com.sun.electric.technology.EdgeH;import com.sun.electric.technology.EdgeV;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.SizeOffset;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.io.FileType;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Color;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JLabel;import javax.swing.JTextField;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/*** This class creates technologies from technology libraries.*/public class LibToTech{ /* the meaning of "us_tecflags" */// private static final int HASDRCMINWID = 01; /* has DRC minimum width information */// private static final int HASDRCMINWIDR = 02; /* has DRC minimum width information */// private static final int HASCOLORMAP = 04; /* has color map */// private static final int HASARCWID = 010; /* has arc width offset factors */// private static final int HASCIF = 020; /* has CIF layers */// private static final int HASDXF = 040; /* has DXF layers */// private static final int HASGDS = 0100; /* has Calma GDS-II layers */// private static final int HASGRAB = 0200; /* has grab point information */// private static final int HASSPIRES = 0400; /* has SPICE resistance information */// private static final int HASSPICAP = 01000; /* has SPICE capacitance information */// private static final int HASSPIECAP = 02000; /* has SPICE edge capacitance information */// private static final int HAS3DINFO = 04000; /* has 3D height/thickness information */// private static final int HASCONDRC = 010000; /* has connected design rules */// private static final int HASCONDRCR = 020000; /* has connected design rules reasons */// private static final int HASUNCONDRC = 040000; /* has unconnected design rules */// private static final int HASUNCONDRCR = 0100000; /* has unconnected design rules reasons */// private static final int HASCONDRCW = 0200000; /* has connected wide design rules */// private static final int HASCONDRCWR = 0400000; /* has connected wide design rules reasons */// private static final int HASUNCONDRCW = 01000000; /* has unconnected wide design rules */// private static final int HASUNCONDRCWR = 02000000; /* has unconnected wide design rules reasons */// private static final int HASCONDRCM = 04000000; /* has connected multicut design rules */// private static final int HASCONDRCMR = 010000000; /* has connected multicut design rules reasons */// private static final int HASUNCONDRCM = 020000000; /* has unconnected multicut design rules */// private static final int HASUNCONDRCMR = 040000000; /* has unconnected multicut design rules reasons */// private static final int HASEDGEDRC = 0100000000; /* has edge design rules */// private static final int HASEDGEDRCR = 0200000000; /* has edge design rules reasons */// private static final int HASMINNODE = 0400000000; /* has minimum node size */// private static final int HASMINNODER = 01000000000; /* has minimum node size reasons */// private static final int HASPRINTCOL = 02000000000; /* has print colors */ /* the globals that define a technology */// static int us_tecflags;// static DRCRULES *us_tecdrc_rules = 0; private TechConversionResult error; /************************************* API AND USER INTERFACE *************************************/ /** * Method to convert the current library to a technology in a new job. * Starts with a dialog to control the process. */ public static void makeTechFromLib() { new GenerateTechnology(); } /** * This class displays a dialog for converting a library to a technology. */ private static class GenerateTechnology extends EDialog { private JLabel lab2, lab3; private JTextField renameName, newName; private JCheckBox alsoXML; /** Creates new form convert library to technology */ private GenerateTechnology() { super(null, true); initComponents(); nameChanged(); setVisible(true); } protected void escapePressed() { exit(false); } // Call this method when the user clicks the OK button private void exit(boolean goodButton) { if (goodButton) new TechFromLibJob(newName.getText(), alsoXML.isSelected()); dispose(); } private void nameChanged() { String techName = newName.getText(); if (Technology.findTechnology(techName) != null) { // name exists, offer to rename it lab2.setEnabled(true); lab3.setEnabled(true); renameName.setEnabled(true); renameName.setEditable(true); } else { // name is unique, don't offer to rename it lab2.setEnabled(false); lab3.setEnabled(false); renameName.setEnabled(false); renameName.setEditable(false); } } private void initComponents() { getContentPane().setLayout(new GridBagLayout()); setTitle("Convert Library to Technology"); setName(""); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { exit(false); } }); JLabel lab1 = new JLabel("Creating new technology:"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab1, gbc); newName = new JTextField(Library.getCurrent().getName()); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(newName, gbc); newName.getDocument().addDocumentListener(new TechNameDocumentListener()); lab2 = new JLabel("Already a technology with this name"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab2, gbc); lab3 = new JLabel("Rename existing technology to:"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab3, gbc); renameName = new JTextField(); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.gridwidth = 2; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(renameName, gbc); alsoXML = new JCheckBox("Also write XML code"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(alsoXML, gbc); // OK and Cancel JButton cancel = new JButton("Cancel"); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 3; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(cancel, gbc); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exit(false); } }); JButton ok = new JButton("OK"); getRootPane().setDefaultButton(ok); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 3; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(ok, gbc); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exit(true); } }); pack(); } /** * Class to handle special changes to the new technology name. */ private class TechNameDocumentListener implements DocumentListener { public void changedUpdate(DocumentEvent e) { nameChanged(); } public void insertUpdate(DocumentEvent e) { nameChanged(); } public void removeUpdate(DocumentEvent e) { nameChanged(); } } } /************************************* BUILDING TECHNOLOGY FROM LIBRARY *************************************/ /** * Class to create a technology-library from a technology (in a Job). */ private static class TechFromLibJob extends Job { private String newName; private String fileName; private TechConversionResult tcr; private TechFromLibJob(String newName, boolean alsoXML) { super("Make Technology from Technolog Library", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.newName = newName; if (alsoXML) { // print the technology as XML fileName = OpenFile.chooseOutputFile(FileType.XML, "File for Technology's XML Code", newName + ".xml"); } startJob(); } @Override public boolean doIt() { LibToTech ltt = new LibToTech(); tcr = new TechConversionResult(); ltt.makeTech(newName, fileName, tcr); fieldVariableChanged("tcr"); return true; } public void terminateOK() { if (tcr.failed()) { tcr.showError(); System.out.println("Failed to convert the library to a technology"); } } } /** * Method to convert the current Library to a Technology. * @param newName the name of the Technology to create. * @param fileName the name of the XML file to write (null to skip XML output). * @param error the structure for storing error status. * @return the new Technology. Returns null on error (and fills in "error"). */ public Technology makeTech(String newName, String fileName, TechConversionResult error) { this.error = error; Library lib = Library.getCurrent(); // get a new name for the technology String newTechName = newName; boolean modified = false; for(;;) { // search by hand because "gettechnology" handles partial matches if (Technology.findTechnology(newTechName) == null) break; newTechName += "X"; modified = true; } if (modified) System.out.println("Warning: already a technology called " + newName + ". Naming this " + newTechName); // get list of dependent libraries Library [] dependentLibs = Info.getDependentLibraries(lib);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -