📄 gdstab.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: GDSTab.java * * Copyright (c) 2006 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.dialogs.projsettings;import com.sun.electric.database.text.Setting;import com.sun.electric.database.text.TextUtils;import com.sun.electric.technology.Foundry;import com.sun.electric.technology.Layer;import com.sun.electric.technology.Technology;import com.sun.electric.tool.io.GDSLayers;import com.sun.electric.tool.io.IOTool;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.ProjectSettingsFrame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.util.Iterator;import javax.swing.DefaultListModel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.ListSelectionModel;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** * Class to handle the "GDS" tab of the Project Settings dialog. */public class GDSTab extends ProjSettingsPanel{ /** Creates new form GDSTab */ public GDSTab(ProjectSettingsFrame parent, boolean modal) { super(parent, modal); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(gdsLayerNumber); EDialog.makeTextFieldSelectAllOnTab(gdsLayerType); EDialog.makeTextFieldSelectAllOnTab(gdsPinLayer); EDialog.makeTextFieldSelectAllOnTab(gdsPinType); EDialog.makeTextFieldSelectAllOnTab(gdsTextLayer); EDialog.makeTextFieldSelectAllOnTab(gdsTextType); EDialog.makeTextFieldSelectAllOnTab(gdsCellNameLenMax); EDialog.makeTextFieldSelectAllOnTab(gdsDefaultTextLayer); EDialog.makeTextFieldSelectAllOnTab(gdsInputScale); } /** return the panel to use for this Project Settings tab. */ public JPanel getPanel() { return gds; } /** return the name of this Project Settings tab. */ public String getName() { return "GDS"; } private JList gdsLayersList; private DefaultListModel gdsLayersModel; private boolean changingGDS = false; private Setting gdsOutMergesBoxesSetting = IOTool.getGDSOutMergesBoxesSetting(); private Setting gdsOutWritesExportPinsSetting = IOTool.getGDSOutWritesExportPinsSetting(); private Setting gdsOutUpperCaseSetting = IOTool.getGDSOutUpperCaseSetting(); private Setting gdsOutDefaultTextLayerSetting = IOTool.getGDSOutDefaultTextLayerSetting(); private Setting gdsOutputConvertsBracketsInExportsSetting = IOTool.getGDSOutputConvertsBracketsInExportsSetting(); private Setting gdsCellNameLenMaxSetting = IOTool.getGDSCellNameLenMaxSetting(); private Setting gdsInputScaleSetting = IOTool.getGDSInputScaleSetting(); // To have ability to store directly the technology and not // to depende on names to search the technology instance private static class TechGDSTab { public Technology tech; TechGDSTab(Technology t) { tech = t; } // This avoids to call Technology.toString() and get extra text. public String toString() { return tech.getTechName(); } } /** * Method called at the start of the dialog. * Caches current values and displays them in the GDS tab. */ public void init() { gdsOutputMergesBoxes.setSelected(getBoolean(gdsOutMergesBoxesSetting)); gdsOutputWritesExportPins.setSelected(getBoolean(gdsOutWritesExportPinsSetting)); gdsOutputUpperCase.setSelected(getBoolean(gdsOutUpperCaseSetting)); gdsDefaultTextLayer.setText(Integer.toString(getInt(gdsOutDefaultTextLayerSetting))); gdsOutputConvertsBracketsInExports.setSelected(getBoolean(gdsOutputConvertsBracketsInExportsSetting)); gdsCellNameLenMax.setText(Integer.toString(getInt(gdsCellNameLenMaxSetting))); gdsInputScale.setText(TextUtils.formatDouble(getDouble(gdsInputScaleSetting))); // build the layers list gdsLayersModel = new DefaultListModel(); gdsLayersList = new JList(gdsLayersModel); gdsLayersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); gdsLayerList.setViewportView(gdsLayersList); gdsLayersList.clearSelection(); gdsLayersList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { gdsClickLayer(); } }); for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext(); ) { Technology tech = it.next(); technologySelection.addItem(new TechGDSTab(tech)); } technologySelection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { techChanged(); } }); technologySelection.setSelectedItem(Technology.getCurrent()); foundrySelection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { foundryChanged(); } }); // to set foundry the first time techChanged(); GDSDocumentListener myDocumentListener = new GDSDocumentListener(this); gdsLayerNumber.getDocument().addDocumentListener(myDocumentListener); gdsLayerType.getDocument().addDocumentListener(myDocumentListener); gdsPinLayer.getDocument().addDocumentListener(myDocumentListener); gdsPinType.getDocument().addDocumentListener(myDocumentListener); gdsTextLayer.getDocument().addDocumentListener(myDocumentListener); gdsTextType.getDocument().addDocumentListener(myDocumentListener); } private void foundryChanged() { Foundry foundry = (Foundry)foundrySelection.getSelectedItem(); if (foundry == null) return; Technology tech = ((TechGDSTab)technologySelection.getSelectedItem()).tech; // show the list of layers in the technology gdsLayersModel.clear(); for(Iterator<Layer> lIt = tech.getLayers(); lIt.hasNext(); ) { Layer layer = lIt.next(); String str = layer.getName(); String gdsLayer = getString(foundry.getGDSLayerSetting(layer)); if (gdsLayer != null && gdsLayer.length() > 0) str += " (" + gdsLayer + ")"; gdsLayersModel.addElement(str); } gdsLayersList.setSelectedIndex(0); gdsClickLayer(); } private void setFoundries(Technology tech) { foundrySelection.removeAllItems(); // Foundry for (Iterator<Foundry> itF = tech.getFoundries(); itF.hasNext();) { foundrySelection.addItem(itF.next()); } foundrySelection.setSelectedItem(tech.getSelectedFoundry()); foundryChanged(); } private void techChanged() { Technology tech = ((TechGDSTab)technologySelection.getSelectedItem()).tech; if (tech == null) return; // set the foundries for the technology setFoundries(tech); } /** * Method called when the user clicks on a layer name in the scrollable list. */ private void gdsClickLayer() { changingGDS = true; String str = (String)gdsLayersList.getSelectedValue(); GDSLayers numbers = gdsGetNumbers(str); if (numbers == null) numbers = GDSLayers.EMPTY; if (numbers.getNumLayers() == 0) { gdsLayerNumber.setText(""); gdsLayerType.setText(""); } else { Integer gdsValue = numbers.getFirstLayer(); int layerNum = gdsValue.intValue() & 0xFFFF; int layerType = (gdsValue.intValue() >> 16) & 0xFFFF; gdsLayerNumber.setText(Integer.toString(layerNum)); gdsLayerType.setText(Integer.toString(layerType)); } if (numbers.getPinLayer() == -1) { gdsPinLayer.setText(""); gdsPinType.setText(""); } else { gdsPinLayer.setText(Integer.toString(numbers.getPinLayer() & 0xFFFF)); gdsPinType.setText(Integer.toString((numbers.getPinLayer() >> 16) & 0xFFFF)); } if (numbers.getTextLayer() == -1) { gdsTextLayer.setText(""); gdsTextType.setText(""); } else { gdsTextLayer.setText(Integer.toString(numbers.getTextLayer() & 0xFFFF)); gdsTextType.setText(Integer.toString((numbers.getTextLayer() >> 16) & 0xFFFF)); } changingGDS = false; } /** * Method to parse the line in the scrollable list and return the GDS layer numbers part * (in parentheses). */ private GDSLayers gdsGetNumbers(String str) { int openParen = str.indexOf('('); if (openParen < 0) return null; int closeParen = str.lastIndexOf(')'); if (closeParen < 0) return null; String gdsNumbers = str.substring(openParen+1, closeParen); GDSLayers numbers = GDSLayers.parseLayerString(gdsNumbers); return numbers; } /** * Method to parse the line in the scrollable list and return the Layer. */ private Layer gdsGetLayer(String str) { int openParen = str.indexOf('('); String layerName = openParen >= 0 ? str.substring(0, openParen-1) : str; Technology tech = ((TechGDSTab)technologySelection.getSelectedItem()).tech; if (tech == null) return null; Layer layer = tech.findLayer(layerName); return layer; } /** * Method called when the user types a new layer number into one of the 3 edit fields. */ private void gdsNumbersChanged() { if (changingGDS) return; String str = (String)gdsLayersList.getSelectedValue(); Layer layer = gdsGetLayer(str); if (layer == null) return; // the layer information String newLine = gdsLayerNumber.getText().trim(); int layerType = TextUtils.atoi(gdsLayerType.getText().trim()); if (layerType != 0) newLine += "/" + layerType; // the pin information String pinLayer = gdsPinLayer.getText().trim(); int pinType = TextUtils.atoi(gdsPinType.getText().trim()); if (pinLayer.length() > 0 || pinType != 0) { newLine += "," + pinLayer; if (pinType != 0) newLine += "/" + pinType; newLine += "p"; } // the text information String textLayer = gdsTextLayer.getText().trim(); int textType = TextUtils.atoi(gdsTextType.getText().trim()); if (textLayer.length() > 0 || textType != 0) { newLine += "," + textLayer; if (textType != 0) newLine += "/" + textType; newLine += "t"; } String wholeLine = layer.getName(); if (newLine.length() > 0) wholeLine = wholeLine + " (" + newLine + ")"; int index = gdsLayersList.getSelectedIndex(); gdsLayersModel.set(index, wholeLine); Foundry foundry = (Foundry)foundrySelection.getSelectedItem(); setString(foundry.getGDSLayerSetting(layer), newLine); } /** * Class to handle special changes to changes to a GDS layer. */ private static class GDSDocumentListener implements DocumentListener { GDSTab dialog; GDSDocumentListener(GDSTab dialog) { this.dialog = dialog; } public void changedUpdate(DocumentEvent e) { dialog.gdsNumbersChanged(); } public void insertUpdate(DocumentEvent e) { dialog.gdsNumbersChanged(); } public void removeUpdate(DocumentEvent e) { dialog.gdsNumbersChanged(); } } /** * Method called when the "OK" panel is hit. * Updates any changed fields in the GDS tab. */ public void term() { setBoolean(gdsOutMergesBoxesSetting, gdsOutputMergesBoxes.isSelected()); setBoolean(gdsOutWritesExportPinsSetting, gdsOutputWritesExportPins.isSelected()); setBoolean(gdsOutUpperCaseSetting, gdsOutputUpperCase.isSelected()); setInt(gdsOutDefaultTextLayerSetting, TextUtils.atoi(gdsDefaultTextLayer.getText())); setBoolean(gdsOutputConvertsBracketsInExportsSetting, gdsOutputConvertsBracketsInExports.isSelected()); setInt(gdsCellNameLenMaxSetting, TextUtils.atoi(gdsCellNameLenMax.getText())); setDouble(gdsInputScaleSetting, TextUtils.atof(gdsInputScale.getText())); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -