📄 manipulate.java
字号:
break; case 3: NodeInfo nIn = new NodeInfo(); nIn.generate(newCell); break; } // show it fieldVariableChanged("newCell"); return true; } public void terminateOK() { WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf != null && newCell != null) wf.setCellWindow(newCell, null); } } /** * Method to complete the creation of a new node in a technology edit cell. * @param newNi the node that was just created. */ public static void completeNodeCreation(NodeInst newNi, Variable v) { // postprocessing on the nodes String portName = null; if (newNi.getProto() == Generic.tech().portNode) { // a port layer portName = JOptionPane.showInputDialog("Port name:", ""); if (portName == null) return; } boolean isHighlight = false; if (v != null) { if (v.getObject() instanceof Integer && ((Integer)v.getObject()).intValue() == Info.HIGHLIGHTOBJ) { isHighlight = true; } } new AddTechEditMarks(newNi, isHighlight, portName); } /** * Class to prepare a NodeInst for technology editing. * Adds variables to the NodeInst which identify it to the technology editor. */ private static class AddTechEditMarks extends Job { private NodeInst newNi; private boolean isHighlight; private String portName; private AddTechEditMarks(NodeInst newNi, boolean isHighlight, String portName) { super("Prepare node for technology editing", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.newNi = newNi; this.isHighlight = isHighlight; this.portName = portName; startJob(); } public boolean doIt() throws JobException { if (isHighlight) { newNi.newVar(Info.OPTION_KEY, new Integer(Info.HIGHLIGHTOBJ)); return true; } // set layer information newNi.newVar(Info.OPTION_KEY, new Integer(Info.LAYERPATCH)); // postprocessing on the nodes if (newNi.getProto() == Generic.tech().portNode) { // a port layer newNi.newDisplayVar(Info.PORTNAME_KEY, portName); return true; } // a real layer: default to the first one String [] layerNames = getLayerNameList(); if (layerNames != null && layerNames.length > 0) { Cell cell = Library.getCurrent().findNodeProto(layerNames[0]); if (cell != null) { newNi.newVar(Info.LAYER_KEY, cell.getId()); LayerInfo li = LayerInfo.parseCell(cell); if (li != null) setPatch(newNi, li.desc); } } return true; } } /** * Method to reorganize the dependent libraries */ public static void editLibraryDependencies() { new EditDependentLibraries(); } /** * Method to edit the component menu for the technology. */ public static void editComponentMenu() { // get information about arcs and nodes in the technology being edited Library [] dependentlibs = Info.getDependentLibraries(Library.getCurrent()); Cell [] arcCells = Info.findCellSequence(dependentlibs, "arc-", Info.ARCSEQUENCE_KEY); Cell [] nodeCells = Info.findCellSequence(dependentlibs, "node-", Info.NODESEQUENCE_KEY); // get the XML string describing the component menu String compMenuXML; Variable var = Library.getCurrent().getVar(Info.COMPMENU_KEY); if (var == null) { // construct a default component menu List<Object> things = new ArrayList<Object>(); // add in arcs for(int i=0; i<arcCells.length; i++) { String arcName = arcCells[i].getName().substring(4); Xml.ArcProto curArc = new Xml.ArcProto(); curArc.name = arcName; things.add(curArc); } // add in nodes for(int i=0; i<nodeCells.length; i++) { Cell np = nodeCells[i]; NodeInfo nIn = NodeInfo.parseCell(np); if (nIn.func == PrimitiveNode.Function.NODE) continue; String nodeName = nodeCells[i].getName().substring(5); Xml.PrimitiveNode curNode = new Xml.PrimitiveNode(); curNode.name = nodeName; curNode.function = nIn.func; things.add(curNode); } // add in special menu entries things.add(Technology.SPECIALMENUPURE); things.add(Technology.SPECIALMENUMISC); things.add(Technology.SPECIALMENUCELL); // construct the menu information int columns = (things.size()+13) / 14; Xml.MenuPalette xmp = new Xml.MenuPalette(); xmp.numColumns = columns; xmp.menuBoxes = new ArrayList<List<Object>>(); for(Object item : things) { List<Object> subList = new ArrayList<Object>(); subList.add(item); xmp.menuBoxes.add(subList); } compMenuXML = xmp.writeXml(); } else { compMenuXML = (String)var.getObject(); } List<Xml.PrimitiveNode> nodes = new ArrayList<Xml.PrimitiveNode>(); for(int i=0; i<nodeCells.length; i++) { Xml.PrimitiveNode xnp = new Xml.PrimitiveNode(); xnp.name = nodeCells[i].getName().substring(5); NodeInfo nIn = NodeInfo.parseCell(nodeCells[i]); xnp.function = nIn.func; nodes.add(xnp); } List<Xml.ArcProto> arcs = new ArrayList<Xml.ArcProto>(); for(int i=0; i<arcCells.length; i++) { Xml.ArcProto xap = new Xml.ArcProto(); xap.name = arcCells[i].getName().substring(4); arcs.add(xap); } Xml.MenuPalette xmp = Xml.parseComponentMenuXMLTechEdit(compMenuXML, nodes, arcs); ComponentMenu.showComponentMenuDialog(Library.getCurrent().getName(), xmp, nodes, arcs); } /** * This class displays a dialog for editing library dependencies. */ private static class EditDependentLibraries extends EDialog { private JList allLibsList, depLibsList; private DefaultListModel allLibsModel, depLibsModel; private JTextField libToAdd; /** Creates new form edit library dependencies */ private EditDependentLibraries() { super(null, true); initComponents(); setVisible(true); } protected void escapePressed() { exit(false); } // Call this method when the user clicks the OK button private void exit(boolean goodButton) { if (goodButton) { int numDeps = depLibsModel.size(); String [] depLibs = new String[numDeps]; for(int i=0; i<numDeps; i++) depLibs[i] = (String)depLibsModel.get(i); new ModifyDependenciesJob(depLibs); } setVisible(false); dispose(); } /** * Class for saving library dependencies. */ private static class ModifyDependenciesJob extends Job { private String [] depLibs; private ModifyDependenciesJob(String [] depLibs) { super("Modify Library Dependencies", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.depLibs = depLibs; startJob(); } public boolean doIt() throws JobException { Library lib = Library.getCurrent(); if (depLibs.length == 0) { if (lib.getVar(Info.DEPENDENTLIB_KEY) != null) lib.delVar(Info.DEPENDENTLIB_KEY); } else { lib.newVar(Info.DEPENDENTLIB_KEY, depLibs); } return true; } } private void removeLib() { int index = depLibsList.getSelectedIndex(); if (index < 0) return; depLibsModel.remove(index); } private void addLib() { String value = (String)allLibsList.getSelectedValue(); String specialLib = libToAdd.getText(); if (specialLib.length() > 0) { value = specialLib; libToAdd.setText(""); } if (value == null) return; for(int i=0; i<depLibsModel.size(); i++) { String depLib = (String)depLibsModel.get(i); if (depLib.equals(value)) return; } depLibsModel.addElement(value); } private void initComponents() { getContentPane().setLayout(new GridBagLayout()); setTitle("Dependent Library Selection"); setName(""); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { exit(false); } }); // left column JLabel lab1 = new JLabel("Dependent Libraries:"); 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); JScrollPane depLibsPane = new JScrollPane(); depLibsModel = new DefaultListModel(); depLibsList = new JList(depLibsModel); depLibsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); depLibsPane.setViewportView(depLibsList); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridheight = 4; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(depLibsPane, gbc); depLibsModel.clear(); Library [] libs = Info.getDependentLibraries(Library.getCurrent()); for(int i=0; i<libs.length; i++) { if (libs[i] == Library.getCurrent()) continue; depLibsModel.addElement(libs[i].getName()); } JLabel lab2 = new JLabel("Current: " + Library.getCurrent().getName()); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 5; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab2, gbc); JLabel lab3 = new JLabel("Libraries are examined from bottom up"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 6; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab3, gbc); // center column JButton remove = new JButton("Remove"); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(remove, gbc); remove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { removeLib(); } }); JButton add = new JButton("<< Add"); gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 2; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(add, gbc); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { addLib(); } }); // right column JLabel lab4 = new JLabel("All Libraries:"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab4, gbc); JScrollPane allLibsPane = new JScrollPane(); allLibsModel = new DefaultListModel(); allLibsList = new JList(allLibsModel); allLibsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); allLibsPane.setViewportView(allLibsList); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 1; gbc.gridheight = 2; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(allLibsPane, gbc); allLibsModel.clear(); for(Library lib : Library.getVisibleLibraries()) { allLibsModel.addElement(lib.getName()); } JLabel lab5 = new JLabel("Library (if not in list):"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 3; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(lab5, gbc); libToAdd = new JTextField(""); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.insets = new Insets(4, 4, 4, 4); getContentPane().add(libToAdd, gbc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -