📄 output.java
字号:
} else if (type == FileType.ECAD) { ECAD.writeECADFile(cell, context, filePath); } else if (type == FileType.EDIF) { EDIF.writeEDIFFile(cell, context, filePath); } else if (type == FileType.ESIM || type == FileType.RSIM) { Sim.writeSimFile(cell, context, filePath, type); } else if (type == FileType.FASTHENRY) { FastHenry.writeFastHenryFile(cell, context, filePath); } else if (type == FileType.HPGL) { HPGL.writeHPGLFile(cell, context, filePath); } else if (type == FileType.GDS) { GDS.writeGDSFile(cell, context, filePath); } else if (type == FileType.IRSIM) { Technology layoutTech = Schematics.getDefaultSchematicTechnology(); IRSIM.writeIRSIMFile(cell, context, layoutTech, filePath); } else if (type == FileType.L) { L.writeLFile(cell, filePath); } else if (type == FileType.LEF) { LEF.writeLEFFile(cell, context, filePath); } else if (type == FileType.MAXWELL) { Maxwell.writeMaxwellFile(cell, context, filePath); } else if (type == FileType.MOSSIM) { MOSSIM.writeMOSSIMFile(cell, context, filePath); } else if (type == FileType.PADS) { Pads.writePadsFile(cell, context, filePath); } else if (type == FileType.PAL) { PAL.writePALFile(cell, context, filePath); } else if (type == FileType.POSTSCRIPT || type == FileType.EPS) { PostScript.writePostScriptFile(cell, filePath, override); } else if (type == FileType.SILOS) { Silos.writeSilosFile(cell, context, filePath); } else if (type == FileType.SKILL) { IOTool.writeSkill(cell, filePath, false); } else if (type == FileType.SKILLEXPORTSONLY) { IOTool.writeSkill(cell, filePath, true); } else if (type == FileType.SPICE) { Spice.writeSpiceFile(cell, context, filePath, false); } else if (type == FileType.TEGAS) { Tegas.writeTegasFile(cell, context, filePath); } else if (type == FileType.VERILOG) { Verilog.writeVerilogFile(cell, context, filePath); } } /** * Returns variable disk name. Usually it is variable name. * Disk name of PortInst variables is key ATTRP_portName_varName. * @param owner owner of the Variable. * @param var Variable. * @return disk name of variable. */ String diskName(ElectricObject owner, Variable var) { String portName = null; if (owner instanceof PortInst) { PortInst pi = (PortInst)owner; portName = pi.getPortProto().getName(); } return diskName(portName, var); } /** * Returns variable disk name. Usually it is variable name. * Disk name of PortInst variables is key ATTRP_portName_varName. * @param portName port name or null. * @param var Variable. * @return disk name of variable. */ String diskName(String portName, Variable var) { if (portName == null) return var.getKey().getName(); StringBuffer sb = new StringBuffer("ATTRP_"); for (int i = 0; i < portName.length(); i++) { char ch = portName.charAt(i); if (ch == '\\' || ch == '_') sb.append('\\'); sb.append(ch); } sb.append('_'); sb.append(var.getKey().getName()); return sb.toString(); } /** * Opens output for writing binary files. * @param filePath the name of the file. * @return true on error. */ protected boolean openBinaryOutputStream(String filePath) { this.filePath = filePath; FileOutputStream fileOutputStream; try { fileOutputStream = new FileOutputStream(filePath); } catch (FileNotFoundException e) { System.out.println("Could not write file " + filePath); System.out.println("Reason: " + e.getMessage()); return true; } BufferedOutputStream bufStrm = new BufferedOutputStream(fileOutputStream); dataOutputStream = new DataOutputStream(bufStrm); return false; } /** * Close output for writing binary to a file. * @return true on error. */ protected boolean closeBinaryOutputStream() { try { dataOutputStream.close(); } catch (IOException e) { System.out.println("Error closing " + filePath); return true; } return false; } /** * Open output for writing text to a file. * @param filePath the name of the file. * @return true on error. */ protected boolean openTextOutputStream(String filePath) { this.filePath = filePath; try { printWriter = new PrintWriter(new BufferedWriter(new FileWriter(filePath))); } catch (IOException e) { System.out.println("Error opening " + filePath+": "+e.getMessage()); return true; } return false; } /** * Close output for writing text to a file. * @return true on error. */ protected boolean closeTextOutputStream() { printWriter.close(); return false; } /** * Open output for collecting a list of strings. */ protected void openStringsOutputStream() { stringWriter = new StringWriter(); } /** * Close output for collecting a list of strings. * @return the list of strings. */ protected List<String> closeStringsOutputStream() { StringBuffer sb = stringWriter.getBuffer(); String [] lines = sb.toString().split("\n"); List<String> strings = new ArrayList<String>(); for(int i=0; i<lines.length; i++) strings.add(lines[i]); return strings; } /** * Method to write copyright header information to the output. * @param prefix the characters that start a line of commented output. * @param postfix the characters that end a line of commented output. */ protected void emitCopyright(String prefix, String postfix) { if (!IOTool.isUseCopyrightMessage()) return; String str = IOTool.getCopyrightMessage(); int start = 0; while (start < str.length()) { int endPos = str.indexOf('\n', start); if (endPos < 0) endPos = str.length(); String oneLine = str.substring(start, endPos); writeChunk(prefix + oneLine + postfix + "\n"); start = endPos+1; } } /** number of characters written on a line */ private int lineCharCount = 0; private int maxWidth = 80; private boolean strictWidthLimit = false; private String continuationString = ""; /** * Method to set the size of a line of output. * @param width the maximum number of characters on a line of output (default is 80). * @param strict true to strictly enforce the line-width limit, even if it means breaking * a symbol in the middle. When false, very long names may exceed the width limit. */ protected void setOutputWidth(int width, boolean strict) { maxWidth = width; strictWidthLimit = strict; } /** * Method to set the string that will be emitted at the start of a "continuation line". * The continuation line is the line that follows a line which is broken up because * of width limits. * @param str the string that will be emitted at the start of a "continuation line". */ protected void setContinuationString(String str) { continuationString = str; } private void writeChunk(String str) { int len = str.length(); if (len <= 0) return; if (printWriter != null) printWriter.print(str); else if (stringWriter != null) stringWriter.write(str); lineCharCount += len; if (str.charAt(len-1) == '\n') lineCharCount = 0; } /** * Method to add a string to the output, limited by the maximum * width of an output line. * @param str the string to add to the output. */ protected void writeWidthLimited(String str) { for(;;) { int len = str.length(); if (len <= 0) break; int i = str.indexOf('\n'); if (i < 0) i = len; else i++; if (lineCharCount + i < maxWidth) { // the next chunk fits: write it String chunk = str; if (i < len) chunk = str.substring(0, i); writeChunk(chunk); str = str.substring(i); if (str.length() == 0) break; continue; } // find place to break the line String exact = str.substring(0, maxWidth - lineCharCount); int splitPos = exact.lastIndexOf(' '); if (splitPos < 0) { int commaPos = exact.lastIndexOf(','); if (commaPos > splitPos) splitPos = commaPos; int openPos = exact.lastIndexOf('('); if (openPos > splitPos) splitPos = openPos; int closePos = exact.lastIndexOf(')'); if (closePos > splitPos) splitPos = closePos; int semiPos = exact.lastIndexOf(';'); if (semiPos > splitPos) splitPos = semiPos; if (splitPos < 0) { splitPos = exact.length()-1; if (!strictWidthLimit) { splitPos = str.length()-1; int spacePos = str.indexOf(' '); if (spacePos >= 0 && spacePos < splitPos) splitPos = spacePos; commaPos = str.indexOf(','); if (commaPos >= 0 && commaPos < splitPos) splitPos = commaPos; openPos = str.indexOf('('); if (openPos >= 0 && openPos < splitPos) splitPos = openPos; closePos = str.indexOf(')'); if (closePos >= 0 && closePos < splitPos) splitPos = closePos; semiPos = str.indexOf(';'); if (semiPos >= 0 && semiPos < splitPos) splitPos = semiPos; } } } while (splitPos+1 < str.length() && str.charAt(splitPos+1) == '\n') splitPos++; exact = str.substring(0, splitPos+1); writeChunk(exact); if (!exact.endsWith("\n")) { writeChunk("\n"); if (continuationString.length() > 0) writeChunk(continuationString); } str = str.substring(exact.length()); } } /** * Method to determine the area of a cell that is to be printed. * Returns null if the area cannot be determined. */ public static Rectangle2D getAreaToPrint(Cell cell, boolean reduce, EditWindow_ wnd) { ERectangle cb = cell.getBounds(); Rectangle2D bounds = new Rectangle2D.Double(cb.getMinX(), cb.getMinY(), cb.getWidth(), cb.getHeight()); if (wnd != null) bounds = wnd.getBoundsInWindow(); // extend it and make it square if (reduce) { double wid = bounds.getWidth() * 0.75; double hei = bounds.getHeight() * 0.75;// us_squarescreen(el_curwindowpart, NOWINDOWPART, FALSE, lx, hx, ly, hy, 0); bounds.setRect(bounds.getCenterX(), bounds.getCenterY(), wid, hei); } if (IOTool.getPlotArea() != 0) { if (wnd == null) { System.out.println("No current window: printing entire cell"); } else { if (IOTool.getPlotArea() == 2) { bounds = wnd.getDisplayedBounds(); } else { Rectangle2D hBounds = wnd.getHighlightedArea(); if (hBounds == null || hBounds.getWidth() == 0 || hBounds.getHeight() == 0) { System.out.println("Warning: no highlighted area; printing entire cell"); } else { bounds = hBounds; } } } } return bounds; } /** * Class to define cell information during output. */ public static class OutputCellInfo extends Job { private Cell cell; private VarContext context; private String filePath; private FileType type; private List<PolyBase> override; /** * @param cell the Cell to be written. * @param context the VarContext of the Cell (its position in the hierarchy above it). * @param filePath the path to the disk file to be written. * @param override the list of Polys to write instead of cell contents. */ public OutputCellInfo(Cell cell, VarContext context, String filePath, FileType type, List<PolyBase> override) { super("Export "+cell+" ("+type+")", IOTool.getIOTool(), Job.Type.EXAMINE, null, null, Priority.USER); this.cell = cell; this.context = context; this.filePath = filePath; this.type = type; this.override = override; startJob(); } public boolean doIt() throws JobException { writeCell(cell, context, filePath, type, override); return true; } } /** * Class to write a library in a CHANGE Job. * Used by regressions that need to queue the output after existing change jobs. */ public static class WriteJELIB extends Job { private Library lib; private String newName; private IdMapper idMapper; public WriteJELIB(Library lib, String newName) { super("Write "+lib, User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.lib = lib; this.newName = newName; startJob(); } public boolean doIt() throws JobException { boolean error = false; try { if (newName != null) { URL libURL = TextUtils.makeURLToFile(newName); lib.setLibFile(libURL); idMapper = lib.setName(TextUtils.getFileNameWithoutExtension(libURL)); if (idMapper != null) lib = EDatabase.serverDatabase().getLib(idMapper.get(lib.getId())); } fieldVariableChanged("idMapper"); error = Output.writeLibrary(lib, FileType.JELIB, false, false, false); } catch (Exception e) { throw new JobException("Exception caught when saving library: " + e.getMessage()); } return !error; } public void terminateOK() { User.fixStaleCellReferences(idMapper); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -