editwindow.java

来自「The ElectricTM VLSI Design System is an 」· Java 代码 · 共 1,983 行 · 第 1/5 页

JAVA
1,983 行
字号
	/**	 * Method to automatically set the opacity of each layer in a Technology.	 * At the current time, this method is not used.	 * @param tech the Technology to set.	 */	public static void setDefaultOpacity(Technology tech)	{		for(Iterator<Layer> it = tech.getLayers(); it.hasNext(); )		{			Layer layer = it.next();			Layer.Function fun = layer.getFunction();			int extra = layer.getFunctionExtras();			double opacity = 0.4;			if (fun.isMetal())			{				opacity = 0.75 - fun.getLevel() * 0.05;			} else if (fun.isContact())			{				if ((extra&Layer.Function.CONMETAL) != 0) opacity = 0.7; else					opacity = 1;			} else if (fun == Layer.Function.OVERGLASS)			{				opacity = 0.2;			} else if (fun == Layer.Function.POLY1 ||					   fun == Layer.Function.POLY2 ||					   fun == Layer.Function.POLY3 ||					   fun == Layer.Function.GATE ||					   fun == Layer.Function.DIFF ||					   fun == Layer.Function.DIFFP ||					   fun == Layer.Function.DIFFN ||					   fun == Layer.Function.WELL ||					   fun == Layer.Function.WELLP ||					   fun == Layer.Function.WELLN ||					   fun == Layer.Function.IMPLANT ||					   fun == Layer.Function.IMPLANTN ||					   fun == Layer.Function.IMPLANTP) {				// lowest level layers should all be opaque				opacity = 1.0;			} else if (fun == Layer.Function.ART) {				if (layer.getName().equals("Glyph"))					opacity = 0;		// essential bounds			}			if (layer.getGraphics().getOpacity() != opacity)				layer.getGraphics().setOpacity(opacity);		}	}	/**	 * Returns alpha blending order for this EditWindow.	 * Alpha blending order specifies pixel color by such a way:	 * Color col = backgroudColor;	 * for (LayerColor layerColor: blendingOrder) {	 *    if (This pixel covers a piece of layer layerColor.layer) {	 *       alpha = layerColor.color.getAlpha();	 *       col =  layerColor.color.getRGB()*alpha + col*(1 - alpha)	 *    }	 * }	 * return col;	 * @param layersAvailable layers available in this EditWindow	 * @return alpha blending order.	 */	public List<AbstractDrawing.LayerColor> getBlendingOrder(Set<Layer> layersAvailable, boolean patternedDisplay, boolean alphaBlendingOvercolor) {		List<AbstractDrawing.LayerColor> layerColors = new ArrayList<AbstractDrawing.LayerColor>();		List<Layer> sortedLayers = new ArrayList<Layer>(layersAvailable);		Collections.sort(sortedLayers, Technology.LAYERS_BY_HEIGHT_LIFT_CONTACTS);		float[] backgroundComps = (new Color(User.getColor(User.ColorPrefType.BACKGROUND))).getRGBColorComponents(null);		float bRed = backgroundComps[0];		float bGreen = backgroundComps[1];		float bBlue = backgroundComps[2];		for(Layer layer : sortedLayers) {			if (!layer.isVisible()) continue;			if (layer == Generic.tech().glyphLay && !patternedDisplay) continue;			Color color = new Color(layer.getGraphics().getRGB());			float[] compArray = color.getRGBComponents(null);			float red = compArray[0];			float green = compArray[1];			float blue = compArray[2];			float opacity = (float)layer.getGraphics().getOpacity();			if (opacity <= 0) continue;			float inverseAlpha = 1 - opacity;			if (alphaBlendingOvercolor) {				red -= bRed*inverseAlpha;				green -= bGreen*inverseAlpha;				blue -= bBlue*inverseAlpha;			} else {				red *= opacity;				green *= opacity;				blue *= opacity;			}			layerColors.add(new AbstractDrawing.LayerColor(layer, red, green, blue, inverseAlpha));		}		final LayerTab layerTab = getWindowFrame().getLayersTab();		final boolean showOpacity = !User.isLegacyComposite();		if (layerTab != null)			SwingUtilities.invokeLater(new Runnable() { public void run() { layerTab.setDisplayAlgorithm(showOpacity); }});			return layerColors;	}	public void testJogl() {		drawing.testJogl();	}	void opacityChanged() {		drawing.opacityChanged();	}	// ************************************* SIMULATION CROSSPROBE LEVEL DISPLAY *************************************	private static class CrossProbe	{		boolean isLine;		Point2D start, end;		Rectangle2D box;		Color color;	};	private List<CrossProbe> crossProbeObjects = new ArrayList<CrossProbe>();	/**	 * Method to clear the list of cross-probed levels in this EditWindow.	 * Cross-probed levels are displays of the current simulation value	 * at a point in the display, and come from the Waveform Window.	 */	public void clearCrossProbeLevels()	{		crossProbeObjects.clear();	}	/**	 * Method to tell whether there is any cross-probed data in this EditWindow.	 * Cross-probed levels are displays of the current simulation value	 * at a point in the display, and come from the Waveform Window.	 * @return true if there are any cross-probed data displays in this EditWindow.	 */	public boolean hasCrossProbeData()	{		if (crossProbeObjects.size() > 0) return true;		return false;	}	/**	 * Method to add a line to the list of cross-probed levels in this EditWindow.	 * Cross-probed levels are displays of the current simulation value	 * at a point in the display, and come from the Waveform Window.	 * @param start the starting point of the line.	 * @param end the ending point of the line.	 * @param color the color of the line.	 */	public void addCrossProbeLine(Point2D start, Point2D end, Color color)	{		CrossProbe cp = new CrossProbe();		cp.isLine = true;		cp.start = start;		cp.end = end;		cp.color = color;		crossProbeObjects.add(cp);	}	/**	 * Method to add a box to the list of cross-probed levels in this EditWindow.	 * Cross-probed levels are displays of the current simulation value	 * at a point in the display, and come from the Waveform Window.	 * @param box the bounds of the box.	 * @param color the color of the box.	 */	public void addCrossProbeBox(Rectangle2D box, Color color)	{		CrossProbe cp = new CrossProbe();		cp.isLine = false;		cp.box = box;		cp.color = color;		crossProbeObjects.add(cp);	}	private void showCrossProbeLevels(Graphics g)	{		for(CrossProbe cp : crossProbeObjects)		{			g.setColor(cp.color);			if (cp.isLine)			{				// draw a line				Point pS = databaseToScreen(cp.start);				Point pE = databaseToScreen(cp.end);				g.drawLine(pS.x, pS.y, pE.x, pE.y);			} else			{				// draw a box				Point pS = databaseToScreen(cp.box.getMinX(), cp.box.getMinY());				Point pE = databaseToScreen(cp.box.getMaxX(), cp.box.getMaxY());				int lX = Math.min(pS.x, pE.x);				int lY = Math.min(pS.y, pE.y);				int wid = Math.abs(pS.x - pE.x);				int hei = Math.abs(pS.y - pE.y);				g.fillRect(lX, lY, wid, hei);			}		}	}	// ************************************* DRAG BOX *************************************	public boolean isDoingAreaDrag() { return doingAreaDrag; }	public void setDoingAreaDrag() { doingAreaDrag = true; }	public void clearDoingAreaDrag() { doingAreaDrag = false; }	public Point getStartDrag() { return startDrag; }	public void setStartDrag(int x, int y) { startDrag.setLocation(x, y); }	public Point getEndDrag() { return endDrag; }	public void setEndDrag(int x, int y) { endDrag.setLocation(x, y); }	private void showDragBox(Graphics g)	{		int lX = (int)Math.min(startDrag.getX(), endDrag.getX());		int hX = (int)Math.max(startDrag.getX(), endDrag.getX());		int lY = (int)Math.min(startDrag.getY(), endDrag.getY());		int hY = (int)Math.max(startDrag.getY(), endDrag.getY());		Graphics2D g2 = (Graphics2D)g;		g2.setStroke(selectionLine);		g.setColor(new Color(User.getColor(User.ColorPrefType.HIGHLIGHT)));		g.drawLine(lX, lY, lX, hY);		g.drawLine(lX, hY, hX, hY);		g.drawLine(hX, hY, hX, lY);		g.drawLine(hX, lY, lX, lY);	}	// ************************************* CELL FRAME *************************************	/**	 * Method to render the cell frame directly to the Graphics.	 */	private void drawCellFrame(Graphics g)	{		DisplayedFrame df = new DisplayedFrame(cell, g, this);		df.renderFrame();	}	/**	 * Class for rendering a cell frame.	 * Extends Cell.FrameDescription and provides hooks for drawing to a Graphics.	 */	private static class DisplayedFrame extends Cell.FrameDescription	{		private Graphics g;		private EditWindow wnd;		private Color lineColor, textColor;		/**		 * Constructor for cell frame rendering.		 * @param cell the Cell that is having a frame drawn.		 * @param g the Graphics to which to draw the frame.		 * @param wnd the EditWindow in which this is being drawn.		 */		public DisplayedFrame(Cell cell, Graphics g, EditWindow wnd)		{			super(cell, wnd.pageNumber);			this.g = g;			this.wnd = wnd;			lineColor = new Color(User.getColor(User.ColorPrefType.INSTANCE));			textColor = new Color(User.getColor(User.ColorPrefType.TEXT));		}		/**		 * Method to draw a line in a frame.		 * @param from the starting point of the line (in database units).		 * @param to the ending point of the line (in database units).		 */		public void showFrameLine(Point2D from, Point2D to)		{			g.setColor(lineColor);			Point f = wnd.databaseToScreen(from);			Point t = wnd.databaseToScreen(to);			g.drawLine(f.x, f.y, t.x, t.y);		}		/**		 * Method to draw text in a frame.		 * @param ctr the anchor point of the text.		 * @param size the size of the text (in database units).		 * @param maxWid the maximum width of the text (ignored if zero).		 * @param maxHei the maximum height of the text (ignored if zero).		 * @param string the text to be displayed.		 */		public void showFrameText(Point2D ctr, double size, double maxWid, double maxHei, String string)		{			// convert text size to screen points			Point2D sizeVector = wnd.deltaDatabaseToScreen(size, size);			int initialHeight = (int)Math.abs(sizeVector.getY());			// get the font			Font font = new Font(User.getDefaultFont(), Font.PLAIN, initialHeight);			g.setFont(font);			g.setColor(textColor);			FontRenderContext frc = new FontRenderContext(null, true, true);			// convert the message to glyphs			GlyphVector gv = font.createGlyphVector(frc, string);			LineMetrics lm = font.getLineMetrics(string, frc);			Rectangle rect = gv.getOutline(0, lm.getAscent()-lm.getLeading()).getBounds();			double width = rect.width;			double height = lm.getHeight();			Point2D databaseSize = wnd.deltaScreenToDatabase((int)width, (int)height);			double dbWidth = Math.abs(databaseSize.getX());			double dbHeight = Math.abs(databaseSize.getY());			if (maxWid > 0 && maxHei > 0 && (dbWidth > maxWid || dbHeight > maxHei))			{				double scale = Math.min(maxWid / dbWidth, maxHei / dbHeight);				font = new Font(User.getDefaultFont(), Font.PLAIN, (int)(initialHeight*scale));				if (font != null)				{					gv = font.createGlyphVector(frc, string);					lm = font.getLineMetrics(string, frc);					rect = gv.getOutline(0, lm.getAscent()-lm.getLeading()).getBounds();					width = rect.width;					height = lm.getHeight();				}			}			// render the text			Graphics2D g2 = (Graphics2D)g;			Point p = wnd.databaseToScreen(ctr);			g2.drawGlyphVector(gv, (float)(p.x - width/2), (float)(p.y + height/2 - lm.getDescent()));		}	}	// ************************************* GRID *************************************	/**	 * Method to set the display of a grid in this window.	 * @param showGrid true to show the grid.	 */	public void setGrid(boolean showGrid)	{		this.showGrid = showGrid;		fullRepaint();	}	/**	 * Method to return the state of grid display in this window.	 * @return true if the grid is displayed in this window.	 */	public boolean isGrid() { return showGrid; }	/**	 * Method to return the distance between grid dots in the X direction.	 * @return the distance between grid dots in the X direction.	 */	public double getGridXSpacing() { return gridXSpacing; }	/**	 * Method to set the distance between grid dots in the X direction.	 * @param spacing the distance between grid dots in the X direction.	 */	public void setGridXSpacing(double spacing) { gridXSpacing = spacing; }	/**	 * Method to return the distance between grid dots in the Y direction.	 * @return the distance between grid dots in the Y direction.	 */	public double getGridYSpacing() { return gridYSpacing; }	/**	 * Method to set the distance between grid dots in the Y direction.	 * @param spacing the distance between grid dots in the Y direction.	 */	public void setGridYSpacing(double spacing) { gridYSpacing = spacing; }	/**	 * Method to return a rectangle in database coordinates that covers the viewable extent of this window.	 * @return a rectangle that describes the viewable extent of this window (database coordinates).	 */	public Rectangle2D displayableBounds()	{		Point2D low = screenToDatabase(0, 0);		Point2D high = screenToDatabase(sz.width-1, sz.height-1);		double lowX = Math.min(low.getX(), high.getX());		double lowY = Math.min(low.getY(), high.getY());		double sizeX = Math.abs(high.getX()-low.getX());		double sizeY = Math.abs(high.getY()-low.getY());		Rectangle2D bounds = new Rectangle2D.Double(lowX, lowY, sizeX, sizeY);		return bounds;	}	// *************************** SEARCHING FOR TEXT ***************************	/** Information about String search */			private StringSearch textSearch = new StringSearch();	private static class StringSearch implements Serializable	{		/** list of all found strings in the cell */	private List<StringsInCell> foundInCell;		/** the currently reported string index */		private int currentFindPosition;		priv

⌨️ 快捷键说明

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