📄 newnodestab.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: NewNodesTab.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.database.variable.Variable;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.SizeOffset;import com.sun.electric.technology.Technology;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.EDialog;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.HashMap;import java.util.Iterator;import java.util.Map;import javax.swing.JPanel;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** * Class to handle the "New Nodes" tab of the Preferences dialog. */public class NewNodesTab extends PreferencePanel{ /** Creates new form NewNodesTab */ public NewNodesTab(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(nodePrimitiveXSize); EDialog.makeTextFieldSelectAllOnTab(nodePrimitiveYSize); } /** return the panel to use for this preferences tab. */ public JPanel getPanel() { return newNode; } /** return the name of this preferences tab. */ public String getName() { return "Nodes"; } private static class PrimNodeInfo { double initialWid, wid; double initialHei, hei; Variable var; } private Map<PrimitiveNode,PrimNodeInfo> initialNewNodesPrimInfo; private boolean newNodesDataChanging = false; private Technology selectedTech; /** * Method called at the start of the dialog. * Caches current values and displays them in the New Nodes tab. */ public void init() { // gather information about the PrimitiveNodes in the current Technology initialNewNodesPrimInfo = new HashMap<PrimitiveNode,PrimNodeInfo>(); for(Iterator<Technology> tIt = Technology.getTechnologies(); tIt.hasNext(); ) { Technology tech = tIt.next(); technologySelection.addItem(tech.getTechName()); for(Iterator<PrimitiveNode> it = tech.getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); PrimNodeInfo pni = new PrimNodeInfo(); SizeOffset so = np.getProtoSizeOffset(); pni.initialWid = pni.wid = np.getDefWidth() - so.getLowXOffset() - so.getHighXOffset(); pni.initialHei = pni.hei = np.getDefHeight() - so.getLowYOffset() - so.getHighYOffset(); initialNewNodesPrimInfo.put(np, pni); } } technologySelection.setSelectedItem(Technology.getCurrent().getTechName()); selectedTech = null; newNodesPrimPopupChanged(); // set checkboxes for "Cells" area nodeCheckCellDates.setSelected(User.isCheckCellDates()); nodeSwitchTechnology.setSelected(User.isAutoTechnologySwitch()); nodePlaceCellCenter.setSelected(User.isPlaceCellCenter()); nodeReconstructArcsExports.setSelected(User.isReconstructArcsAndExportsToDeletedCells()); nodePromptForIndex.setSelected(User.isPromptForIndexWhenDescending()); // set checkboxes for "all nodes" area nodeDisallowModificationComplexNodes.setSelected(User.isDisallowModificationComplexNodes()); nodeDisallowModificationLockedPrims.setSelected(User.isDisallowModificationLockedPrims()); nodeMoveAfterDuplicate.setSelected(User.isMoveAfterDuplicate()); nodeDupArrayCopyExports.setSelected(User.isDupCopiesExports()); nodeExtractCopyExports.setSelected(User.isExtractCopiesExports()); // setup listeners to react to any changes to a primitive size technologySelection.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newNodesPrimPopupChanged(); } }); nodePrimitive.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { newNodesPrimPopupChanged(); } }); nodePrimitiveXSize.getDocument().addDocumentListener(new NewNodeDocumentListener(this)); nodePrimitiveYSize.getDocument().addDocumentListener(new NewNodeDocumentListener(this)); } /** * Method called when the primitive node popup is changed. */ private void newNodesPrimPopupChanged() { String techName = (String)technologySelection.getSelectedItem(); Technology tech = Technology.findTechnology(techName); if (tech == null) return; if (tech != selectedTech) { // reload the primitives selectedTech = tech; nodePrimitive.removeAllItems(); for(Iterator<PrimitiveNode> it = tech.getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); nodePrimitive.addItem(np.getName()); } } String primName = (String)nodePrimitive.getSelectedItem(); PrimitiveNode np = tech.findNodeProto(primName); PrimNodeInfo pni = initialNewNodesPrimInfo.get(np); if (pni == null) return; newNodesDataChanging = true; nodePrimitiveXSize.setText(TextUtils.formatDouble(pni.wid)); nodePrimitiveYSize.setText(TextUtils.formatDouble(pni.hei)); newNodesDataChanging = false; } /** * Class to handle special changes to per-primitive node options. */ private static class NewNodeDocumentListener implements DocumentListener { NewNodesTab dialog; NewNodeDocumentListener(NewNodesTab dialog) { this.dialog = dialog; } public void changedUpdate(DocumentEvent e) { dialog.newNodesPrimDataChanged(); } public void insertUpdate(DocumentEvent e) { dialog.newNodesPrimDataChanged(); } public void removeUpdate(DocumentEvent e) { dialog.newNodesPrimDataChanged(); } } /** * Method called when any of the primitive data (in the top part) changes. * Caches all values for the selected primitive node. */ private void newNodesPrimDataChanged() { if (newNodesDataChanging) return; String techName = (String)technologySelection.getSelectedItem(); Technology tech = Technology.findTechnology(techName); if (tech == null) return; String primName = (String)nodePrimitive.getSelectedItem(); PrimitiveNode np = tech.findNodeProto(primName); PrimNodeInfo pni = initialNewNodesPrimInfo.get(np); if (pni == null) return; pni.wid = TextUtils.atof(nodePrimitiveXSize.getText()); pni.hei = TextUtils.atof(nodePrimitiveYSize.getText()); } /** * Method called when the "OK" panel is hit. * Updates any changed fields in the New Nodes tab. */ public void term() { for(Iterator<Technology> tIt = Technology.getTechnologies(); tIt.hasNext(); ) { Technology tech = tIt.next(); for(Iterator<PrimitiveNode> it = tech.getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); PrimNodeInfo pni = initialNewNodesPrimInfo.get(np); if (pni.wid != pni.initialWid || pni.hei != pni.initialHei) { SizeOffset so = np.getProtoSizeOffset(); double wid = pni.wid + so.getLowXOffset() + so.getHighXOffset(); double hei = pni.hei + so.getLowYOffset() + so.getHighYOffset(); np.setDefSize(wid, hei); } } } boolean currBoolean = nodeCheckCellDates.isSelected(); if (currBoolean != User.isCheckCellDates()) User.setCheckCellDates(currBoolean); currBoolean = nodeSwitchTechnology.isSelected(); if (currBoolean != User.isAutoTechnologySwitch()) User.setAutoTechnologySwitch(currBoolean); currBoolean = nodePlaceCellCenter.isSelected(); if (currBoolean != User.isPlaceCellCenter()) User.setPlaceCellCenter(currBoolean); currBoolean = nodeReconstructArcsExports.isSelected(); if (currBoolean != User.isReconstructArcsAndExportsToDeletedCells()) User.setReconstructArcsAndExportsToDeletedCells(currBoolean); currBoolean = nodePromptForIndex.isSelected(); if (currBoolean != User.isPromptForIndexWhenDescending()) User.setPromptForIndexWhenDescending(currBoolean); currBoolean = nodeDisallowModificationComplexNodes.isSelected(); if (currBoolean != User.isDisallowModificationComplexNodes()) User.setDisallowModificationComplexNodes(currBoolean); currBoolean = nodeDisallowModificationLockedPrims.isSelected(); if (currBoolean != User.isDisallowModificationLockedPrims()) User.setDisallowModificationLockedPrims(currBoolean); currBoolean = nodeMoveAfterDuplicate.isSelected(); if (currBoolean != User.isMoveAfterDuplicate()) User.setMoveAfterDuplicate(currBoolean); currBoolean = nodeDupArrayCopyExports.isSelected(); if (currBoolean != User.isDupCopiesExports()) User.setDupCopiesExports(currBoolean); currBoolean = nodeExtractCopyExports.isSelected(); if (currBoolean != User.isExtractCopiesExports()) User.setExtractCopiesExports(currBoolean); } /** * Method called when the factory reset is requested. */ public void reset() { for(Iterator<Technology> tIt = Technology.getTechnologies(); tIt.hasNext(); ) { Technology tech = tIt.next(); for(Iterator<PrimitiveNode> it = tech.getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); if (np.getDefaultLambdaBaseWidth() != np.getFactoryDefaultLambdaBaseWidth() || np.getDefaultLambdaBaseHeight() != np.getFactoryDefaultLambdaBaseHeight()) np.setDefSize(np.getFactoryDefaultLambdaBaseWidth(), np.getFactoryDefaultLambdaBaseHeight()); } } if (User.isFactoryCheckCellDates() != User.isCheckCellDates()) User.setCheckCellDates(User.isFactoryCheckCellDates()); if (User.isFactoryAutoTechnologySwitch() != User.isAutoTechnologySwitch()) User.setAutoTechnologySwitch(User.isFactoryAutoTechnologySwitch()); if (User.isFactoryPlaceCellCenter() != User.isPlaceCellCenter()) User.setPlaceCellCenter(User.isFactoryPlaceCellCenter()); if (User.isFactoryReconstructArcsAndExportsToDeletedCells() != User.isReconstructArcsAndExportsToDeletedCells())
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -