⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 layoutlib.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		}		// round all dimensions to a 10e-4 lambda grid		x = DBMath.round(x);		y = DBMath.round(y);		width = DBMath.round(width);		height = DBMath.round(height);        return new Rectangle2D.Double(x, y, width, height);    }	/**	 * Create a new NodeInst.  The following geometric transformations	 * are performed upon the NodeProto in order to arrive at the	 * final position of the NodeInst in the coordinate space of the	 * parent:	 * <ol>	 * <li> Scale the NodeProto in x and y so that it has dimensions	 * |width| and |height|. All scaling is performed about the	 * NodeProto's origin, (0, 0).	 * <li> If width<0 then mirror the preceding result about the	 * y-axis.	 * <li> If height<0 then mirror the preceding result about the	 * x-axis.	 * <li> Rotating the preceding result clockwise by angle degrees.	 * <li> Translate the preceding result by (x, y). Note that the	 * NodeProto's origin always ends up at (x, y) in the	 * coordinate space of the parent.	 * </ol> 	 * 	 * The newNodeInst method differs from NodeInst.newInstance in the	 * following ways:	 *	 * <ul>	 * <li>The "size offset" is added to the width and height	 * arguments before the object is created. The result is a	 * NodeInst that the GUI reports has dimensions: width x height.	 * <li>The angle is in units of degrees but is rounded to the	 * nearest tenth degree.	 * <li>If np is a Cell then the width and height are taken from	 * the Cell's defaults. The width and height arguments only	 * specify mirroring.	 * <li>If np is a Cell then rotation and mirroring are performed	 * relative to the Cell's origin.	 * <li>If np is a Cell then the NodeInst is positioned using the	 * Cell's origin.  That is, the resulting NodeInst will map the	 * Cell's origin to (x, y) in the coordinate space of the parent.	 * <li>If the width or height arguments are equal to DEF_SIZE then	 * the NodeInst is created using the NodeProto's default	 * dimensions. Eventually I will change this to <i>minimum</i>	 * dimensions.	 * </ul>	 * @param np the NodeProto to instantiate	 * @param width the desired width of the NodeInst	 * @param height the desired height of the NodeInst	 * @param x the desired x-coordinate of the NodeProto's origin in	 * the coordinate space of the parent. If x is negative then the	 * NodeInst mirrors about the y-axis.	 * @param y the desired y-coordinate of the NodeProto's origin in	 * the coordinate space of the parent. If y is negative then the	 * NodeInst mirrors about the x-axis.	 * @param angle the angle, in degrees, of rotation about the	 * NodeProto's origin.	 * @param parent the Cell that will contain the NodeInst.	 * @return the new NodeInst. 	 */    public static NodeInst newNodeInst(NodeProto np,		                               double x, double y,									   double width, double height,			                           double angle, Cell parent) {        Rectangle2D rect = calculateNodeInst(np, x, y, width, height);        return newNodeInst(np, rect, angle, parent);    }    public static NodeInst newNodeInst(NodeProto np, Rectangle2D rect,			                           double angle, Cell parent)    {        double x = rect.getX();        double y = rect.getY();        double width = rect.getWidth();        double height = rect.getHeight();        Orientation orient = Orientation.fromJava((int)Math.round(angle*10), width < 0, height < 0);		NodeInst ni = NodeInst.newInstance(np, new Point2D.Double(x, y), Math.abs(width), Math.abs(height),                parent, orient, null, 0);		error(ni==null, "newNodeInst failed");										// adjust position so that translation is Cell-Center relative		if (np instanceof Cell) {			Point2D ref = getPosition(ni);			ni.move(x-ref.getX(), y-ref.getY());		}		return ni;	}	/**	 * Modify the position of a NodeInst.  The size and position of a	 * NodeInst in the coordinate space of its parent cell is	 * determined by 5 parameters: x, y, width, height, and angle, as	 * described in the JavaDoc for newNodeInst. The modNodeInst	 * method modifies those parameters.	 * <p>The modNodeInst method differs from NodeInst.modifyInstance	 * in the following ways:	 * <ul>	 * <li>If ni is an instance of a Cell then mirroring, rotation,	 * and positioning are performed relative to the Cell's origin	 * <li>The arguments dw and dh, are added to the absolute values	 * of the NodeInst's x-size and y-size.	 * <li>The arguments mirrorAboutXAxis and mirrorAboutYAxis are	 * used to mirror the NodeInst about the x and y axes.	 * </ul>	 * @param ni the NodeInst to modify	 * @param dx the amount by which to change the x-coordinate of the	 * NodeInst's position	 * @param dy the amount by which to change the y-coordinate of the	 * NodeInst's position	 * @param dw the amount by which to change to absolute value of	 * the NodeInst's width	 * @param dh the amount by which to change to absolute value of	 * the NodeInst's height.	 * @param mirrorAboutYAxis if true then toggle the mirroring of	 * the NodeInst about the y-axis	 * @param mirrorAboutXAxis if true then toggle the mirroring of	 * the NodeInst about the x-axis	 * @param dAngle the amount by which to change the NodeInst's angle	 */	public static void modNodeInst(NodeInst ni, double dx, double dy, 	                               double dw, double dh, 	                               boolean mirrorAboutYAxis, 	                               boolean mirrorAboutXAxis,								   double dAngle) {// 	    boolean oldMirX = ni.isMirroredAboutXAxis();// 	    boolean oldMirY = ni.isMirroredAboutYAxis();// 		double oldXS = ni.getXSize() * (oldMirY ? -1 : 1);// 		double oldYS = ni.getYSize() * (oldMirX ? -1 : 1);		 		double newX = getPosition(ni).getX() + dx;		double newY = getPosition(ni).getY() + dy;// 		double newW = Math.max(ni.getXSize() + dw, 0);// 		double newH = Math.max(ni.getYSize() + dh, 0);//		// 		boolean newMirX = oldMirX ^ mirrorAboutXAxis;// 		boolean newMirY = oldMirY ^ mirrorAboutYAxis;//		// 		double newXS = newW * (newMirY ? -1 : 1);// 		double newYS = newH * (newMirX ? -1 : 1);		Orientation dOrient = Orientation.fromJava((int)Math.rint(dAngle*10), mirrorAboutYAxis, mirrorAboutXAxis);		ni.modifyInstance(0, 0, dw, dh, dOrient);// 		ni.modifyInstance(0, 0, newXS-oldXS, newYS-oldYS, // 		                  (int)Math.rint(dAngle*10));		ni.move(newX-getPosition(ni).getX(), newY-getPosition(ni).getY());	}	/**	 * Get the position of a NodeInst. In the coordinate space of the	 * NodeInst's parent, get the x and y-coordinates of the origin of	 * the NodeInst's NodeProto.	 * @param ni the NodeInst we want the position of	 * @return the x and y-coordinates of the origin of the	 * NodeInst's NodeProto	 */	public static Point2D getPosition(NodeInst ni) {		NodeProto np = ni.getProto();		Point2D p;		if (np instanceof Cell) {			AffineTransform xForm = ni.transformOut();			p = xForm.transform(new Point2D.Double(0, 0), null);		} else {			p = ni.getAnchorCenter();		}		double x = DBMath.round(p.getX());		double y = DBMath.round(p.getY());		return new Point2D.Double(x,y);	}	/**	 * Create a new ArcInst. This differs from ArcInst.newInstance in that	 * the "width-offset" is added to the width parameter. The result is an 	 * ArcInst that the GUI reports is width wide.	 * @param ap the ArcProto to instantiate	 * @param width the desired width of the ArcInst	 * @param head the head PortInst	 * @param hX the x-coordinate of the head PortInst	 * @param hY the y-coordinate of the head PortInst	 * @param tail the tail PortInst	 * @param tX the x-coordinate of the tail PortInst	 * @param tY the y-coordinate of the tail PortInst	 * @return the new ArcInst	 */	public static ArcInst newArcInst(ArcProto ap, double width,							  		 PortInst head, double hX, double hY,							  		 PortInst tail, double tX, double tY) {		// Take the default width if that's what the user wants.		// Otherwise adjust the user-specified width or height by the 		// SizeOffset.		if (width==DEF_SIZE) {			width = ap.getDefaultLambdaBaseWidth();//			width = ap.getDefaultLambdaFullWidth();//		} else {//			width += ap.getLambdaWidthOffset();		}				hX = DBMath.round(hX);		hY = DBMath.round(hY);		tX = DBMath.round(tX);		tY = DBMath.round(tY);		width = DBMath.round(width);		ArcInst ai = ArcInst.newInstanceBase(ap, width, //		ArcInst ai = ArcInst.newInstanceFull(ap, width, 		                                 head, tail, new Point2D.Double(hX, hY),										 new Point2D.Double(tX, tY),										 null, 0);        error(ai==null, "newArcInst failed");		ai.setFixedAngle(true);		return ai;	}	/**	 * Create a new ArcInst. This differs from ArcInst.newInstance in that	 * the "width-offset" is added to the width parameter. The result is an 	 * ArcInst that the GUI reports is width wide.	 *	 * <p> Connect the new ArcInst to the centers of the PortInsts.	 * If the centers don't share an X or y-coordinate then connect	 * the head and the tail using two ArcInsts. The ArcInst attached	 * to the head is horizontal and the ArcInst attached to the tail	 * is vertical.	 * @param ap the head PortInst	 * @param width the desired width of the ArcInst	 * @param head the head ArcInst	 * @param tail the tail ArcInst	 * @return the ArcInst connected to the tail.	 */	public static ArcInst newArcInst(ArcProto ap, double width,							         PortInst head, PortInst tail) {        EPoint headP = head.getCenter();		double hX = headP.getX(); // roundCenterX(head);		double hY = headP.getY(); // roundCenterY(head);        EPoint tailP = tail.getCenter();		double tX = tailP.getX(); // roundCenterX(tail);		double tY = tailP.getY(); // roundCenterY(tail);		ArcInst ai;		if (hX==tX || hY==tY) {			// no jog necessary						         				ai = newArcInst(ap, width, head, hX, hY, tail, tX, tY);		} else {			Cell parent = head.getNodeInst().getParent();			NodeProto pinProto = ap.findOverridablePinProto();			PortInst pin = newNodeInst(pinProto, tX, hY, DEF_SIZE, DEF_SIZE, 0, 			                           parent).getOnlyPortInst(); 			// debug            EPoint pinP = pin.getCenter();			double newX = pinP.getX(); // roundCenterX(pin);			double newY = pinP.getY(); // roundCenterY(pin);						if (newX!=tX || newY!=hY) {				Rectangle2D r = head.getBounds();				double loy = r.getMinY();				double hiy = r.getMaxY();				System.out.println(loy+" "+hiy);				error(true, "center moved");			}									ai = newArcInst(ap, width, head, pin);			ai.setFixedAngle(true);			ai = newArcInst(ap, width, pin, tail);		}		ai.setFixedAngle(true);		return ai;	}	/**	 *  Create an export for a particular layer.	 *	 * <p> At the coordinates <code>(x, y)</code> create a NodeInst of	 * a layer-pin for the layer <code>ap</code>. Export that	 * layer-pin's PortInst.	 *	 * <p> Attach an ArcInst of ArcProto ap to the layer-pin.  The

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -