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

📄 panel.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			int highY = Math.max(convertYDataToScreen(meas.getMinY()), convertYDataToScreen(meas.getMaxY()));			g.drawLine(lowX, lowY, lowX, highY);			g.drawLine(lowX, highY, highX, highY);			g.drawLine(highX, highY, highX, lowY);			g.drawLine(highX, lowY, lowX, lowY);			// show dimensions while dragging			double lowXValue = convertXScreenToData(lowX);			double highXValue = convertXScreenToData(highX);			double lowValue = convertYScreenToData(highY);			double highValue = convertYScreenToData(lowY);			g.setFont(waveWindow.getFont());			// show the low X value and arrow			String lowXValueString = TextUtils.convertToEngineeringNotation(lowXValue, "s");			GlyphVector gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), lowXValueString);			Rectangle2D glyphBounds = gv.getLogicalBounds();			int textWid = (int)glyphBounds.getWidth();			int textHei = (int)glyphBounds.getHeight();			int textY = (lowY+highY)/2;			g.drawString(lowXValueString, lowX-textWid-6, textY+textHei/2-10);			g.drawLine(lowX-1, textY, lowX-textWid, textY);			g.drawLine(lowX-1, textY, lowX-6, textY+4);			g.drawLine(lowX-1, textY, lowX-6, textY-4);			// show the high X value and arrow			String highXValueString = TextUtils.convertToEngineeringNotation(highXValue, "s");			gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), highXValueString);			glyphBounds = gv.getLogicalBounds();			textWid = (int)glyphBounds.getWidth();			textHei = (int)glyphBounds.getHeight();			int highXValueTextWid = textWid;			g.drawString(highXValueString, highX+6, textY+textHei/2-10);			g.drawLine(highX+1, textY, highX+textWid, textY);			g.drawLine(highX+1, textY, highX+6, textY+4);			g.drawLine(highX+1, textY, highX+6, textY-4);			// show the difference X value			String xDiffString = TextUtils.convertToEngineeringNotation(highXValue-lowXValue, "s");			gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), xDiffString);			glyphBounds = gv.getLogicalBounds();			textWid = (int)glyphBounds.getWidth();			textHei = (int)glyphBounds.getHeight();			if (textWid + 24 < highX - lowX)			{				// fits inside: draw arrows around text				int yPosText = highY + textHei*5;				int yPos = yPosText - textHei/2;				int xCtr = (highX+lowX)/2;				g.drawString(xDiffString, xCtr - textWid/2, yPosText);				g.drawLine(lowX, yPos, xCtr - textWid/2 - 2, yPos);				g.drawLine(highX, yPos, xCtr + textWid/2 + 2, yPos);				g.drawLine(lowX, yPos, lowX+5, yPos+4);				g.drawLine(lowX, yPos, lowX+5, yPos-4);				g.drawLine(highX, yPos, highX-5, yPos+4);				g.drawLine(highX, yPos, highX-5, yPos-4);			} else			{				// does not fit inside: draw outside of arrows				int yPosText = highY + textHei*5;				int yPos = yPosText - textHei/2;				g.drawString(xDiffString, highX + 12, yPosText);				g.drawLine(lowX, yPos, lowX-10, yPos);				g.drawLine(highX, yPos, highX+10, yPos);				g.drawLine(lowX, yPos, lowX-5, yPos+4);				g.drawLine(lowX, yPos, lowX-5, yPos-4);				g.drawLine(highX, yPos, highX+5, yPos+4);				g.drawLine(highX, yPos, highX+5, yPos-4);			}			if (analog)			{				// show the low value				String lowValueString = TextUtils.convertToEngineeringNotation(highValue, null);				gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), lowValueString);				glyphBounds = gv.getLogicalBounds();				textWid = (int)glyphBounds.getWidth();				textHei = (int)glyphBounds.getHeight();				int xP = (lowX+highX)/2;				int yText = lowY - 10 - textHei;				g.drawString(lowValueString, xP, yText - 2);				g.drawLine(xP, lowY-1, xP, yText);				g.drawLine(xP, lowY-1, xP+4, lowY-5);				g.drawLine(xP, lowY-1, xP-4, lowY-5);				// show the high value				String highValueString = TextUtils.convertToEngineeringNotation(lowValue, null);				gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), highValueString);				glyphBounds = gv.getLogicalBounds();				textWid = (int)glyphBounds.getWidth();				textHei = (int)glyphBounds.getHeight();				yText = highY + 10 + textHei;				g.drawString(highValueString, xP, yText + textHei + 2);				g.drawLine(xP, highY+1, xP, yText);				g.drawLine(xP, highY+1, xP+4, highY+5);				g.drawLine(xP, highY+1, xP-4, highY+5);				// show the value difference				String valueDiffString = TextUtils.convertToEngineeringNotation(highValue - lowValue, null);				gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), valueDiffString);				glyphBounds = gv.getLogicalBounds();				textWid = (int)glyphBounds.getWidth();				textHei = (int)glyphBounds.getHeight();				if (textHei + 12 < highY - lowY)				{					// fits inside: draw arrows around text					int xPos = highX + highXValueTextWid + 30;					int yCtr = (highY+lowY)/2;					g.drawString(valueDiffString, xPos+2, yCtr + textHei/2);					g.drawLine(xPos, lowY, xPos, highY);					g.drawLine(xPos, lowY, xPos+4, lowY+5);					g.drawLine(xPos, lowY, xPos-4, lowY+5);					g.drawLine(xPos, highY, xPos+4, highY-5);					g.drawLine(xPos, highY, xPos-4, highY-5);				} else				{					// does not fit inside: draw outside of arrows					int xPos = highX + highXValueTextWid + 30;					g.drawString(valueDiffString, xPos+4, lowY - textHei/2 - 4);					g.drawLine(xPos, lowY, xPos, lowY-10);					g.drawLine(xPos, highY, xPos, highY+10);					g.drawLine(xPos, lowY, xPos+4, lowY-5);					g.drawLine(xPos, lowY, xPos-4, lowY-5);					g.drawLine(xPos, highY, xPos+4, highY+5);					g.drawLine(xPos, highY, xPos-4, highY+5);				}			}		}	}	private void drawPanelContents(int wid, int hei, Graphics2D localGraphics, Rectangle2D bounds, List<PolyBase> polys)	{		// draw the grid first (behind the signals)		if (analog && waveWindow.isShowGrid())		{			if (localGraphics != null)			{				localGraphics.setStroke(Highlight2.dottedLine);				localGraphics.setColor(gridColor);			}			// draw the vertical grid lines			double displayedXLow = convertXScreenToData(vertAxisPos);			double displayedXHigh = convertXScreenToData(wid);			StepSize ss = new StepSize(displayedXHigh, displayedXLow, 10);			if (ss.getSeparation() != 0.0)			{				double value = ss.getLowValue();				for(;;)				{					if (value >= displayedXLow)					{						if (value > ss.getHighValue()) break;						int x = convertXDataToScreen(value);						if (polys != null)						{							polys.add(new Poly(new Point2D[] {								new Point2D.Double(x, 0),								new Point2D.Double(x, hei)}));						} else						{							localGraphics.drawLine(x, 0, x, hei);						}					}					value += ss.getSeparation();				}			}			ss = new StepSize(analogHighValue, analogLowValue, 5);			if (ss.getSeparation() != 0.0)			{				double value = ss.getLowValue();				for(;;)				{					if (value >= analogLowValue)					{						if (value > analogHighValue || value > ss.getHighValue()) break;						int y = convertYDataToScreen(value);						if (polys != null)						{							polys.add(new Poly(new Point2D[] {								new Point2D.Double(vertAxisPos, y),								new Point2D.Double(wid, y)}));						} else						{							localGraphics.drawLine(vertAxisPos, y, wid, y);						}					}					value += ss.getSeparation();				}			}			if (localGraphics != null)			{				localGraphics.setStroke(Highlight2.solidLine);			}		}		// draw all of the signals		if (USE_ANTIALIASING && analog && localGraphics != null) {			Object oldAntialiasing = localGraphics.getRenderingHint(RenderingHints.KEY_ANTIALIASING);			localGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);			processSignals(localGraphics, bounds, polys);			localGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldAntialiasing);		} else {			processSignals(localGraphics, bounds, polys);		}		// draw all of the control points		if (localGraphics != null) processControlPoints(localGraphics, bounds);		// draw the vertical label		if (polys != null)		{			polys.add(new Poly(new Point2D[] {				new Point2D.Double(vertAxisPos, 0),				new Point2D.Double(vertAxisPos, hei)}));		} else		{			localGraphics.setColor(new Color(User.getColor(User.ColorPrefType.WAVE_FOREGROUND)));			localGraphics.drawLine(vertAxisPos, 0, vertAxisPos, hei);			if (selected)			{				localGraphics.drawLine(vertAxisPos-1, 0, vertAxisPos-1, hei);				localGraphics.drawLine(vertAxisPos-2, 0, vertAxisPos-2, hei-1);				localGraphics.drawLine(vertAxisPos-3, 0, vertAxisPos-3, hei-2);			}		}		if (analog)		{			double displayedLow = convertYScreenToData(hei);			double displayedHigh = convertYScreenToData(0);			StepSize ss = new StepSize(displayedHigh, displayedLow, 5);			if (ss.getSeparation() != 0.0)			{				double value = ss.getLowValue();				if (localGraphics != null)					localGraphics.setFont(waveWindow.getFont());				int lastY = -1;				for(int i=0; ; i++)				{					if (value > displayedHigh) break;					if (value >= displayedLow)					{						int y = convertYDataToScreen(value);						if (lastY >= 0)						{							if (lastY - y > 100)							{								// add 5 tick marks								for(int j=1; j<5; j++)								{									int intY = (lastY - y) / 5 * j + y;									if (polys != null)									{										polys.add(new Poly(new Point2D[] {											new Point2D.Double(vertAxisPos-5, intY),											new Point2D.Double(vertAxisPos, intY)}));									} else									{										localGraphics.drawLine(vertAxisPos-5, intY, vertAxisPos, intY);									}								}							} else if (lastY - y > 25)							{								// add 1 tick mark								int intY = (lastY - y) / 2 + y;								if (polys != null)								{									polys.add(new Poly(new Point2D[] {										new Point2D.Double(vertAxisPos-5, intY),										new Point2D.Double(vertAxisPos, intY)}));								} else								{									localGraphics.drawLine(vertAxisPos-5, intY, vertAxisPos, intY);								}							}						}						if (polys != null)						{							polys.add(new Poly(new Point2D[] {								new Point2D.Double(vertAxisPos-10, y),								new Point2D.Double(vertAxisPos, y)}));						} else						{							localGraphics.drawLine(vertAxisPos-10, y, vertAxisPos, y);						}						String yValue = TextUtils.convertToEngineeringNotation(value, null);						if (polys != null)						{							Poly poly = new Poly(new Point2D[] {								new Point2D.Double(vertAxisPos-12, y)});							poly.setStyle(Poly.Type.TEXTRIGHT);							poly.setTextDescriptor(TextDescriptor.EMPTY.withAbsSize(6));							poly.setString(yValue);							polys.add(poly);						} else						{							GlyphVector gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), yValue);							Rectangle2D glyphBounds = gv.getLogicalBounds();							int height = (int)glyphBounds.getHeight();							int yPos = y + height / 2;							if (yPos-height <= 0) yPos = height+1;							if (yPos >= hei) yPos = hei;							int xPos = vertAxisPos-10-(int)glyphBounds.getWidth()-2;							if (xPos < 0) xPos = 0;							localGraphics.drawString(yValue, xPos, yPos);						}						lastY = y;					}					value += ss.getSeparation();				}			}		}	}	private List<WaveSelection> processSignals(Graphics g, Rectangle2D bounds, List<PolyBase> forPs)	{		List<WaveSelection> selectedObjects = null;		if (bounds != null) selectedObjects = new ArrayList<WaveSelection>();		int hei = sz.height;		Signal xSignal = xAxisSignal;		if (waveWindow.isXAxisLocked()) xSignal = waveWindow.getXAxisSignalAll();		double[] result = new double[3];		int linePointMode = waveWindow.getLinePointMode();		Collection<WaveSignal> sigs = waveSignals.values();		int sigIndex = 0;		for(WaveSignal ws : sigs)		{			if (g != null)			{				if (waveWindow.getPrintingMode() == 2) g.setColor(Color.BLACK); else					g.setColor(ws.getColor());			}			if (forPs != null)			{				double yPos = hei / 2;				Poly.Type style = Poly.Type.TEXTRIGHT;				if (sigs.size() > 1)				{					if (sigIndex == sigs.size()-1) style = Poly.Type.TEXTBOTRIGHT; else						if (sigIndex == 0) style = Poly.Type.TEXTTOPRIGHT;					yPos = ((double)(hei * sigIndex)) / (sigs.size()-1);				}				Poly poly = new Poly(new Point2D[] {new Point2D.Double(0, yPos)});				poly.setStyle(style);				poly.setTextDescriptor(TextDescriptor.EMPTY.withAbsSize(12));				poly.setString(ws.getSignal().getFullName());				forPs.add(poly);			}			sigIndex++;			if (ws.getSignal() instanceof AnalogSignal)			{				// draw analog trace				AnalogSignal as = (AnalogSignal)ws.getSignal();				AnalogAnalysis an = as.getAnalysis();				for (int s = 0, numSweeps = as.getNumSweeps(); s < numSweeps; s++)				{					boolean included = waveWindow.isSweepSignalIncluded(an, s);					if (!included)						continue;					Waveform waveform = as.getWaveform(s);                    Waveform xWaveform = null;                    if (xSignal != null)                        xWaveform = ((AnalogSignal)xSignal).getWaveform(s);					int lastX = 0, lastLY = 0, lastHY = 0;					int numEvents = waveform.getNumEvents();					for(int i=0; i<numEvents; i++)					{

⌨️ 快捷键说明

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