📄 technologytab.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: TechnologyTab.java * * Copyright (c) 2004 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.options;import com.sun.electric.database.text.TextUtils;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Schematics;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Frame;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.util.HashMap;import java.util.Iterator;import java.util.Map;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 "Technology" tab of the Preferences dialog. */public class TechnologyTab extends PreferencePanel{ /** Creates new form TechnologyTab */ public TechnologyTab(Frame parent, boolean modal) { super(parent, modal); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(techSchematicsNegatingSize); EDialog.makeTextFieldSelectAllOnTab(vhdlName); EDialog.makeTextFieldSelectAllOnTab(vhdlNegatedName); } /** return the panel to use for this preferences tab. */ public JPanel getPanel() { return technology; } /** return the name of this preferences tab. */ public String getName() { return "Technology"; } private JList schemPrimList; private DefaultListModel schemPrimModel; private Map<PrimitiveNode,String> schemPrimMap; private boolean changingVHDL = false; /** * Method called at the start of the dialog. * Caches current values and displays them in the Technology tab. */ public void init() { // Layout rotateLayoutTransistors.setSelected(User.isRotateLayoutTransistors()); // Artwork techArtworkArrowsFilled.setSelected(Artwork.tech().isFilledArrowHeads()); // Schematics techSchematicsNegatingSize.setText(TextUtils.formatDouble(Schematics.tech().getNegatingBubbleSize())); // VHDL layers list schemPrimModel = new DefaultListModel(); schemPrimList = new JList(schemPrimModel); schemPrimList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); vhdlPrimPane.setViewportView(schemPrimList); schemPrimList.clearSelection(); schemPrimList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { schemClickPrim(); } }); schemPrimModel.clear(); schemPrimMap = new HashMap<PrimitiveNode,String>(); for(Iterator<PrimitiveNode> it = Schematics.tech().getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); if (np != Schematics.tech().andNode && np != Schematics.tech().orNode && np != Schematics.tech().xorNode && np != Schematics.tech().muxNode && np != Schematics.tech().bufferNode) continue; String str = Schematics.tech().getVHDLNames(np); schemPrimMap.put(np, str); schemPrimModel.addElement(makeLine(np, str)); } schemPrimList.setSelectedIndex(0); vhdlName.getDocument().addDocumentListener(new SchemPrimDocumentListener(this)); vhdlNegatedName.getDocument().addDocumentListener(new SchemPrimDocumentListener(this)); schemClickPrim(); } private String makeLine(PrimitiveNode np, String vhdlName) { return np.getName() + " (" + vhdlName + ")"; } /** * Method called when the user clicks on a layer name in the scrollable list. */ private void schemClickPrim() { changingVHDL = true; PrimitiveNode np = getSelectedPrim(); if (np == null) return; String vhdlNames = schemPrimMap.get(np); int slashPos = vhdlNames.indexOf('/'); if (slashPos < 0) { vhdlName.setText(vhdlNames); vhdlNegatedName.setText(""); } else { vhdlName.setText(vhdlNames.substring(0, slashPos)); vhdlNegatedName.setText(vhdlNames.substring(slashPos+1)); } changingVHDL = false; } private PrimitiveNode getSelectedPrim() { String str = (String)schemPrimList.getSelectedValue(); int spacePos = str.indexOf(' '); if (spacePos >= 0) str = str.substring(0, spacePos); PrimitiveNode np = Schematics.tech().findNodeProto(str); return np; } /** * Class to handle special changes to changes to a CIF layer. */ private static class SchemPrimDocumentListener implements DocumentListener { TechnologyTab dialog; SchemPrimDocumentListener(TechnologyTab dialog) { this.dialog = dialog; } public void changedUpdate(DocumentEvent e) { dialog.primVHDLChanged(); } public void insertUpdate(DocumentEvent e) { dialog.primVHDLChanged(); } public void removeUpdate(DocumentEvent e) { dialog.primVHDLChanged(); } } /** * Method called when the user types a new VHDL into the schematics tab. */ private void primVHDLChanged() { if (changingVHDL) return; String str = vhdlName.getText(); String strNot = vhdlNegatedName.getText(); String vhdl = ""; if (str.length() > 0 || strNot.length() > 0) vhdl = str + "/" + strNot; PrimitiveNode np = getSelectedPrim(); if (np == null) return; schemPrimMap.put(np, vhdl); int index = schemPrimList.getSelectedIndex(); schemPrimModel.set(index, makeLine(np, vhdl)); } /** * Method called when the "OK" panel is hit. * Updates any changed fields in the Technology tab. */ public void term() { boolean redrawWindows = false; boolean redrawMenus = false; // Layout boolean currentRotateTransistors = rotateLayoutTransistors.isSelected(); if (currentRotateTransistors != User.isRotateLayoutTransistors()) { User.setRotateLayoutTransistors(currentRotateTransistors); redrawMenus = true; } // Artwork boolean currentArrowsFilled = techArtworkArrowsFilled.isSelected(); if (currentArrowsFilled != Artwork.tech().isFilledArrowHeads()) { Artwork.tech().setFilledArrowHeads(currentArrowsFilled); redrawWindows = true; } // Schematics double currentNegatingBubbleSize = TextUtils.atof(techSchematicsNegatingSize.getText()); if (currentNegatingBubbleSize != Schematics.tech().getNegatingBubbleSize()) { Schematics.tech().setNegatingBubbleSize(currentNegatingBubbleSize); redrawWindows = true; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -