📄 editmenu.java
字号:
super("Update Parameters", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.highlighted = highlighted; this.allLibraries = allLibraries; startJob(); } public boolean doIt() throws JobException { int count = 0; if (allLibraries) { for (Iterator<Library> it = Library.getLibraries(); it.hasNext(); ) { Library lib = it.next(); for (Iterator<Cell> it2 = lib.getCells(); it2.hasNext(); ) { Cell c = it2.next(); for (Iterator<NodeInst> it3 = c.getNodes(); it3.hasNext(); ) { NodeInst ni = it3.next(); if (ni.isCellInstance()) { CircuitChangeJobs.inheritAttributes(ni); count++; } } } } } else { for (Geometric eobj : highlighted) { if (eobj instanceof NodeInst) { NodeInst ni = (NodeInst)eobj; if (ni.isCellInstance()) { CircuitChangeJobs.inheritAttributes(ni); count++; } } } } System.out.println("Updated Parameters on " + count + " nodes"); return true; } } /** * Method to change the global text scale by a given amount. * @param scale the amount to scale the global text size. */ public static void changeGlobalTextSize(double scale) { EditWindow wnd = EditWindow.needCurrent(); if (wnd == null) return; double curScale = wnd.getGlobalTextScale(); curScale *= scale; if (curScale != 0) { wnd.setGlobalTextScale(curScale); EditWindow.repaintAllContents(); } } /** * Method to edit the current text-cell in an external editor. */ private static void editExternally() { TextWindow tw = null; WindowFrame wf = WindowFrame.getCurrentWindowFrame(); if (wf != null && wf.getContent() instanceof TextWindow) { tw = (TextWindow)wf.getContent(); } if (tw == null) { Job.getUserInterface().showErrorMessage("You must be editing a text cell before editing it externally", "No Text To Edit"); return; } String externalEditor = User.getDefaultTextExternalEditor(); if (externalEditor.length() == 0) { Job.getUserInterface().showErrorMessage("No external text editor is defined. Use the Display/Text Preferences to set one", "No Text Editor Set"); return; } Cell cell = tw.getCell(); File f = null; String fileName = cell.getName() + "tmp"; // prefix in File.createTempFile must be longer than 2 try { f = File.createTempFile(fileName, null); } catch (Exception e) { e.printStackTrace(); } if (f == null) return; fileName = f.getPath(); if (!tw.writeTextCell(fileName)) { // error with written file JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(), "Could not save temporary file " + fileName, "Error saving temporary file", JOptionPane.ERROR_MESSAGE); return; } try { Client.OS os = Client.getOperatingSystem(); String commandString; if (os == Client.OS.WINDOWS) commandString = "cmd /c \"" + externalEditor + "\" " + fileName; else if (os == Client.OS.MACINTOSH) { // MacOS box only allows the selection of *.app programs. int index = externalEditor.indexOf(".app"); // like TextEdit.app if (index != -1) { String rootName = externalEditor.substring(0, index); int ind2 = rootName.lastIndexOf("/"); if (ind2 != -1) // remove all / rootName = rootName.substring(ind2, rootName.length()); commandString = externalEditor + "/Contents/MacOS/" + rootName + " " + fileName; } else commandString = externalEditor + " " + fileName; } else commandString = externalEditor + " " + fileName; Process p = Runtime.getRuntime().exec(commandString); try { p.waitFor(); } catch (InterruptedException e) { System.out.println("External text editor interrupted: " + e); } } catch (IOException e) { System.out.println("IO Exception: " + e); } tw.readTextCell(fileName); tw.goToLineNumber(1); if (f.delete()) System.out.println("** Deleted " + fileName + " **"); else System.out.println("Failed to delete " + fileName); } /** * This method implements the command to highlight all objects in the current Cell. */ public static void selectAllCommand() { doSelection(false, false); } /** * This method implements the command to highlight all objects in the current Cell * that are easy to select. */ public static void selectEasyCommand() { doSelection(true, false); } /** * This method implements the command to highlight all objects in the current Cell * that are hard to select. */ public static void selectHardCommand() { doSelection(false, true); } private static void doSelection(boolean mustBeEasy, boolean mustBeHard) { Cell curCell = WindowFrame.needCurCell(); if (curCell == null) return; EditWindow wnd = EditWindow.getCurrent(); if (wnd == null) return; Highlighter highlighter = wnd.getHighlighter(); // compute bounds for multi-page schematics Rectangle2D thisPageBounds = null; if (curCell.isMultiPage()) { int curPage = wnd.getMultiPageNumber(); Dimension d = new Dimension(); int frameFactor = Cell.FrameDescription.getCellFrameInfo(curCell, d); if (frameFactor == 0 && curCell.isMultiPage()) { double offY = curPage * Cell.FrameDescription.MULTIPAGESEPARATION; thisPageBounds = new Rectangle2D.Double(-d.getWidth()/2, -d.getHeight()/2+offY, d.getWidth(), d.getHeight()); } } boolean cellsAreHard = !User.isEasySelectionOfCellInstances(); highlighter.clear(); for(Iterator<NodeInst> it = curCell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); // for multipage schematics, restrict to current page if (thisPageBounds != null) { if (!thisPageBounds.contains(ni.getAnchorCenter())) continue; } // "select all" should not include the cell-center if (ni.getProto() == Generic.tech().cellCenterNode && !mustBeEasy && !mustBeHard) continue; boolean hard = ni.isHardSelect(); if ((ni.isCellInstance()) && cellsAreHard) hard = true; if (mustBeEasy && hard) continue; if (mustBeHard && !hard) continue; // do not show primitives with all layers invisible if (!User.isHighlightInvisibleObjects() && !ni.isCellInstance()) { PrimitiveNode np = (PrimitiveNode)ni.getProto(); if (np.isNodeInvisible()) continue; } if (!ni.isInvisiblePinWithText()) highlighter.addElectricObject(ni, curCell); if (User.isTextVisibilityOnNode()) { if (ni.isUsernamed()) highlighter.addText(ni, curCell, NodeInst.NODE_NAME); for(Iterator<Variable> vIt = ni.getParametersAndVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (var.isDisplay()) highlighter.addText(ni, curCell, var.getKey()); } } } for(Iterator<ArcInst> it = curCell.getArcs(); it.hasNext(); ) { ArcInst ai = it.next(); // for multipage schematics, restrict to current page if (thisPageBounds != null) { if (!thisPageBounds.contains(ai.getHeadLocation())) continue; } boolean hard = ai.isHardSelect(); if (mustBeEasy && hard) continue; if (mustBeHard && !hard) continue; // do not include arcs that have all layers invisible if (!User.isHighlightInvisibleObjects() && ai.getProto().isArcInvisible()) continue; highlighter.addElectricObject(ai, curCell); if (User.isTextVisibilityOnArc()) { if (ai.isUsernamed()) highlighter.addText(ai, curCell, ArcInst.ARC_NAME); for(Iterator<Variable> vIt = ai.getVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (var.isDisplay()) highlighter.addText(ai, curCell, var.getKey()); } } } for(Iterator<Export> it = curCell.getExports(); it.hasNext(); ) { Export pp = it.next(); highlighter.addText(pp, curCell, null); } // Selecting annotations if (User.isTextVisibilityOnCell()) { for(Iterator<Variable> it = curCell.getParametersAndVariables(); it.hasNext(); ) { Variable var = it.next(); if (var.isAttribute()) { // for multipage schematics, restrict to current page if (thisPageBounds != null) { if (!thisPageBounds.contains(new Point2D.Double(var.getXOff(), var.getYOff()))) continue; } highlighter.addText(curCell, curCell, var.getKey()); } } } highlighter.finished(); } /** * This method implements the command to highlight all objects in the current Cell * that are like the currently selected object. */ public static void selectAllLikeThisCommand() { Cell curCell = WindowFrame.needCurCell(); if (curCell == null) return; EditWindow wnd = EditWindow.getCurrent(); if (wnd == null) return; Highlighter highlighter = wnd.getHighlighter(); // make a set of prototypes and characteristics to match Set<Object> likeThis = new HashSet<Object>(); for(Highlight2 h : highlighter.getHighlights()) { // handle attribute text if (h.isHighlightText()) { Key key = h.getVarKey(); if (key != null && key != Export.EXPORT_NAME) { likeThis.add(key.getName()); continue; } } ElectricObject eObj = h.getElectricObject(); if (eObj instanceof PortInst) eObj = ((PortInst)eObj).getNodeInst(); if (eObj instanceof NodeInst) { NodeInst ni = (NodeInst)eObj; likeThis.add(ni.getProto()); } else if (eObj instanceof ArcInst) { ArcInst ai = (ArcInst)eObj; likeThis.add(ai.getProto()); } else if (eObj instanceof Export) { Export e = (Export)eObj; PortCharacteristic pc = e.getCharacteristic(); likeThis.add(pc.getName()); } } highlighter.clear(); for(Iterator<NodeInst> it = curCell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (likeThis.contains(ni.getProto())) { if (ni.isInvisiblePinWithText()) { for(Iterator<Variable> vIt = ni.getVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (var.isDisplay()) { highlighter.addText(ni, curCell, var.getKey()); break; } } } else { highlighter.addElectricObject(ni, curCell); } } if (likeThis.contains(NodeInst.NODE_NAME.getName())) highlighter.addText(ni, curCell, NodeInst.NODE_NAME); for(Iterator<Variable> vIt = ni.getParametersAndVariables(); vIt.hasNext(); ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -