📄 edif.java
字号:
if (aName.length() > base.length() && TextUtils.isDigit(aName.charAt(base.length()))) { String newName = base + "[" + aName.substring(base.length()) + "]"; putNameOnArcOnce(ai, newName); } } } } seenArcs.add(ai); for (int i = 0; i < 2; i++) { NodeInst ni = ai.getPortInst(i).getNodeInst(); if (ni.getFunction() == PrimitiveNode.Function.PIN) { // scan through this nodes portarcinst's for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); ) { Connection oCon = it.next(); ArcInst pAi = oCon.getArc(); if (!seenArcs.contains(pAi)) checkBusNames(pAi, base, seenArcs); } } } } private void doPoly() { if (curPoints.size() == 0) return; // get the bounds of the poly Point2D p0 = curPoints.get(0); double lX = p0.getX(); double lY = p0.getY(); double hX = lX; double hY = lY; for(int i=1; i<curPoints.size(); i++) { Point2D point = curPoints.get(i); if (lX > point.getX()) lX = point.getX(); if (hX < point.getX()) hX = point.getX(); if (lY > point.getY()) lY = point.getY(); if (hY < point.getY()) hY = point.getY(); } NodeProto np = curFigureGroup; if (curFigureGroup == null || curFigureGroup == Artwork.tech().boxNode) { if (curKeyword == KPOLYGON) np = Artwork.tech().closedPolygonNode; else np = Artwork.tech().openedPolygonNode; } double sX = hX - lX; double sY = hY - lY; double cX = (hX + lX) / 2; double cY = (hY + lY) / 2; double yPos = cY; if (curCellPage > 0) yPos += (curCellPage-1) * Cell.FrameDescription.MULTIPAGESEPARATION; NodeInst ni = NodeInst.makeInstance(np, new Point2D.Double(cX, yPos), sX, sY, curCell, curOrientation, null, 0); if (ni == null) { System.out.println("Error, line " + lineReader.getLineNumber() + ": could not create polygon"); errorCount++; } else { EPoint [] trace = new EPoint[curPoints.size()]; for(int i=0; i<curPoints.size(); i++) { Point2D point = curPoints.get(i); trace[i] = new EPoint(point.getX(), point.getY()); } // store the trace information ni.setTrace(trace); } freePointList(); } /** * Method to fix symbols that start with &<number> by removing the ampersand. * @param inStr the original symbol. * @return the fixed symbol. */ private String fixLeadingAmpersand(String inStr) { if (inStr.startsWith("&")) { if (inStr.length() > 1 && Character.isDigit(inStr.charAt(1))) return inStr.substring(1); } return inStr; } private String fixAngleBracketBusses(String busName) { int openAngle = busName.indexOf('<'); if (openAngle >= 0) { int closeAngle = busName.indexOf('>', openAngle); if (closeAngle >= 0) { String busPart = busName.substring(openAngle+1, closeAngle); if (busPart.startsWith("*")) busPart = ""; else busPart = "[" + busPart + "]"; busName = busName.substring(0, openAngle) + busPart + busName.substring(closeAngle+1); } } return busName; } /** * Method to convert a bus name to an individual member name. * @param name the bus name. * @param ind1 the index of the first entry. * @param ind2 the index of the second entry. * @return the specified member name. */ private String getMemberName(String name, int ind1, int ind2) { // get true name of array specification String baseName = renamedObjects.get(name); if (baseName == null) baseName = name; // find first index entry int openSq = baseName.indexOf('['); if (openSq < 0) return baseName; int closeSq = baseName.indexOf(']', openSq); if (closeSq < 0) closeSq = baseName.length(); int comma = baseName.indexOf(',', openSq); if (comma < 0) comma = baseName.length(); int endInd1 = Math.min(closeSq, comma); if (endInd1 < 0) return baseName; String index1 = baseName.substring(openSq+1, endInd1); String index2 = null; String restOfLine = baseName.substring(endInd1); if (comma >= 0 && comma < baseName.length()) { closeSq = baseName.indexOf(']', comma); if (closeSq >= 0) { index2 = baseName.substring(comma+1, closeSq); restOfLine = baseName.substring(closeSq); } } int [] indices = getIndices(index1); if (ind1 >= 0 && ind1 < indices.length) baseName = baseName.substring(0, openSq+1) + indices[ind1]; if (index2 != null) { int [] indices2 = getIndices(index2); if (ind2 >= 0 && ind2 < indices2.length) baseName += "," + indices2[ind2]; } baseName += restOfLine; return baseName; } /** * Method to examine an array specification and return all of the indices. * @param index the array specification, for example "1:5" or "4:2". * @return an array of indices, for example [1,2,3,4,5] or [4,3,2]. */ private int [] getIndices(String index) { List<Integer> indices = new ArrayList<Integer>(); for(int pos=0; pos<index.length(); ) { if (Character.isWhitespace(index.charAt(pos))) { pos++; continue; } if (Character.isDigit(index.charAt(pos))) { int val = TextUtils.atoi(index.substring(pos)); int valEnd = val; while (pos < index.length() && Character.isDigit(index.charAt(pos))) pos++; while (pos < index.length() && Character.isWhitespace(index.charAt(pos))) pos++; if (pos < index.length() && index.charAt(pos) == ':') { pos++; while (pos < index.length() && Character.isWhitespace(index.charAt(pos))) pos++; if (Character.isDigit(index.charAt(pos))) { valEnd = TextUtils.atoi(index.substring(pos)); while (pos < index.length() && Character.isDigit(index.charAt(pos))) pos++; while (pos < index.length() && Character.isWhitespace(index.charAt(pos))) pos++; } } if (valEnd < val) { for(int i=val; i>=valEnd; i--) indices.add(new Integer(i)); } else { for(int i=val; i<=valEnd; i++) indices.add(new Integer(i)); } continue; } break; } int [] retInd = new int[indices.size()]; for(int i=0; i<indices.size(); i++) retInd[i] = indices.get(i).intValue(); return retInd; } /** * Method to find a cell in the current library. * @param name the name of the cell. * @param view the view name of the cell. * @return the cell if it exists; null if not. */ private Cell findCellInLibrary(String name, String view) { for(Iterator<Cell> it = curLibrary.getCells(); it.hasNext(); ) { Cell cell = it.next(); if (cell.getName().equalsIgnoreCase(name) && cell.getView().getAbbreviation().equalsIgnoreCase(view)) return cell; } return null; } /** * Method to create a new cell. * @param libName the name of the library in which the cell will be created * (null to use the current library). * @param name the name of the cell. * @param view the view name to create. * @return the newly created cell (or existing one if allowed). */ private Cell createCell(String libName, String name, String view) { Library lib = curLibrary; if (libName != null) { Library namedLib = Library.findLibrary(libName); if (namedLib != null) lib = namedLib; } for(Iterator<Cell> it = lib.getCells(); it.hasNext(); ) { Cell cell = it.next(); if (cell.getName().equalsIgnoreCase(name) && cell.getView().getAbbreviation().equalsIgnoreCase(view)) return cell; } Cell proto = null; if (proto == null) { String cName = name; if (view.length() > 0) cName += "{" + view + "}"; proto = Cell.makeInstance(lib, cName); if (proto != null) { if (view.equals("ic")) proto.setWantExpanded(); builtCells.add(proto); } } return proto; } /**************************************** PARSING TABLE ****************************************/ private class EDIFKEY { /** the name of the keyword */ private String name; /** edif state */ private EDIFKEY [] stateArray; private EDIFKEY(String name) { this.name = name; edifKeys.put(TextUtils.canonicString(name), this); } protected void push() throws IOException {} protected void pop() throws IOException {} } private EDIFKEY KUNKNOWN = new EDIFKEY(""); private EDIFKEY KINIT = new EDIFKEY(""); private EDIFKEY KANNOTATE = new EDIFKEY("annotate"); private EDIFKEY KARC = new KeyArc(); private EDIFKEY KARRAY = new KeyArray(); private EDIFKEY KAUTHOR = new EDIFKEY ("author"); private EDIFKEY KBOOLEAN = new EDIFKEY ("boolean"); private EDIFKEY KBORDERPATTERN = new EDIFKEY ("borderpattern"); private EDIFKEY KBOUNDINGBOX = new KeyBoundingBox(); private EDIFKEY KCELL = new KeyCell(); private EDIFKEY KCELLREF = new KeyCellRef(); private EDIFKEY KCELLTYPE = new EDIFKEY("cellType"); private EDIFKEY KCIRCLE = new KeyCircle(); private EDIFKEY KCOLOR = new EDIFKEY("color"); private EDIFKEY KCOMMENT = new EDIFKEY("comment"); private EDIFKEY KCOMMENTGRAPHICS = new EDIFKEY("commentGraphics"); private EDIFKEY KCONNECTLOCATION = new EDIFKEY("connectLocation"); private EDIFKEY KCONTENTS = new EDIFKEY("contents"); private EDIFKEY KCORNERTYPE = new KeyCornerType(); private EDIFKEY KCURVE = new EDIFKEY("curve"); private EDIFKEY KDATAORIGIN = new EDIFKEY("dataOrigin"); private EDIFKEY KDCFANOUTLOAD = new EDIFKEY("dcFanoutLoad"); private EDIFKEY KDCMAXFANOUT = new EDIFKEY("dcMaxFanout"); private EDIFKEY KDELTA = new KeyDelta(); private EDIFKEY KDESIGN = new KeyDesign(); private EDIFKEY KDESIGNATOR = new EDIFKEY("designator"); private EDIFKEY KDIRECTION = new KeyDirection(); private EDIFKEY KDISPLAY = new KeyDisplay(); private EDIFKEY KDOT = new KeyDot(); private EDIFKEY KSCALEDINTEGER = new EDIFKEY("e"); private EDIFKEY KEDIF = new EDIFKEY("edif"); private EDIFKEY KEDIFLEVEL = new EDIFKEY("edifLevel"); private EDIFKEY KEDIFVERSION = new EDIFKEY("edifVersion"); private EDIFKEY KENDTYPE = new KeyEndType(); private EDIFKEY KEXTERNAL = new KeyExternal(); private EDIFKEY KFABRICATE = new KeyFabricate(); private EDIFKEY KFALSE = new KeyFalse(); private EDIFKEY KFIGURE = new KeyFigure(); private EDIFKEY KFIGUREGROUP = new EDIFKEY("figureGroup"); private EDIFKEY KFIGUREGROUPOVERRIDE = new KeyFigureGroupOverride(); private EDIFKEY KFILLPATTERN = new EDIFKEY("fillpattern"); private EDIFKEY KGRIDMAP = new EDIFKEY("gridMap"); private EDIFKEY KINSTANCE = new KeyInstance(); private EDIFKEY KINSTANCEREF = new KeyInstanceRef(); private EDIFKEY KINTEGER = new KeyInteger(); private EDIFKEY KINTERFACE = new KeyInterface(); private EDIFKEY KJOINED = new KeyJoined(); private EDIFKEY KJUSTIFY = new KeyJustify(); private EDIFKEY KKEYWORDDISPLAY = new EDIFKEY("keywordDisplay"); private EDIFKEY KEDIFKEYLEVEL = new EDIFKEY("keywordLevel"); private EDIFKEY KEDIFKEYMAP = new EDIFKEY("keywordMap"); private EDIFKEY KLIBRARY = new KeyLibrary(); private EDIFKEY KLIBRARYREF = new LibraryRef(); private EDIFKEY KLISTOFNETS = new EDIFKEY("listOfNets"); private EDIFKEY KLISTOFPORTS = new EDIFKEY("listOfPorts"); private EDIFKEY KMEMBER = new KeyMember(); private EDIFKEY KNAME = new KeyName(); private EDIFKEY KNET = new KeyNet(); private EDIFKEY KNETBUNDLE = new KeyNetBundle(); private EDIFKEY KNUMBER = new KeyNumber(); private EDIFKEY KNUMBERDEFINITION = new EDIFKEY("numberDefinition"); private EDIFKEY KOPENSHAPE = new KeyOpenShape(); private EDIFKEY KORIENTATION = new KeyOrientation(); private EDIFKEY KORIGIN = new EDIFKEY("origin"); private EDIFKEY KOWNER = new EDIFKEY("owner"); private EDIFKEY KPAGE = new KeyPage(); private EDIFKEY KPAGESIZE = new EDIFKEY("pageSize"); private EDIFKEY KPATH = new KeyPath(); private EDIFKEY KPATHWIDTH = new KeyPathWidth(); private EDIFKEY KPOINT = new EDIFKEY("point"); private EDIFKEY KPOINTLIST = new EDIFKEY("pointList"); private EDIFKEY KPOLYGON = new KeyPolygon(); private EDIFKEY KPORT = new KeyPort(); private EDIFKEY KPORTBUNDLE = new EDIFKEY("portBundle"); private EDIFKEY KPORTIMPLEMENTATION = new KeyPortImplementation(); private EDIFKEY KPORTINSTANCE = new EDIFKEY("portInstance"); private EDIFKEY KPORTLIST = new KeyPortList(); private EDIFKEY KPORTREF = new KeyPortRef(); private EDIFKEY KPROGRAM = new KeyProgram(); private EDIFKEY KPROPERTY = new KeyProperty(); private EDIFKEY KPROPERTYDISPLAY = new EDIFKEY("propertyDisplay"); private EDIFKEY KPT = new KeyPt(); private EDIFKEY KRECTANGLE = new KeyRectangle(); private EDIFKEY KRENAME = new KeyRename(); private EDIFKEY KSCALE = new EDIFKEY("scale"); private EDIFKEY KSCALEX = new EDIFKEY("scaleX"); private EDIFKEY KSCALEY = new EDIFKEY("scaleY"); private EDIFKEY KSHAPE = new EDIFKEY("shape"); private EDIFKEY KSTATUS = new EDIFKEY("status"); private EDIFKEY KSTRING = new KeyString(); private EDIFKEY KSTRINGDISPLAY = new KeyStringDisplay(); private EDIFKEY KSYMBOL = new KeySymbol(); private EDIFKEY KTECHNOLOGY = new KeyTechnology(); private EDIFKEY KTEXTHEIGHT = new KeyTextHeight(); private EDIFKEY KTIMESTAMP = new EDIFKEY("timestamp"); private EDIFKEY KTRANSFORM = new KeyTransform(); private EDIFKEY KTRUE = new KeyTrue(); private EDIFKEY KUNIT = new KeyUnit(); private EDIFKEY KUSERDATA = new EDIFKEY("userData"); private EDIFKEY KVERSION = new EDIFKEY("version"); private EDIFKEY KVIEW = new KeyView(); private EDIFKEY KVIEWREF = new ViewRef(); private EDIFKEY KVIEWTYPE = new KeyViewType(); private EDIFKEY KVISIBLE = new EDIFKEY("visible"); private EDIFKEY KWRITTEN = new EDIFKEY("written"); private class KeyArc extends EDIFKEY { private KeyArc() { super("arc"); } protected void pop() { // set array values if (curPoints.size() >= 3) { double [] x = new double[3]; double [] y = new double[3]; Point2D p0 = curPoints.get(0); Point2D p1 = curPoints.get(1); Point2D p2 = curPoints.get(2); x[0] = p0.getX(); y[0] = p0.getY(); x[1] = p1.getX(); y[1] = p1.getY(); x[2] = p2.getX(); y[2] = p2.getY(); makeArc(x, y); } freePointList(); } } private class KeyArray extends EDIFKEY { private KeyArray() { super("array"); } protected void push() throws IOException { // note array is a special process integer value function isArray = true; arrayXVal = arrayYVal = 0; deltaPointXX = deltaPointXY = 0; deltaPointYX = deltaPointYY = 0; deltaPointsSet = false; if (checkName()) { if (keyStack[keyStackDepth-1] == KCELL) { cellName = cellReference = fixLeadingAmpersand(objectName); } else if (keyStack[keyStackDepth-1] == KPORT) { portName = portReference = fixLeadingAmpersand(objectName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -