📄 fasthenryarc.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: FastHenryArc.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;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.Variable;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.io.output.FastHenry;import com.sun.electric.tool.simulation.Simulation;import com.sun.electric.tool.user.Highlight2;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.TopLevel;import java.awt.Frame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.Collections;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import javax.swing.JFrame;import javax.swing.JOptionPane;/** * Class to handle the "FastHenryArc" dialog. */public class FastHenryArc extends EDialog{ private ArcInst ai; private List<String> groupsList; private String initialGroupName; private double initialThickness; private int initialWidthSubdivs, initialHeightSubdivs; private double initialZHead, initialZTail; public static void showFastHenryArcDialog() { JFrame jf = null; if (TopLevel.isMDIMode()) jf = TopLevel.getCurrentJFrame(); FastHenryArc theDialog = new FastHenryArc(jf); theDialog.setVisible(true); } /** Creates new form FastHenryArc */ private FastHenryArc(Frame parent) { super(parent, true); initComponents(); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(fhaThickness); EDialog.makeTextFieldSelectAllOnTab(fhaWidthSubdivs); EDialog.makeTextFieldSelectAllOnTab(fhaHeightSubdivs); EDialog.makeTextFieldSelectAllOnTab(fhaHeadZ); EDialog.makeTextFieldSelectAllOnTab(fhaTailZ); // must have a single arc selected ai = null; int arcCount = 0; EditWindow wnd = EditWindow.getCurrent(); if (wnd != null) { for(Highlight2 h : wnd.getHighlighter().getHighlights()) { if (h.isHighlightEOBJ()) { ElectricObject eobj = h.getElectricObject(); if (eobj instanceof ArcInst) { ai = (ArcInst)eobj; arcCount++; } } } if (arcCount > 1) ai = null; } if (ai == null) { disableDialog(); return; } // enable dialog fhaIncludeArc.setEnabled(true); // gather list of all groups in the cell Set<String> groupNames = new HashSet<String>(); for(Iterator<ArcInst> it = ai.getParent().getArcs(); it.hasNext(); ) { ArcInst oAi = it.next(); Variable var = oAi.getVar(FastHenry.GROUP_NAME_KEY); if (var == null) continue; groupNames.add(var.getPureValue(-1)); } groupsList = new ArrayList<String>(); for(String str : groupNames) { groupsList.add(str); } Collections.sort(groupsList, String.CASE_INSENSITIVE_ORDER); for(String str : groupsList) { fhaGroups.addItem(str); } // see if an arc is selected FastHenry.FastHenryArcInfo fhai = new FastHenry.FastHenryArcInfo(ai); initialGroupName = ""; String groupName = fhai.getGroupName(); if (groupName == null) fhaIncludeArc.setSelected(false); else { fhaIncludeArc.setSelected(true); fhaGroups.setSelectedItem(initialGroupName = groupName); } fhaWidth.setText(TextUtils.formatDouble(ai.getLambdaBaseWidth())); String thickness = ""; if (fhai.getThickness() >= 0) thickness = TextUtils.formatDouble(initialThickness = fhai.getThickness()); fhaThickness.setText(thickness); fhaDefaultThickness.setText("default=" + TextUtils.formatDouble(Simulation.getFastHenryDefThickness())); String widthSubdivisions = ""; if (fhai.getWidthSubdivisions() >= 0) widthSubdivisions = Integer.toString(initialWidthSubdivs = fhai.getWidthSubdivisions()); fhaWidthSubdivs.setText(widthSubdivisions); fhaDefaultWidthSubdivs.setText("default=" + Integer.toString(Simulation.getFastHenryWidthSubdivisions())); String heightSubdivisions = ""; if (fhai.getHeightSubdivisions() >= 0) heightSubdivisions = Integer.toString(initialHeightSubdivs = fhai.getHeightSubdivisions()); fhaHeightSubdivs.setText(heightSubdivisions); fhaDefaultHeightSubdivs.setText("default=" + Integer.toString(Simulation.getFastHenryHeightSubdivisions())); fhaHeadXY.setText("Head at: X=" + TextUtils.formatDouble(ai.getHeadLocation().getX()) + " Y=" + TextUtils.formatDouble(ai.getHeadLocation().getY()) + " Z="); String headZ = ""; if (fhai.getZHead() >= 0) headZ = TextUtils.formatDouble(initialZHead = fhai.getZHead()); fhaHeadZ.setText(headZ); fhaTailXY.setText("Tail at: X=" + TextUtils.formatDouble(ai.getTailLocation().getX()) + " Y=" + TextUtils.formatDouble(ai.getTailLocation().getY()) + " Z="); String tailZ = ""; if (fhai.getZTail() >= 0) tailZ = TextUtils.formatDouble(initialZTail = fhai.getZTail()); fhaTailZ.setText(tailZ); String defaultZ = ""; if (fhai.getZDefault() >= 0) defaultZ = TextUtils.formatDouble(fhai.getZDefault()); fhaDefaultZ.setText("default=" + defaultZ); includeArcClicked(); fhaNewGroup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { makeNewGroup(); } }); fhaIncludeArc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { includeArcClicked(); } }); pack(); } private void makeNewGroup() { String groupName = (String)JOptionPane.showInputDialog(null, "Name of new FastHenry group:", "New Group Name", JOptionPane.QUESTION_MESSAGE, null, null, "NewGroup"); if (groupName == null) return; if (groupsList.contains(groupName)) { JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(), "That group name is already in the list"); return; } groupsList.add(groupName); Collections.sort(groupsList, String.CASE_INSENSITIVE_ORDER); fhaGroups.removeAllItems(); for(String str : groupsList) fhaGroups.addItem(str); fhaGroups.setSelectedItem(groupName); } private void includeArcClicked() { boolean enable = fhaIncludeArc.isSelected(); fhaGroupLabel.setEnabled(enable); fhaGroups.setEnabled(enable); fhaNewGroup.setEnabled(enable); fhaWidthLabel.setEnabled(enable); fhaWidth.setEnabled(enable); fhaThicknessLabel.setEnabled(enable); fhaThickness.setEnabled(enable); fhaThickness.setEditable(enable); fhaDefaultThickness.setEnabled(enable); fhaWidthSubdivsLabel.setEnabled(enable); fhaWidthSubdivs.setEnabled(enable); fhaWidthSubdivs.setEditable(enable); fhaDefaultWidthSubdivs.setEnabled(enable); fhaHeightSubdivsLabel.setEnabled(enable); fhaHeightSubdivs.setEnabled(enable); fhaHeightSubdivs.setEditable(enable); fhaDefaultHeightSubdivs.setEnabled(enable); fhaHeadXY.setEnabled(enable); fhaHeadZ.setEnabled(enable); fhaHeadZ.setEditable(enable); fhaTailXY.setEnabled(enable); fhaTailZ.setEnabled(enable); fhaTailZ.setEditable(enable); fhaDefaultZ.setEnabled(enable); } private void disableDialog() { fhaIncludeArc.setSelected(false); fhaIncludeArc.setEnabled(false); fhaGroupLabel.setEnabled(false); fhaGroups.setEnabled(false); fhaNewGroup.setEnabled(false); fhaWidthLabel.setEnabled(false); fhaWidth.setText(""); fhaThicknessLabel.setEnabled(false); fhaThickness.setText(""); fhaDefaultThickness.setText(""); fhaWidthSubdivsLabel.setEnabled(false); fhaWidthSubdivs.setText(""); fhaDefaultWidthSubdivs.setText(""); fhaHeightSubdivsLabel.setEnabled(false); fhaHeightSubdivs.setText(""); fhaDefaultHeightSubdivs.setText(""); fhaHeadXY.setText("Head at: X= Y= Z="); fhaHeadXY.setEnabled(false); fhaHeadZ.setText(""); fhaTailXY.setText("Tail at: X= Y= Z="); fhaTailXY.setEnabled(false); fhaTailZ.setText(""); fhaDefaultZ.setText("default="); fhaDefaultZ.setEnabled(false); } /** * Class to delete an attribute in a new thread. */ private static class UpdateFastHenryArc extends Job { private ArcInst ai; private boolean includeArc; private String groupName, initialGroupName; private double thickness, initialThickness; private int widthSubdivs, initialWidthSubdivs; private int heightSubdivs, initialHeightSubdivs; private double headZ, initialHeadZ; private double tailZ, initialTailZ; private UpdateFastHenryArc( ArcInst ai, boolean includeArc, String groupName, String initialGroupName, double thickness, double initialThickness, int widthSubdivs, int initialWidthSubdivs, int heightSubdivs, int initialHeightSubdivs, double headZ, double initialHeadZ, double tailZ, double initialTailZ) { super("Update FastHenry Arc", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.ai = ai; this.includeArc = includeArc; this.groupName = groupName; this.initialGroupName = initialGroupName; this.thickness = thickness; this.initialThickness = initialThickness; this.widthSubdivs = widthSubdivs; this.initialWidthSubdivs = initialWidthSubdivs; this.heightSubdivs = heightSubdivs; this.initialHeightSubdivs = initialHeightSubdivs; this.headZ = headZ; this.initialHeadZ = initialHeadZ; this.tailZ = tailZ; this.initialTailZ = initialTailZ; startJob(); } public boolean doIt() throws JobException { if (includeArc) { // add to fasthenry analysis if (!groupName.equals(initialGroupName)) { ai.newDisplayVar(FastHenry.GROUP_NAME_KEY, groupName); } // update variables if (thickness != initialThickness) ai.newVar(FastHenry.THICKNESS_KEY, new Double(thickness)); if (widthSubdivs != initialWidthSubdivs) ai.newVar(FastHenry.WIDTH_SUBDIVS_KEY, new Integer(widthSubdivs)); if (heightSubdivs != initialHeightSubdivs) ai.newVar(FastHenry.HEIGHT_SUBDIVS_KEY, new Integer(heightSubdivs)); if (headZ != initialHeadZ) ai.newVar(FastHenry.ZHEAD_KEY, new Double(headZ)); if (tailZ != initialTailZ) ai.newVar(FastHenry.ZTAIL_KEY, new Double(tailZ)); } else { if (ai.getVar(FastHenry.GROUP_NAME_KEY) != null) ai.delVar(FastHenry.GROUP_NAME_KEY); } return true; } } private void okPressed() { if (ai != null) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -