?? gds.java
字號:
boolean trans = false; if (theToken == GDS_STRANS) { ReadOrientation ro = new ReadOrientation(); ro.doIt(); angle = ro.angle; trans = ro.trans; } int nCols = 0, nRows = 0; if (theToken == GDS_COLROW) { getToken(); nCols = tokenValue16; getToken(); nRows = tokenValue16; getToken(); } if (theToken != GDS_XY) handleError("Array reference has no parameters"); getToken(); determinePoints(3, 3); // see if the instance is a single object if (TALLYCONTENTS) { countARef++; countATotal += nCols*nRows; return; } boolean mY = false; boolean mX = false; if (trans) { mY = true; angle = (angle + 900) % 3600; } Point2D colInterval = new Point2D.Double(0, 0); if (nCols != 1) { colInterval.setLocation((theVertices[1].getX() - theVertices[0].getX()) / nCols, (theVertices[1].getY() - theVertices[0].getY()) / nCols); } Point2D rowInterval = new Point2D.Double(0, 0); if (nRows != 1) { rowInterval.setLocation((theVertices[2].getX() - theVertices[0].getX()) / nRows, (theVertices[2].getY() - theVertices[0].getY()) / nRows); } theCell.makeInstanceArray(theNodeProto, nCols, nRows, Orientation.fromJava(angle, mX, mY), theVertices[0], rowInterval, colInterval); } private class ReadOrientation { private int angle; private boolean trans; private double scale; private void doIt() throws IOException { double anglevalue = 0.0; scale = 1.0; boolean mirror_x = false; getToken(); if (theToken != GDS_FLAGSYM) handleError("Structure reference is missing its flags field"); if ((tokenFlags&0100000) != 0) mirror_x = true; getToken(); if (theToken == GDS_MAG) { getToken(); scale = tokenValueDouble; getToken(); } if (theToken == GDS_ANGLE) { getToken(); anglevalue = tokenValueDouble * 10; getToken(); } angle = ((int)anglevalue) % 3600; trans = mirror_x; if (trans) angle = (2700 - angle) % 3600; // should not happen...*/ if (angle < 0) angle = angle + 3600; } } private void determineSRef() throws IOException { getToken(); readUnsupported(unsupportedSet); if (theToken != GDS_SNAME) handleError("Structure reference name is missing"); getToken(); getPrototype(tokenString); getToken(); int angle = 0; boolean trans = false; if (theToken == GDS_STRANS) { ReadOrientation ro = new ReadOrientation(); ro.doIt(); angle = ro.angle; trans = ro.trans; } if (theToken != GDS_XY) handleError("Structure reference has no translation value"); getToken(); determinePoints(1, 1); if (TALLYCONTENTS) { countSRef++; return; } Point2D loc = new Point2D.Double(theVertices[0].getX(), theVertices[0].getY()); boolean mY = false; if (trans) { mY = true; angle = (angle + 900) % 3600; } theCell.makeInstance(theNodeProto, loc, Orientation.fromJava(angle, false, mY), 0, 0, null); } private void determineShape() throws IOException { getToken(); readUnsupported(unsupportedSet); determineLayer(); getToken(); if (theToken != GDS_XY) handleError("Boundary has no points"); getToken(); int n = determinePoints(3, MAXPOINTS); if (TALLYCONTENTS) { countShape++; return; } determineBoundary(n); } private void determineBoundary(int npts) { boolean is90 = true; boolean is45 = true; for (int i=0; i<npts-1 && i<MAXPOINTS-1; i++) { double dx = theVertices[i+1].getX() - theVertices[i].getX(); double dy = theVertices[i+1].getY() - theVertices[i].getY(); if (dx != 0 && dy != 0) { is90 = false; if (Math.abs(dx) != Math.abs(dy)) is45 = false; } } ShapeType perimeter = SHAPELINE; if (theVertices[0].getX() == theVertices[npts-1].getX() && theVertices[0].getY() == theVertices[npts-1].getY()) perimeter = SHAPECLOSED; ShapeType oclass = SHAPEOBLIQUE; if (perimeter == SHAPECLOSED && (is90 || is45)) oclass = SHAPEPOLY; if (npts == 5 && is90 && perimeter == SHAPECLOSED) oclass = SHAPERECTANGLE; if (oclass == SHAPERECTANGLE) { readBox(); // create the rectangle if (layerUsed) { Point2D ctr = new Point2D.Double((theVertices[0].getX()+theVertices[1].getX())/2, (theVertices[0].getY()+theVertices[1].getY())/2); double sX = Math.abs(theVertices[1].getX() - theVertices[0].getX()); double sY = Math.abs(theVertices[1].getY() - theVertices[0].getY()); if (mergeThisCell) { PrimitiveNode plnp = layerNodeProto; NodeLayer [] layers = plnp.getLayers(); merge.addPolygon(layers[0].getLayer(), new Poly(ctr.getX(), ctr.getY(), sX, sY)); } else { theCell.makeInstance(layerNodeProto, ctr, Orientation.IDENT, sX, sY, null); } } return; } if (oclass == SHAPEOBLIQUE || oclass == SHAPEPOLY) { if (!layerUsed) return; if (mergeThisCell) { PrimitiveNode plnp = layerNodeProto; NodeLayer [] layers = plnp.getLayers(); merge.addPolygon(layers[0].getLayer(), new Poly(theVertices)); // ??? npts } else { // determine the bounds of the polygon double lx = theVertices[0].getX(); double hx = theVertices[0].getX(); double ly = theVertices[0].getY(); double hy = theVertices[0].getY(); for (int i=1; i<npts;i++) { if (lx > theVertices[i].getX()) lx = theVertices[i].getX(); if (hx < theVertices[i].getX()) hx = theVertices[i].getX(); if (ly > theVertices[i].getY()) ly = theVertices[i].getY(); if (hy < theVertices[i].getY()) hy = theVertices[i].getY(); } // store the trace information EPoint [] points = new EPoint[npts]; for(int i=0; i<npts; i++) { points[i] = new EPoint(theVertices[i].getX(), theVertices[i].getY()); } // now create the node theCell.makeInstance(layerNodeProto, new EPoint((lx+hx)/2, (ly+hy)/2), Orientation.IDENT, hx-lx, hy-ly, points); } return; } } private void readBox() { double pxm = theVertices[4].getX(); double pxs = theVertices[4].getX(); double pym = theVertices[4].getY(); double pys = theVertices[4].getY(); for (int i = 0; i<4; i++) { if (theVertices[i].getX() > pxm) pxm = theVertices[i].getX(); if (theVertices[i].getX() < pxs) pxs = theVertices[i].getX(); if (theVertices[i].getY() > pym) pym = theVertices[i].getY(); if (theVertices[i].getY() < pys) pys = theVertices[i].getY(); } theVertices[0].setLocation(pxs, pys); theVertices[1].setLocation(pxm, pym); } private void determinePath() throws IOException { int endcode = 0; getToken(); readUnsupported(unsupportedSet); determineLayer(); getToken(); if (theToken == GDS_PATHTYPE) { getToken(); endcode = tokenValue16; getToken(); } double width = 0; if (theToken == GDS_WIDTH) { getToken(); width = tokenValue32 * theScale; getToken(); } double bgnextend = (endcode == 0 || endcode == 4 ? 0 : width/2); double endextend = bgnextend; if (theToken == GDS_BGNEXTN) { getToken(); if (endcode == 4) bgnextend = tokenValue32 * theScale; getToken(); } if (theToken == GDS_ENDEXTN) { getToken(); if (endcode == 4) endextend = tokenValue32 * theScale; getToken(); } if (theToken == GDS_XY) { getToken(); int n = determinePoints(2, MAXPOINTS); if (TALLYCONTENTS) { countPath++; return; } // construct the path for (int i=0; i < n-1; i++) { Point2D fromPt = theVertices[i]; Point2D toPt = theVertices[i+1]; // determine whether either end needs to be shrunk double fextend = width / 2; double textend = fextend; int thisAngle = GenMath.figureAngle(fromPt, toPt); if (i > 0) { Point2D prevPoint = theVertices[i-1]; int lastAngle = GenMath.figureAngle(prevPoint, fromPt); if (Math.abs(thisAngle-lastAngle) % 900 != 0) { int ang = Math.abs(thisAngle-lastAngle) / 10; if (ang > 180) ang = 360 - ang; if (ang > 90) ang = 180 - ang; fextend = Poly.getExtendFactor(width, ang); } } else { fextend = bgnextend; } if (i+1 < n-1) { Point2D nextPoint = theVertices[i+2]; int nextAngle = GenMath.figureAngle(toPt, nextPoint); if (Math.abs(thisAngle-nextAngle) % 900 != 0) { int ang = Math.abs(thisAngle-nextAngle) / 10; if (ang > 180) ang = 360 - ang; if (ang > 90) ang = 180 - ang; textend = Poly.getExtendFactor(width, ang); } } else { textend = endextend; } // handle arbitrary angle path segment if (layerUsed) { // determine shape of segment double length = fromPt.distance(toPt); Poly poly = Poly.makeEndPointPoly(length, width, GenMath.figureAngle(toPt, fromPt), fromPt, fextend, toPt, textend, Poly.Type.FILLED); if (mergeThisCell) { PrimitiveNode plnp = layerNodeProto; NodeLayer [] layers = plnp.getLayers(); merge.addPolygon(layers[0].getLayer(), poly); } else { // make the node for this segment Rectangle2D polyBox = poly.getBox(); if (polyBox != null) { theCell.makeInstance(layerNodeProto, new EPoint(polyBox.getCenterX(), polyBox.getCenterY()), Orientation.IDENT, polyBox.getWidth(), polyBox.getHeight(), null); } else { polyBox = poly.getBounds2D(); double cx = polyBox.getCenterX(); double cy = polyBox.getCenterY(); // store the trace information Point2D [] polyPoints = poly.getPoints(); EPoint [] points = new EPoint[polyPoints.length]; for(int j=0; j<polyPoints.length; j++) { points[j] = new EPoint(polyPoints[j].getX(), polyPoints[j].getY()); } // store the trace information theCell.makeInstance(layerNodeProto, new EPoint(cx, cy), Orientation.IDENT, polyBox.getWidth(), polyBox.getHeight(), points); } } } } } else { handleError("Path element has no points"); } } private void determineNode() throws IOException { getToken();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -