📄 libraryfiles.java
字号:
} else { // old version: just use transpose information if (nil.transpose[nodeIndex] != 0) { flipY = true; rotation = (rotation + 900) % 3600; } } Orientation orient = Orientation.fromJava(rotation, flipX, flipY); // figure out the grab center if this is a cell instance if (proto instanceof Cell) { if (nil.anchorX != null)// if (magic <= ELIBConstants.MAGIC13) { // version 13 and later stores and uses anchor location double anchorX = (nil.anchorX[nodeIndex]-xoff) / lambda; double anchorY = (nil.anchorY[nodeIndex]-yoff) / lambda; center.setLocation(anchorX, anchorY); } else { Cell subCell = (Cell)proto; Rectangle2D bounds = subCell.getBounds(); Point2D shift = new Point2D.Double(-bounds.getCenterX(), -bounds.getCenterY()); AffineTransform trans = orient.pureRotate(); trans.transform(shift, shift); center.setLocation(center.getX() + shift.getX(), center.getY() + shift.getY()); } } int flags = ImmutableNodeInst.flagsFromElib(nil.userBits[nodeIndex]); int techBits = ImmutableNodeInst.techSpecificFromElib(nil.userBits[nodeIndex]); NodeInst ni = NodeInst.newInstance(parent, proto, nil.name[nodeIndex], nil.nameTextDescriptor[nodeIndex], center, size, orient, flags, techBits, nil.protoTextDescriptor[nodeIndex], Input.errorLogger); nil.theNode[nodeIndex] = ni;// if (proto instanceof PrimitiveNode) {// PrimitiveNode pn = (PrimitiveNode)proto;// PrimitiveNode.NodeSizeRule nodeSizeRule = pn.getMinSizeRule();// if (nodeSizeRule != null) {// if (size.getLambdaX() < nodeSizeRule.getWidth())// Input.errorLogger.logWarning(" (" + parent + ") node " + ni.getName() + " width is less than minimum by " +// (nodeSizeRule.getWidth() - size.getLambdaX()), ni, parent, null, 2);// if (size.getLambdaY() < nodeSizeRule.getHeight())// Input.errorLogger.logWarning(" (" + parent + ") node " + ni.getName() + " height is less than minimum by " +// (nodeSizeRule.getHeight() - size.getLambdaY()), ni, parent, null, 2);// }// } if (ni == null) return; Variable[] vars = nil.vars[nodeIndex]; if (vars != null) { for (int j = 0; j < vars.length; j++) { Variable var = vars[j]; if (var == null) continue; // convert outline information if (var.getKey() == NodeInst.TRACE && proto instanceof PrimitiveNode && ((PrimitiveNode)proto).isHoldsOutline() ) { Object value = var.getObject(); if (value instanceof Integer[] || value instanceof Float[]) { // convert outline information, if present Number[] outline = (Number[])value; int newLength = outline.length / 2; EPoint [] newOutline = new EPoint[newLength]; double lam = outline instanceof Integer[] ? lambda : 1.0; for(int k=0; k<newLength; k++) { double oldX = outline[k*2].doubleValue()/lam; double oldY = outline[k*2+1].doubleValue()/lam; if (!Double.isNaN(oldX) && !Double.isNaN(oldY)) newOutline[k] = new EPoint(oldX, oldY); } var = var.withObject(newOutline); } } if (ni.isDeprecatedVariable(var.getKey())) continue; if (ni.isParam(var.getKey())) ni.addParameter(var); else ni.addVar(var.withParam(false)); } } // if this was a dummy cell, log instance as an error so the user can find easily if (proto instanceof Cell && ((Cell)proto).getVar(IO_DUMMY_OBJECT) != null) { Input.errorLogger.logError("Instance of dummy cell "+proto.getName(), ni, parent, null, 1); } } void realizeVariables(ElectricObject eObj, Variable[] vars) { if (vars == null) return; for (Variable var: vars) realizeVariable(eObj, var); } private void realizeVariable(ElectricObject eObj, Variable var) { if (var == null || eObj.isDeprecatedVariable(var.getKey())) return; if (eObj.isParam(var.getKey()) && eObj instanceof NodeInst) { ((NodeInst)eObj).addParameter(var); return; } var = var.withParam(false); String origVarName = var.getKey().toString(); // convert old port variables if (eObj instanceof NodeInst && var.getKey().getName().startsWith("ATTRP_")) { NodeInst ni = (NodeInst)eObj; // the form is "ATTRP_portName_variableName" with "\" escapes StringBuffer portName = new StringBuffer(); String varName = null; int len = origVarName.length(); for(int j=6; j<len; j++) { char ch = origVarName.charAt(j); if (ch == '\\') { j++; portName.append(origVarName.charAt(j)); continue; } if (ch == '_') { varName = origVarName.substring(j+1); break; } portName.append(ch); } if (varName != null) { String thePortName = portName.toString(); PortProto pp = findPortProto(ni.getProto(), thePortName); PortInst pi = pp != null ? ni.findPortInstFromProto(pp) : null; if (pi != null) { pi.newVar(Variable.newKey(varName), var.getObject(), var.getTextDescriptor()); return; } } } eObj.addVar(var); } static PortProto findPortProto(NodeProto np, String portId) { PortProtoId portProtoId = np.getId().newPortId(portId); PortProto pp = np.getPort(portProtoId); if (pp != null) return pp; if (np.getNumPorts() == 1 && portId.length() == 0) return np.getPort(0); if (np instanceof PrimitiveNode) { PrimitiveNode primNode = (PrimitiveNode)np; pp = (PrimitivePort)primNode.findPortProto(portId); if (pp == null) pp = primNode.getTechnology().convertOldPortName(portId, primNode); } return pp; } /** * Method to add meaning preferences to an ElectricObject from a List of strings. * @param obj the Object to augment with meaning preferences. * @param vars Variables with meaning preferences. */ void realizeMeaningPrefs(Object obj, Variable[] vars) { realizeMeaningPrefs(projectSettings, obj, vars); } /** * Method to add meaning preferences to an ElectricObject from a List of strings. * @param projectSettings a map for result * @param obj the Object to augment with meaning preferences. * @param vars Variables with meaning preferences. */ static void realizeMeaningPrefs(HashMap<Setting,Object> projectSettings, Object obj, Variable[] vars) { for (int i = 0; i < vars.length; i++) { Variable var = vars[i]; if (var == null) continue; Object value = var.getObject(); if (!(value instanceof String)) { if (value instanceof Short || value instanceof Byte) value = new Integer(((Number)value).intValue()); if (!(value instanceof Number) && !(value instanceof Boolean)) continue; } String prefName = var.getKey().getName(); String prefPath = null; if (obj instanceof Technology) { prefPath = ((Technology)obj).getTechnologyPreferences().absolutePath() + "/"; Map<Setting,Object> convertedVars = ((Technology)obj).convertOldVariable(prefName, value); if (convertedVars != null) { for (Map.Entry<Setting,Object> e: convertedVars.entrySet()) { Setting setting = e.getKey(); prefName = setting.getPrefName(); value = e.getValue(); projectSettings.put(setting, value); } continue; } } else if (obj instanceof Tool) { prefPath = ((Tool)obj).prefs.absolutePath() + "/"; } Setting setting = Setting.getSettingByPrefPath(prefPath + prefName); if (setting != null) projectSettings.put(setting, value); } } TextDescriptor makeDescriptor(int td0, int td1) { mtd.setCBits(td0, fixTextDescriptorFont(td1)); return TextDescriptor.newTextDescriptor(mtd); } TextDescriptor makeDescriptor(int td0, int td1, int flags) { mtd.setCBits(td0, fixTextDescriptorFont(td1), flags); return TextDescriptor.newTextDescriptor(mtd); } /** * Method to grab font associations that were stored on a Library. * The font associations are used later to convert indices to true font names and numbers. * @param associationArray array from FONT_ASSOCIATIONS variable. */ void setFontNames(String[] associationArray) { int maxAssociation = 0; for(int i=0; i<associationArray.length; i++) { if (associationArray[i] == null) continue; int fontNumber = TextUtils.atoi(associationArray[i]); if (fontNumber > maxAssociation) maxAssociation = fontNumber; } if (maxAssociation <= 0) return; fontNames = new String[maxAssociation]; for(int i=0; i<maxAssociation; i++) fontNames[i] = null; for(int i=0; i<associationArray.length; i++) { if (associationArray[i] == null) continue; int fontNumber = TextUtils.atoi(associationArray[i]); if (fontNumber <= 0) continue; int slashPos = associationArray[i].indexOf('/'); if (slashPos < 0) continue; fontNames[fontNumber-1] = associationArray[i].substring(slashPos+1); } } /** * Method to convert the font number in a TextDescriptor to the proper value as * cached in the Library. The caching is examined by "getFontAssociationVariable()". * @param descriptor1 value of descriptor1 from disk. * @return patched value of descriptor1. */ private int fixTextDescriptorFont(int descriptor1) { int fontNumber = (descriptor1 & ELIBConstants.VTFACE) >> ELIBConstants.VTFACESH; if (fontNumber == 0) return descriptor1; descriptor1 &= ~ELIBConstants.VTFACE; if (fontNames != null && fontNumber <= fontNames.length) { String fontName = fontNames[fontNumber-1]; TextDescriptor.ActiveFont af = TextDescriptor.ActiveFont.findActiveFont(fontName); if (af != null) { fontNumber = af.getIndex(); if (fontNumber <= (ELIBConstants.VTFACE >> ELIBConstants.VTFACESH)) descriptor1 |= fontNumber << ELIBConstants.VTFACESH; } } return descriptor1; } /** * Set line number for following errors and warnings. * @param lineNumber line numnber for following erros and warnings. */ void setLineNumber(int lineNumber) {} /** * Issue error message. * @param message message string. * @return MessageLog object for attaching further geometry details. */ void logError(String message) { errorCount++; System.out.println(message); errorLogger.logError(message, -1); } /** * Issue warning message. * @param message message string. * @return MessageLog object for attaching further geometry details. */ void logWarning(String message) { System.out.println(message); errorLogger.logWarning(message, null, -1); } // *************************** THE CELL CLEANUP INTERFACE *************************** protected void computeTech(Cell cell, Set uncomputedCells) { uncomputedCells.remove(cell); } protected double computeLambda(Cell cell, int cellIndex) { return 1; } protected boolean spreadLambda(Cell cell, int cellIndex) { return false; } protected boolean canScale() { return false; } /** * Method to recursively create the contents of each cell in the library. */ abstract void realizeCellsRecursively(Cell cell, HashSet<Cell> recursiveSetupFlag, String scaledCellName, double scale);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -