📄 applicon860.java
字号:
appleGetWord(); // tfield appleGetWord(); // torien tcount = appleGetWord(); if ((tcount&1) != 0) tcount++; // allocate and read the string str = ""; for(int k=0; k<tcount; k++) str += dataInputStream.readByte(); // remove line-feeds, count carriage-returns i = 0; StringBuffer sb = new StringBuffer(); for(int k=0; k<str.length(); k++) { char ch = str.charAt(k); if (ch == '\r') { sb.append('\n'); i++; } else if (ch != '\n') sb.append(ch); } str = sb.toString(); if (ni != null) { if (i <= 1) { // one carriage return: simple message int crPos = str.indexOf('\n'); if (crPos >= 0) str = str.substring(0, crPos); TextDescriptor td = TextDescriptor.getNodeTextDescriptor().withDisplay(true); ni.newVar(Artwork.ART_MESSAGE, str, td); } else { // multi-line message String [] message = str.split("\n"); TextDescriptor td = TextDescriptor.getNodeTextDescriptor().withDisplay(true); ni.newVar(Artwork.ART_MESSAGE, message, td); } } break; case 4: // cell name record if (length != 17) { System.out.println("Cell name length=" + length); return false; } cellname = ""; for(int k=0; k<30; k++) cellname += dataInputStream.readByte(); st = cellname.indexOf(']') + 1; i = cellname.indexOf('.', st); if (i >= 0) cellname = cellname.substring(0, i); subnp = lib.findNodeProto(cellname); if (subnp == null) { System.out.println("Instance of cell '" + cellname.substring(st) + "' not found"); return false; } break; case 5: // cell instance header record if (length != 6) { System.out.println("Cell instance header length=" + length); return false; } appleGetWord(); appleGetWord(); appleGetWord(); // numcir appleGetWord(); // textflg break; case 105: // cell instance record length -= 2; for(i=0; i<length; i++) cidata[i] = appleGetWord(); // get first point x1 = cidata[0] & 0xFFFF; x1 |= (cidata[1] & 0xFFFF) << 16; y1 = cidata[2] & 0xFFFF; y1 |= (cidata[3] & 0xFFFF) << 16; x1 = appleScale(x1, xoff, scale); y1 = appleScale(y1, yoff, scale); i = 5; // ignore stretch point if ((cidata[length-1]&2) != 0) i += 5; // get transformation matrix int rot = 0, trans = 0; if ((cidata[length-1]&4) != 0) { a1 = cidata[i] & 0xFFFF; a1 |= (cidata[i+1] & 0xFFFF) << 16; if (a1 == -2147483647) a1 = -1; else if (a1 == 2147483647) a1 = 1; else a1 = 0; a2 = cidata[i+2] & 0xFFFF; a2 |= (cidata[i+3] & 0xFFFF) << 16; if (a2 == -2147483647) a2 = -1; else if (a2 == 2147483647) a2 = 1; else a2 = 0; a3 = cidata[i+4] & 0xFFFF; a3 |= (cidata[i+5] & 0xFFFF) << 16; if (a3 == -2147483647) a3 = -1; else if (a3 == 2147483647) a3 = 1; else a3 = 0; a4 = cidata[i+6] & 0xFFFF; a4 |= (cidata[i+7] & 0xFFFF) << 16; if (a4 == -2147483647) a4 = -1; else if (a4 == 2147483647) a4 = 1; else a4 = 0; // convert to rotation/transpose if (a1 == 0 && a2 == -1 && a3 == 1 && a4 == 0) rot = 900; if (a1 == -1 && a2 == 0 && a3 == 0 && a4 == -1) rot = 1800; if (a1 == 0 && a2 == 1 && a3 == -1 && a4 == 0) rot = 2700; if (a1 == 0 && a2 == -1 && a3 == -1 && a4 == 0) { trans = 1; } if (a1 == -1 && a2 == 0 && a3 == 0 && a4 == 1) { rot = 900; trans = 1; } if (a1 == 0 && a2 == 1 && a3 == 1 && a4 == 0) { rot = 1800; trans = 1; } if (a1 == 1 && a2 == 0 && a3 == 0 && a4 == -1) { rot = 2700; trans = 1; } i += 8; } if (subnp != null && curfacet != null) { // determine center of instance Orientation orient = Orientation.fromC(rot, trans != 0); AffineTransform mat = orient.pureRotate(); Rectangle2D subBounds = subnp.getBounds(); Point2D dest = new Point2D.Double(0, 0); mat.transform(new Point2D.Double(subBounds.getCenterX(), subBounds.getCenterY()), dest); double vx = dest.getX() + x1; double vy = dest.getY() + y1; Point2D center = new Point2D.Double(subBounds.getWidth(), subBounds.getHeight()); ni = NodeInst.newInstance(subnp, center, vx*2, vy*2, curfacet, orient, null, 0); if (ni == null) return false; } break; case 255: // end definition record if (length != 2) { System.out.println("End definition length=" + length); return false; } if (curfacet == null) { System.out.println("End definition has no associated begin"); return false; } curfacet = null; break; case 0: // format record for(i=0; i<length-2; i++) appleGetWord(); break; case 1: // title record for(i=0; i<length-2; i++) appleGetWord(); break; case 100: // group record for(i=0; i<length-2; i++) appleGetWord(); break; case 104: // auxiliary record for(i=0; i<length-2; i++) appleGetWord(); break; default: System.out.println("Unknown record type: " + type); return true; } }// return true; } /** * Method to get the chain value from disk. * Automatically senses byte swapping and tape/disk format. */ private int appleGetChain() throws IOException { int chain; if ((appleState&INITIALIZED) == 0) { // on first call, evaluate nature of file appleState |= INITIALIZED; chain = appleGetWord(); if (chain == 3 || chain == 1) return(chain); // tape header may be present if (Character.isDigit(chain&0377) && Character.isDigit((chain>>8)&0377)) { appleGetWord(); appleState |= TAPEFORMAT; chain = appleGetWord(); } // bytes may be swapped if (chain == 0x300 || chain == 0x100) { appleState |= BYTESSWAPPED; chain >>= 8; } return chain; } // normal chain request if ((appleState&TAPEFORMAT) != 0) { // get 4-digit code, skip to end of block for(int i=0; i<4; i++) { int val = dataInputStream.readByte(); updateProgressDialog(2); if (Character.isDigit(val)) continue; i--; } } chain = appleGetWord(); return chain; } private int appleGetWord() throws IOException { byte low = dataInputStream.readByte(); byte high = dataInputStream.readByte(); updateProgressDialog(2); if ((appleState&BYTESSWAPPED) == 0) return (low&0377) | ((high&0377)<<8); return (high&0377) | ((low&0377)<<8); } /** * Method to convert the Apple floating point representation in "lo", "hi" * and "exp" into a true floating point number */ private double appleFloat(int lo, int hi, int exp) { int i; double fl; i = (lo & 0xFFFF) | ((hi & 0xFFFF) << 16); exp = 31 - exp; fl = i & 0x7FFFFFFF; fl /= (1 << exp); if ((i & 0x80000000) != 0) fl = -fl; return(fl); } static Poly poly = null; private void setupAppleLayers() { Technology tech = Technology.getCurrent(); for(Iterator<PrimitiveNode> it = tech.getNodes(); it.hasNext(); ) { PrimitiveNode pn = it.next(); if (pn.getFunction() == PrimitiveNode.Function.NODE) { NodeLayer [] nls = pn.getLayers(); for(int i=0; i<nls.length; i++) { NodeLayer nl = nls[i]; Layer lay = nl.getLayer(); int appleLayer = lay.getIndex(); // TODO: should get the user-specified apple/860 layer appleNodeMap.put(new Integer(appleLayer), pn); } } } } /** * Method to convert from Apple units, through offset "offset" and scale * "scale" and return the proper value */ private int appleScale(int value, int offset, double scale) { double temp; temp = value - offset; temp = temp * scale; value = (int)temp; // round to the nearest quarter micron if ((value % 25) != 0) { if (value > 0) value = (value+12) / 25 * 25; else value = (value-12) / 25 * 25; } return(value); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -