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

📄 vectordrawing.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				int subLevel = level;				if (subLevel == 0) subLevel = 1;				render(subVC, soX, soY, subContext, subLevel);			} else			{				// now draw with the proper line type				int[] op = subVC.outlinePoints;				int p1x = op[0] + soX;				int p1y = op[1] + soY;				int p2x = op[2] + soX;				int p2y = op[3] + soY;				int p3x = op[4] + soX;				int p3y = op[5] + soY;				int p4x = op[6] + soX;				int p4y = op[7] + soY;				gridToScreen(p1x, p1y, tempPt1);   gridToScreen(p2x, p2y, tempPt2);				offscreen.drawLine(tempPt1, tempPt2, null, instanceGraphics, 0, false);				gridToScreen(p2x, p2y, tempPt1);   gridToScreen(p3x, p3y, tempPt2);				offscreen.drawLine(tempPt1, tempPt2, null, instanceGraphics, 0, false);				gridToScreen(p3x, p3y, tempPt1);   gridToScreen(p4x, p4y, tempPt2);				offscreen.drawLine(tempPt1, tempPt2, null, instanceGraphics, 0, false);				gridToScreen(p1x, p1y, tempPt1);   gridToScreen(p4x, p4y, tempPt2);				offscreen.drawLine(tempPt1, tempPt2, null, instanceGraphics, 0, false);				// draw the instance name				if (User.isTextVisibilityOnInstance())				{					tempRect.setBounds(lX, lY, hX-lX, hY-lY);					TextDescriptor descript = vsc.n.protoDescriptor;					offscreen.drawText(tempRect, Poly.Type.TEXTBOX, descript, subCell.describe(false), null, textGraphics, false);				}			}			if (level == 0 || onPathDown || inPlaceCurrent == cell)				drawPortList(vsc, subVC, soX, soY, ni.isExpanded());		}	}	/**	 * Method to draw a list of cached shapes.	 * @param oX the X offset to draw the shapes (in database grid coordinates).	 * @param oY the Y offset to draw the shapes (in database grid coordinates).	 * @param shapes the List of shapes (VectorBase objects).	 * @param level: 0=top-level cell in window; 1=low level cell; -1=greeked cell.	 * @param forceVisible true to force all layers to be drawn (regardless of user settings)	 */	private void drawList(int oX, int oY, List<VectorCache.VectorBase> shapes, int level, boolean forceVisible)		throws AbortRenderingException	{		// render all shapes in reverse order (because PixelDrawing don't overwrite opaque layers)		for (int k = shapes.size() - 1; k >= 0; k--)		{			VectorCache.VectorBase vb = shapes.get(k);			if (stopRendering) throw new AbortRenderingException();			// get visual characteristics of shape			Layer layer = vb.layer;			boolean dimmed = false;			if (layer != null)			{				if (level < 0)				{					// greeked cells ignore cut and implant layers					Layer.Function fun = layer.getFunction();					if (fun.isContact() || fun.isWell() || fun.isSubstrate()) continue;				}				if (!forceVisible && !layer.isVisible()) continue;				dimmed = layer.isDimmed();			}			byte [][] layerBitMap = null;			EGraphics graphics = vb.graphics;			if (graphics != null)			{				int layerNum = graphics.getTransparentLayer() - 1;				if (layerNum < offscreen.numLayerBitMaps) layerBitMap = offscreen.getLayerBitMap(layerNum);			}			// handle each shape			if (vb instanceof VectorCache.VectorManhattan)			{				boxCount++;				VectorCache.VectorManhattan vm = (VectorCache.VectorManhattan)vb;				double maxSize = maxObjectSize*DBMath.GRID;				int fadeCol = -1;				if (layer != null)				{					Layer.Function fun = layer.getFunction();					if (fun.isImplant() || fun.isSubstrate())					{						// well and substrate layers are made smaller so that they "greek" sooner						if (!vm.pureLayer)							maxSize *= 10;					} else if (vm.graphics != null) {						fadeCol = vm.graphics.getRGB();					}				}				for (int i = 0; i < vm.coords.length; i += 4) {					int c1X = vm.coords[i];					int c1Y = vm.coords[i+1];					int c2X = vm.coords[i+2];					int c2Y = vm.coords[i+3];					long dX = c2X - c1X;					long dY = c2Y - c1Y;					if (dX < maxSize || dY < maxSize)					{						if (fadeCol < 0) continue;						if (dX < maxSize && dY < maxSize)						{							// both dimensions tiny: just draw a dot							gridToScreen(c1X+oX, c1Y+oY, tempPt1);							int x = tempPt1.x;							int y = tempPt1.y;							if (x < screenLX || x >= screenHX) continue;							if (y < screenLY || y >= screenHY) continue;							offscreen.drawPoint(x, y, null, fadeCol);							tinyBoxCount++;						} else						{							// one dimension tiny: draw a line							gridToScreen(c1X+oX, c2Y+oY, tempPt1);							gridToScreen(c2X+oX, c1Y+oY, tempPt2);							assert tempPt1.x <= tempPt2.x && tempPt1.y <= tempPt2.y;							int lX = tempPt1.x;							int hX = tempPt2.x;							int lY = tempPt1.y;							int hY = tempPt2.y;							if (hX < screenLX || lX >= screenHX) continue;							if (hY < screenLY || lY >= screenHY) continue;							drawTinyBox(lX, hX, lY, hY, fadeCol, null);							lineBoxCount++;						}						continue;					}					// determine coordinates of rectangle on the screen					gridToScreen(c1X+oX, c2Y+oY, tempPt1);					gridToScreen(c2X+oX, c1Y+oY, tempPt2);					assert tempPt1.x <= tempPt2.x && tempPt1.y <= tempPt2.y;					int lX = tempPt1.x;					int hX = tempPt2.x;					int lY = tempPt1.y;					int hY = tempPt2.y;					// reject if completely off the screen					if (hX < screenLX || lX >= screenHX) continue;					if (hY < screenLY || lY >= screenHY) continue;					// clip to screen					if (lX < screenLX) lX = screenLX;					if (hX >= screenHX) hX = screenHX-1;					if (lY < screenLY) lY = screenLY;					if (hY >= screenHY) hY = screenHY-1;					// draw the box					offscreen.drawBox(lX, hX, lY, hY, layerBitMap, graphics, dimmed);				}			} else if (vb instanceof VectorCache.VectorLine)			{				lineCount++;				VectorCache.VectorLine vl = (VectorCache.VectorLine)vb;				// determine coordinates of line on the screen				gridToScreen(vl.fX+oX, vl.fY+oY, tempPt1);				gridToScreen(vl.tX+oX, vl.tY+oY, tempPt2);				// clip and draw the line				offscreen.drawLine(tempPt1, tempPt2, layerBitMap, graphics, vl.texture, dimmed);			} else if (vb instanceof VectorCache.VectorPolygon)			{				polygonCount++;				VectorCache.VectorPolygon vp = (VectorCache.VectorPolygon)vb;				Point [] intPoints = new Point[vp.points.length];				for(int i=0; i<vp.points.length; i++)				{					intPoints[i] = new Point();					gridToScreen(vp.points[i].x+oX, vp.points[i].y+oY, intPoints[i]);				}				Point [] clippedPoints = GenMath.clipPoly(intPoints, screenLX, screenHX-1, screenLY, screenHY-1);				offscreen.drawPolygon(clippedPoints, layerBitMap, graphics, dimmed);			} else if (vb instanceof VectorCache.VectorCross)			{				crossCount++;				VectorCache.VectorCross vcr = (VectorCache.VectorCross)vb;				gridToScreen(vcr.x+oX, vcr.y+oY, tempPt1);				int size = 5;				if (vcr.small) size = 3;				offscreen.drawLine(new Point(tempPt1.x-size, tempPt1.y), new Point(tempPt1.x+size, tempPt1.y), null, graphics, 0, dimmed);				offscreen.drawLine(new Point(tempPt1.x, tempPt1.y-size), new Point(tempPt1.x, tempPt1.y+size), null, graphics, 0, dimmed);			} else if (vb instanceof VectorCache.VectorText)			{				VectorCache.VectorText vt = (VectorCache.VectorText)vb;				switch (vt.textType)				{					case VectorCache.VectorText.TEXTTYPEARC:						if (!User.isTextVisibilityOnArc()) continue;						break;					case VectorCache.VectorText.TEXTTYPENODE:						if (!User.isTextVisibilityOnNode()) continue;						break;					case VectorCache.VectorText.TEXTTYPECELL:						if (!User.isTextVisibilityOnCell()) continue;						break;					case VectorCache.VectorText.TEXTTYPEEXPORT:						if (!User.isTextVisibilityOnExport()) continue;						break;					case VectorCache.VectorText.TEXTTYPEANNOTATION:						if (!User.isTextVisibilityOnAnnotation()) continue;						break;					case VectorCache.VectorText.TEXTTYPEINSTANCE:						if (!User.isTextVisibilityOnInstance()) continue;						break;				}				if (vt.height < maxTextSize) continue;				String drawString = vt.str;				int lX = vt.bounds.x;				int lY = vt.bounds.y;				int hX = lX + vt.bounds.width;				int hY = lY + vt.bounds.height;				gridToScreen(lX + oX, hY + oY, tempPt1);				gridToScreen(hX + oX, lY + oY, tempPt2);				lX = tempPt1.x;				lY = tempPt1.y;				hX = tempPt2.x;				hY = tempPt2.y;//				int lX, hX, lY, hY;//				if (tempPt1.x < tempPt2.x) { lX = tempPt1.x;   hX = tempPt2.x; } else//					{ lX = tempPt2.x;   hX = tempPt1.x; }//				if (tempPt1.y < tempPt2.y) { lY = tempPt1.y;   hY = tempPt2.y; } else//					{ lY = tempPt2.y;   hY = tempPt1.y; }				// for ports, switch between the different port display methods//				if (vt.textType == VectorCache.VectorText.TEXTTYPEPORT)//				{//					int portDisplayLevel = User.getPortDisplayLevel();//					Color portColor = vt.e.getBasePort().getPortColor();//					if (vt.ni.isExpanded()) portColor = textColor;//					if (portColor != null) portGraphics.setColor(portColor);//					int cX = (lX + hX) / 2;//					int cY = (lY + hY) / 2;//					if (portDisplayLevel == 2)//					{//						// draw port as a cross//						int size = 3;//						offscreen.drawLine(new Point(cX-size, cY), new Point(cX+size, cY), null, portGraphics, 0, false);//						offscreen.drawLine(new Point(cX, cY-size), new Point(cX, cY+size), null, portGraphics, 0, false);//						crossCount++;//						continue;//					}////					// draw port as text//					if (portDisplayLevel == 1) drawString = vt.e.getShortName(); else//						drawString = vt.e.getName();//					graphics = portGraphics;//					layerBitMap = null;//					lX = hX = cX;//					lY = hY = cY;//				} else				if (vt.textType == VectorCache.VectorText.TEXTTYPEEXPORT && vt.basePort != null)				{					if (!vt.basePort.getParent().isVisible()) continue;					int exportDisplayLevel = User.getExportDisplayLevel();					if (exportDisplayLevel == 2)					{						// draw export as a cross						int cX = (lX + hX) / 2;						int cY = (lY + hY) / 2;						int size = 3;						offscreen.drawLine(new Point(cX-size, cY), new Point(cX+size, cY), null, textGraphics, 0, false);						offscreen.drawLine(new Point(cX, cY-size), new Point(cX, cY+size), null, textGraphics, 0, false);						crossCount++;						continue;					}					// draw export as text					if (exportDisplayLevel == 1)						drawString = Export.getShortName(drawString);					graphics = textGraphics;					layerBitMap = null;				}				textCount++;				tempRect.setBounds(lX, lY, hX-lX, hY-lY);				offscreen.drawText(tempRect, vt.style, vt.descript, drawString, layerBitMap, graphics, dimmed);			} else if (vb instanceof VectorCache.VectorCircle)			{				circleCount++;				VectorCache.VectorCircle vci = (VectorCache.VectorCircle)vb;				gridToScreen(vci.cX+oX, vci.cY+oY, tempPt1);				gridToScreen(vci.eX+oX, vci.eY+oY, tempPt2);				switch (vci.nature)				{					case 0: offscreen.drawCircle(tempPt1, tempPt2, layerBitMap, graphics, dimmed);        break;					case 1: offscreen.drawThickCircle(tempPt1, tempPt2, layerBitMap, graphics, dimmed);   break;					case 2: offscreen.drawDisc(tempPt1, tempPt2, layerBitMap, graphics, dimmed);          break;				}			} else if (vb instanceof VectorCache.VectorCircleArc)			{				arcCount++;				VectorCache.VectorCircleArc vca = (VectorCache.VectorCircleArc)vb;				gridToScreen(vca.cX+oX, vca.cY+oY, tempPt1);				gridToScreen(vca.eX1+oX, vca.eY1+oY, tempPt2);				gridToScreen(vca.eX2+oX, vca.eY2+oY, tempPt3);				offscreen.drawCircleArc(tempPt1, tempPt2, tempPt3, vca.thick, layerBitMap, graphics, dimmed);			}		}	}	/**	 * Method to draw a list of cached port shapes.	 * @param oX the X offset to draw the shapes (in database grid coordinates).	 * @param oY the Y offset to draw the shapes (in database grid coordinates).	 * @parem true to draw a list on expanded instance	 */	private void drawPortList(VectorCache.VectorSubCell vsc, VectorCache.VectorCell subVC_, int oX, int oY, boolean expanded)		throws AbortRenderingException	{		if (!User.isTextVisibilityOnPort()) return;		// render all shapes		List<VectorCache.VectorCellExport> portShapes = subVC_.vcg.getPortShapes();		int[] portCenters = subVC_.getPortCenters();		assert portShapes.size()*2 == portCenters.length;		for (int i = 0; i < portShapes.size(); i++) {			VectorCache.VectorCellExport vce = portShapes.get(i);			if (stopRendering) throw new AbortRenderingException();			// get visual characteristics of shape			if (vsc.shownPorts.get(vce.getChronIndex())) continue;			if (vce.height < maxTextSize) continue;			int cX = portCenters[i*2];			int cY = portCenters[i*2 + 1];			gridToScreen(cX + oX, cY + oY, tempPt1);			cX = tempPt1.x;			cY = tempPt1.y;			int portDisplayLevel = User.getPortDisplayLevel();			Color portColor = vce.getPortColor();			if (expanded) portColor = textColor;			if (portColor != null) portGraphics.setColor(portColor);			if (portDisplayLevel == 2)			{				// draw port as a cross				int size = 3;				offscreen.drawLine(new Point(cX-size, cY), new Point(cX+size, cY), null, portGraphics, 0, false);				offscreen.drawLine(new Point(cX, cY-size), new Point(cX, cY+size), null, portGraphics, 0, false);				crossCount++;				continue;			}			// draw port as text			boolean shortName = portDisplayLevel == 1;			String drawString = vce.getName(shortName);			textCount++;			tempRect.setBounds(cX, cY, 0, 0);			offscreen.drawText(tempRect, vce.style, vce.descript, drawString, null, portGraphics, false);		}	}	/**	 * Method to convert a database grid coordinate to screen coordinates.	 * @param dbX the X coordinate (in database grid units).	 * @param dbY the Y coordinate (in database grid units).	 * @param result the Point in which to store the screen coordinates.	 */	private void gridToScreen(int dbX, int dbY, Point result)	{		if (false) {			result.x = ((dbX - factorX_) * scale_int) >> SCALE_SH;			result.y = ((factorY_ - dbY) * scale_int) >> SCALE_SH;		} else {			double scrX = (dbX - factorX) * scale_;			double scrY = (factorY - dbY) * scale_;			result.x = (int)(scrX >= 0 ? scrX + 0.5 : scrX - 0.5);

⌨️ 快捷键说明

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