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

📄 panel.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                        waveform.getEvent(i, result);                        int x = convertXDataToScreen(result[0]);                        int lowY = convertYDataToScreen(result[1]);                        int highY = convertYDataToScreen(result[2]);						if (xWaveform != null)						{							xWaveform.getEvent(i, result);							x = convertXDataToScreen(result[1]);						}						if ((x >= vertAxisPos && x <= sz.width) ||							(lastX > vertAxisPos && lastX < sz.width))						{	                        if (i != 0)	                        {	                        	if (linePointMode <= 1)	                        	{	                        		// drawing has lines		                            if (processALine(g, lastX, lastLY, x, lowY, bounds, forPs, selectedObjects, ws, s)) break;		                            if (lastLY != lastHY || lowY != highY)		                            {		        						if (processALine(g, lastX, lastHY, x, highY, bounds, forPs, selectedObjects, ws, s)) break;		        						if (processALine(g, lastX, lastHY, x, lowY, bounds, forPs, selectedObjects, ws, s)) break;		        						if (processALine(g, lastX, lastLY, x, highY, bounds, forPs, selectedObjects, ws, s)) break;		                            }	                        	}							}	                        if (an.extrapolateValues() && i == numEvents-1 && linePointMode <= 1)	                    	{	                    		if (getMinXAxis() < getMaxXAxis())	                    		{		                    		// process extrapolated line from the last data point		                            if (processALine(g, x, lowY, sz.width, lowY, bounds, forPs, selectedObjects, ws, s)) break;		                            if (lastLY != lastHY || lowY != highY)		                            {		        						if (processALine(g, x, highY, sz.width, highY, bounds, forPs, selectedObjects, ws, s)) break;		                            }	                    		}	                    	}	                    	if (linePointMode >= 1)							{	                    		// drawing has points								if (processABox(g, x-2, lowY-2, x+2, lowY+2, bounds, forPs, selectedObjects, ws, false, 0)) break;							}						}						lastX = x;   lastLY = lowY; lastHY = highY;					}				}				continue;            }			if (ws.getSignal() instanceof DigitalSignal)			{				// draw digital traces				DigitalSignal ds = (DigitalSignal)ws.getSignal();				DigitalAnalysis an = ds.getAnalysis();				List<DigitalSignal> bussedSignals = ds.getBussedSignals();				if (bussedSignals != null)				{					// a digital bus trace					long curYValue = 0;					double curXValue = 0;					int lastX = vertAxisPos;					for(;;)					{						double nextXValue = Double.MAX_VALUE;						int bit = 0;						boolean curDefined = true;						for(Signal subSig : bussedSignals)						{							DigitalSignal subDS = (DigitalSignal)subSig;							int numEvents = subDS.getNumEvents();							boolean undefined = false;							for(int i=0; i<numEvents; i++)							{								double xValue = subDS.getTime(i);								if (xValue <= curXValue)								{									switch (subDS.getState(i) & Stimuli.LOGIC)									{										case Stimuli.LOGIC_LOW:  curYValue &= ~(1<<bit);   undefined = false;   break;										case Stimuli.LOGIC_HIGH: curYValue |= (1<<bit);    undefined = false;   break;										case Stimuli.LOGIC_X:										case Stimuli.LOGIC_Z: undefined = true;    break;									}								} else								{									if (xValue < nextXValue) nextXValue = xValue;									break;								}							}							if (undefined) { curDefined = false;   break; }							bit++;						}						int x = convertXDataToScreen(curXValue);						if (x >= vertAxisPos)						{							if (x < vertAxisPos+5)							{								// on the left edge: just draw the "<"								if (processALine(g, x, hei/2, x+5, hei-5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;								if (processALine(g, x, hei/2, x+5, 5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;							} else							{								// bus change point: draw the "X"								if (processALine(g, x-5, 5, x+5, hei-5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;								if (processALine(g, x+5, 5, x-5, hei-5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;							}							if (lastX+5 < x-5)							{								// previous bus change point: draw horizontal bars to connect								if (processALine(g, lastX+5, 5, x-5, 5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;								if (processALine(g, lastX+5, hei-5, x-5, hei-5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;							}							String valString = "XX";							if (curDefined) valString = Long.toString(curYValue);							if (g != null)							{								g.setFont(waveWindow.getFont());								GlyphVector gv = waveWindow.getFont().createGlyphVector(waveWindow.getFontRenderContext(), valString);								Rectangle2D glyphBounds = gv.getLogicalBounds();								int textHei = (int)glyphBounds.getHeight();								g.drawString(valString, x+2, hei/2+textHei/2);							}							if (forPs != null)							{								Point2D [] pts = new Point2D[1];								pts[0] = new Point2D.Double(x+2, hei/2);								Poly poly = new Poly(pts);								poly.setStyle(Poly.Type.TEXTLEFT);								poly.setTextDescriptor(TextDescriptor.EMPTY.withAbsSize(8));								poly.setString(valString);								forPs.add(poly);							}						}						curXValue = nextXValue;						lastX = x;						if (nextXValue == Double.MAX_VALUE) break;					}					if (an.extrapolateValues())					{						int wid = sz.width;						if (lastX+5 < wid)						{							// run horizontal bars to the end							if (processALine(g, lastX+5, 5, wid, 5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;							if (processALine(g, lastX+5, hei-5, wid, hei-5, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;						}					}					continue;				}				// a simple digital signal				int lastx = vertAxisPos;				int lastState = 0;				if (ds.getStateVector() == null) continue;				int numEvents = ds.getNumEvents();				int lastLowy = 0, lastHighy = 0;				for(int i=0; i<numEvents; i++)				{					double xValue = ds.getTime(i);					int x = convertXDataToScreen(xValue);					if (Simulation.isWaveformDisplayMultiState() && g != null)					{						if (waveWindow.getPrintingMode() == 2) g.setColor(Color.BLACK); else						{							switch (ds.getState(i) & Stimuli.STRENGTH)							{								case Stimuli.OFF_STRENGTH:  g.setColor(waveWindow.getOffStrengthColor());    break;								case Stimuli.NODE_STRENGTH: g.setColor(waveWindow.getNodeStrengthColor());   break;								case Stimuli.GATE_STRENGTH: g.setColor(waveWindow.getGateStrengthColor());   break;								case Stimuli.VDD_STRENGTH:  g.setColor(waveWindow.getPowerStrengthColor());  break;							}						}					}					int state = ds.getState(i) & Stimuli.LOGIC;					int lowy = 0, highy = 0;					switch (state)					{						case Stimuli.LOGIC_HIGH:							lowy = highy = 5;							break;						case Stimuli.LOGIC_LOW:							lowy = highy = hei-5;							break;						case Stimuli.LOGIC_X:							lowy = 5;   highy = hei-5;							break;						case Stimuli.LOGIC_Z:							lowy = (hei-10) / 3 + 5;   highy = hei - (hei-10) / 3 - 5;							break;					}					if (g != null && !Simulation.isWaveformDisplayMultiState()) g.setColor(Color.RED);					if (i != 0)					{						if (state != lastState)						{							if (processALine(g, x, Math.min(lowy, lastLowy), x, Math.max(lowy, lastLowy), bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;						}					}					if (g != null && !Simulation.isWaveformDisplayMultiState())					{						if (lastState == Stimuli.LOGIC_Z) g.setColor(Color.GREEN);					}					if (lastLowy == lastHighy)					{						if (processALine(g, lastx, lastLowy, x, lastLowy, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;					} else					{						if (processABox(g, lastx, lastLowy, x, lastHighy, bounds, forPs, selectedObjects, ws, false, 0)) return selectedObjects;					}					if (an.extrapolateValues())					{						if (i >= numEvents-1)						{							if (g != null && !Simulation.isWaveformDisplayMultiState())							{								if (state == Stimuli.LOGIC_Z) g.setColor(Color.GREEN); else g.setColor(Color.RED);							}							int wid = sz.width;							if (lowy == highy)							{								if (processALine(g, x, lowy, wid-1, lowy, bounds, forPs, selectedObjects, ws, -1)) return selectedObjects;							} else							{								if (processABox(g, x, lowy, wid-1, highy, bounds, forPs, selectedObjects, ws, false, 0)) return selectedObjects;							}						}					}					lastx = x;					lastLowy = lowy;					lastHighy = highy;					lastState = state;				}			}		}		return selectedObjects;	}	private List<WaveSelection> processControlPoints(Graphics g, Rectangle2D bounds)	{		List<WaveSelection> selectedObjects = null;		if (bounds != null) selectedObjects = new ArrayList<WaveSelection>();		// show control points		for(WaveSignal ws : waveSignals.values())		{			if (g != null) g.setColor(ws.getColor());			Double [] points = ws.getSignal().getControlPoints();			if (points == null) continue;			if (g != null) g.setColor(ws.getColor());			for(int i=0; i<points.length; i++)			{				double xValue = points[i].doubleValue();				int x = convertXDataToScreen(xValue);				if (processABox(g, x-CONTROLPOINTSIZE, sz.height-CONTROLPOINTSIZE*2, x+CONTROLPOINTSIZE, sz.height,					bounds, null, selectedObjects, ws, true, xValue)) break;				// see if the control point is selected				boolean found = false;				if (bounds == null && ws.getSelectedControlPoints() != null)				{					for(int j=0; j<ws.getSelectedControlPoints().length; j++)						if (ws.getSelectedControlPoints()[j] == xValue) { found = true;   break; }				}				if (found)				{					g.setColor(Color.GREEN);					if (processABox(g, x-CONTROLPOINTSIZE+2, sz.height-CONTROLPOINTSIZE*2+2, x+CONTROLPOINTSIZE-2, sz.height-2,						bounds, null, selectedObjects, ws, true, xValue)) break;					g.setColor(ws.getColor());				}			}		}		return selectedObjects;	}	private boolean processABox(Graphics g, int lX, int lY, int hX, int hY, Rectangle2D bounds, List<PolyBase> forPs,		List<WaveSelection> result, WaveSignal ws, boolean controlPoint, double controlXValue)	{		// bounds is non-null if doing hit-testing		if (bounds != null)		{			// do bounds checking for hit testing			if (hX > bounds.getMinX() && lX < bounds.getMaxX() && hY > bounds.getMinY() && lY < bounds.getMaxY())			{				if (forPs != null)				{					PolyBase poly = new PolyBase((lX+hX)/2, (lY+hY)/2, hX-lX, hY-lY);					poly.setStyle(Poly.Type.FILLED);					poly.setLayer(Artwork.tech().defaultLayer);					forPs.add(poly);					return false;				}				WaveSelection wSel = new WaveSelection();				wSel.ws = ws;				wSel.controlPoint = controlPoint;				wSel.controlXValue = controlXValue;				result.add(wSel);				return true;			}			return false;		}		// clip to left edge		if (hX <= vertAxisPos) return false;		if (lX < vertAxisPos) lX = vertAxisPos;		// not doing hit-testing, just doing drawing		g.fillRect(lX, lY, hX-lX, hY-lY);		return false;	}	private boolean processALine(Graphics g, int fX, int fY, int tX, int tY, Rectangle2D bounds,		List<PolyBase> forPs, List<WaveSelection> result, WaveSignal ws, int sweepNum)	{		if (bounds != null)		{			// do bounds checking for hit testing			Point2D from = new Point2D.Double(fX, fY);			Point2D to = new Point2D.Double(tX, tY);			if (!GenMath.clipLine(from, to, bounds.getMinX(), bounds.getMaxX(), bounds.getMinY(), bounds.getMaxY()))			{				if (forPs != null)				{					forPs.add(new PolyBase(new Point2D[] {from, to}));					return false;				}				WaveSelection wSel = new WaveSelection();				wSel.ws = ws;				wSel.controlPoint = false;				result.add(wSel);				return true;			}			return false;		}		// clip to left edge		if (fX < vertAxisPos || tX < vertAxisPos)		{			Point2D from = new Point2D.Double(fX, fY);			Point2D to = new Point2D.Double(tX, tY);			if (GenMath.clipLine(from, to, vertAxisPos, sz.width, 0, sz.height)) return false;			fX = (int)from.getX();			fY = (int)from.getY();			tX = (int)to.getX();			tY = (int)to.getY();		}		// draw the line		g.drawLine(fX, fY, tX, tY);		// highlight the line if requested		boolean highlighted = ws.isHighlighted();		if (ws.getPanel().waveWindow.getHighlightedSweep() >= 0)		{			highlighted = ws.getPanel().waveWindow.getHighlightedSweep() == sweepNum;		}		if (highlighted)		{			if (fX == tX)			{				// vertical line				g.drawLine(fX-1, fY, tX-1, tY);				g.drawLine(fX+1, fY, tX+1, tY);			} else if (fY == tY)			{		

⌨️ 快捷键说明

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