changetext.java
来自「The ElectricTM VLSI Design System is an 」· Java 代码 · 共 954 行 · 第 1/3 页
JAVA
954 行
findAllInCell(cp, cell, true); } else if (cp.changeCellsWithView) { View v = View.findView(cp.viewListSelection); if (v != null) { for(Iterator<Cell> it = Library.getCurrent().getCells(); it.hasNext(); ) { Cell c = it.next(); if (c.getView() == v) findAllInCell(cp, c, true); } } } else if (cp.changeAllInLibrary) { for(Iterator<Cell> it = Library.getCurrent().getCells(); it.hasNext(); ) { Cell c = it.next(); findAllInCell(cp, c, true); } } } /** * Method to grab all text in a Cell and process it. * @param cell the cell to examine. * @param change true to change the text in the cell according to the bottom of the dialog; * false to gather the text sizes in the cell for display. */ private static void findAllInCell(ChangeParameters cp, Cell cell, boolean change) { // make sure text adjustment is allowed if (change) { if (CircuitChangeJobs.cantEdit(cell, null, true, true, true) != 0) return; } // text on nodes for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (ni.isCellInstance() && !ni.isExpanded()) { // cell instance text accumulateTextFound(cp, ni, NodeInst.NODE_PROTO, change); } if (!ni.getNameKey().isTempname()) { // node name accumulateTextFound(cp, ni, NodeInst.NODE_NAME, change); } for(Iterator<Variable> vIt = ni.getParametersAndVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (!var.isDisplay()) continue; accumulateTextFound(cp, ni, var.getKey(), change); } } // text on arcs for(Iterator<ArcInst> it = cell.getArcs(); it.hasNext(); ) { ArcInst ai = it.next(); if (!ai.getNameKey().isTempname()) { // arc name accumulateTextFound(cp, ai, ArcInst.ARC_NAME, change); } for(Iterator<Variable> vIt = ai.getVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (!var.isDisplay()) continue; accumulateTextFound(cp, ai, var.getKey(), change); } } // text on exports for(Iterator<PortProto> it = cell.getPorts(); it.hasNext(); ) { Export pp = (Export)it.next(); accumulateTextFound(cp, pp, Export.EXPORT_NAME, change); for(Iterator<Variable> vIt = pp.getVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (!var.isDisplay()) continue; accumulateTextFound(cp, pp, var.getKey(), change); } } // text on the cell for(Iterator<Variable> vIt = cell.getParametersAndVariables(); vIt.hasNext(); ) { Variable var = vIt.next(); if (!var.isDisplay()) continue; accumulateTextFound(cp, cell, var.getKey(), change); } } /** * Method to process a relevant piece of text. * @param eObj the ElectricObject on which the text resides. * @param var the Variable on which the text resides (may be null). * @param name the Name object of the text (for Node and Arc names). * @param change true to change the text the cell according to the bottom of the dialog; * false to gather the text sizes for display. */ private static void accumulateTextFound(ChangeParameters cp, ElectricObject eObj, Variable.Key varKey, boolean change) { if (eObj instanceof NodeInst) { NodeInst ni = (NodeInst)eObj; if (ni.getProto() == Generic.tech().invisiblePinNode) { if (cp.annotationsSelected) { if (processText(cp, eObj, varKey, change)) cp.numAnnotationsChanged++; } } else if (varKey == NodeInst.NODE_PROTO) { if (cp.instancesSelected) { if (processText(cp, eObj, varKey, change)) cp.numInstancesChanged++; } } else { if (cp.nodesSelected) { if (processText(cp, eObj, varKey, change)) cp.numNodesChanged++; } } } else if (eObj instanceof ArcInst) { if (cp.arcsSelected) { if (processText(cp, eObj, varKey, change)) cp.numArcsChanged++; } } else if (eObj instanceof Cell) { if (cp.cellsSelected) { if (processText(cp, eObj, varKey, change)) cp.numCellsChanged++; } } else if (eObj instanceof Export) { if (cp.exportsSelected) { if (processText(cp, eObj, varKey, change)) cp.numExportsChanged++; } } } /** * Method to process a single TextDescriptor that is on a relevant piece of text. * @param cp the ChangeParameters with information about how to handle the text. * @param owner ElectricObject which is owner of the TextDescriptor * @param varKey key of variable or speical key selecting TextDescriptor * @param change true to change the TextDescriptor according to the bottom of the dialog; * false to gather the TextDescriptor sizes for display. * @return true if a change was made. */ private static boolean processText(ChangeParameters cp, ElectricObject owner, Variable.Key varKey, boolean change) { TextDescriptor.Size s = owner.getTextDescriptor(varKey).getSize(); if (change) { // change this text boolean changed = false; MutableTextDescriptor td = owner.getMutableTextDescriptor(varKey); if (cp.usePoints) { int size = TextUtils.atoi(cp.pointSize); if (!s.isAbsolute() || s.getSize() != size) { td.setAbsSize(size); changed = true; } } else { double size = TextUtils.atof(cp.unitSize); if (s.isAbsolute() || s.getSize() != size) { td.setRelSize(size); changed = true; } } int fontIndex = 0; if (cp.selectedFontIndex != 0) { TextDescriptor.ActiveFont newFont = TextDescriptor.ActiveFont.findActiveFont(cp.selectedFontName); if (newFont != null) fontIndex = newFont.getIndex(); } if (fontIndex != td.getFace()) { td.setFace(fontIndex); changed = true; } if (cp.isBold != td.isBold()) { td.setBold(!td.isBold()); changed = true; } if (cp.isItalic != td.isItalic()) { td.setItalic(!td.isItalic()); changed = true; } if (cp.isUnderline != td.isUnderline()) { td.setUnderline(!td.isUnderline()); changed = true; } if (changed) owner.setTextDescriptor(varKey, TextDescriptor.newTextDescriptor(td)); return changed; } // accumulate information to list the range of sizes double size = s.getSize(); if (cp.numToChange == 0) { if (s.isAbsolute()) { cp.lowPointSize = cp.highPointSize = (int)size; } else { cp.lowUnitSize = cp.highUnitSize = size; } } else { if (s.isAbsolute()) { if ((int)size < cp.lowPointSize) cp.lowPointSize = (int)size; if ((int)size > cp.highPointSize) cp.highPointSize = (int)size; } else { if (size < cp.lowUnitSize) cp.lowUnitSize = size; if (size > cp.highUnitSize) cp.highUnitSize = size; } } cp.numToChange++; return false; } private static class ChangeTextSizes extends Job { private Cell cell; private ChangeParameters cp; private ChangeTextSizes(Cell cell, ChangeParameters cp) { super("Change Text Size", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.cell = cell; this.cp = cp; startJob(); } public boolean doIt() throws JobException { cp.numNodesChanged = cp.numArcsChanged = cp.numExportsChanged = 0; cp.numAnnotationsChanged = cp.numInstancesChanged = cp.numCellsChanged = 0; changeSelectedText(cell, cp); if (cp.numNodesChanged != 0 || cp.numArcsChanged != 0 || cp.numExportsChanged != 0 || cp.numAnnotationsChanged != 0 || cp.numInstancesChanged != 0 || cp.numCellsChanged != 0) { String what = "Changed text on"; boolean others = false; if (cp.numNodesChanged != 0) { what += " " + cp.numNodesChanged + " nodes"; others = true; } if (cp.numArcsChanged != 0) { if (others) what += ", "; what += " " + cp.numArcsChanged + " arcs"; others = true; } if (cp.numExportsChanged != 0) { if (others) what += ", "; what += " " + cp.numExportsChanged + " exports"; others = true; } if (cp.numAnnotationsChanged != 0) { if (others) what += ", "; what += " " + cp.numAnnotationsChanged + " annotations"; others = true; } if (cp.numInstancesChanged != 0) { if (others) what += ", "; what += " " + cp.numInstancesChanged + " instances"; others = true; } if (cp.numCellsChanged != 0) { if (others) what += ", "; what += " " + cp.numCellsChanged + " cells"; others = true; } System.out.println(what); } return true; } } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?