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

📄 explorertree.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				String theString = (String)nodeInfo;				if (theString.equalsIgnoreCase("jobs"))				{					if (iconJobs == null)						iconJobs = Resources.getResource(getClass(), "IconJobs.gif");					setIcon(iconJobs);				} else if (theString.equalsIgnoreCase("libraries"))				{					if (iconLibraries == null)						iconLibraries = Resources.getResource(getClass(), "IconLibraries.gif");					setIcon(iconLibraries);				} else if (theString.equalsIgnoreCase("errors"))				{					if (iconErrors == null)						iconErrors = Resources.getResource(getClass(), "IconErrors.gif");					setIcon(iconErrors);				} else if (theString.equalsIgnoreCase("signals") || theString.equalsIgnoreCase("trans signals") ||					theString.equalsIgnoreCase("ac signals") || theString.equalsIgnoreCase("dc signals"))				{					if (iconSignals == null)						iconSignals = Resources.getResource(getClass(), "IconSignals.gif");					setIcon(iconSignals);				} else if (theString.equalsIgnoreCase("sweeps") || theString.equalsIgnoreCase("trans sweeps") ||					theString.equalsIgnoreCase("ac sweeps") || theString.equalsIgnoreCase("dc sweeps"))				{					if (iconSweeps == null)						iconSweeps = Resources.getResource(getClass(), "IconSweeps.gif");					setIcon(iconSweeps);				} else if (theString.equalsIgnoreCase("measurements"))				{					if (iconMeasurements == null)						iconMeasurements = Resources.getResource(getClass(), "IconMeasurement.gif");					setIcon(iconMeasurements);				}			}            if (nodeInfo instanceof ErrorLogger.MessageLog)            {                ErrorLogger.MessageLog theLog = (ErrorLogger.MessageLog)nodeInfo;                // Error   WarningLog                if (theLog instanceof ErrorLogger.WarningLog)                {                    if (iconWarnMsg == null)                        iconWarnMsg = Resources.getResource(getClass(), "IconWarningLog.gif");                    setIcon(iconWarnMsg);                } else // warning                {                    if (iconErrorMsg == null)                        iconErrorMsg = Resources.getResource(getClass(), "IconErrorLog.gif");                    setIcon(iconErrorMsg);                }            }			if (nodeInfo instanceof JobTree.JobTreeNode)			{				//JobTree.JobTreeNode j = (JobTree.JobTreeNode)nodeInfo;				//setToolTipText(j.getToolTip());				//System.out.println("set tool tip to "+j.getToolTip());			}			return this;		}		private Map<View,IconGroup> iconGroups = new HashMap<View,IconGroup>();		private IconGroup findIconGroup(View view)		{			IconGroup ig = iconGroups.get(view);			if (ig == null)			{				ig = new IconGroup();				// get the appropriate background icon				if (view == View.LAYOUT) ig.regular = Resources.getResource(getClass(), "IconViewLayout.gif"); else				if (view == View.SCHEMATIC) ig.regular = Resources.getResource(getClass(), "IconViewSchematics.gif"); else				if (view == View.ICON) ig.regular = Resources.getResource(getClass(), "IconViewIcon.gif"); else				if (view == View.DOC) ig.regular = Resources.getResource(getClass(), "IconViewText.gif"); else				ig.regular = Resources.getResource(getClass(), "IconViewMisc.gif");				// make sure the overlay icons have been read				if (iconSpiderWeb == null) iconSpiderWeb = Resources.getResource(getClass(), "IconSpiderWeb.gif");				if (iconLocked == null) iconLocked = Resources.getResource(getClass(), "IconLocked.gif");				if (iconUnlocked == null) iconUnlocked = Resources.getResource(getClass(), "IconUnlocked.gif");				if (iconAvailable == null) iconAvailable = Resources.getResource(getClass(), "IconAvailable.gif");				ig.old = buildIcon(iconSpiderWeb, ig.regular);				ig.available = buildIcon(iconAvailable, ig.regular);				ig.locked = buildIcon(iconLocked, ig.regular);				ig.unlocked = buildIcon(iconUnlocked, ig.regular);				iconGroups.put(view, ig);			}			return ig;		}		private ImageIcon buildIcon(ImageIcon fg, ImageIcon bg)		{			// overlay and create the other icons for this view			int wid = fg.getIconWidth();			int hei = fg.getIconHeight();			BufferedImage bi = new BufferedImage(wid, hei, BufferedImage.TYPE_INT_RGB);			int [] backgroundValues = new int[wid*hei];			PixelGrabber background = new PixelGrabber(bg.getImage(), 0, 0, wid, hei, backgroundValues, 0, wid);			int [] foregroundValues = new int[wid*hei];			PixelGrabber foreground = new PixelGrabber(fg.getImage(), 0, 0, wid, hei, foregroundValues, 0, wid);			try			{				background.grabPixels();				foreground.grabPixels();			} catch (InterruptedException e) {}			for(int y=0; y<hei; y++)			{				for(int x=0; x<wid; x++)				{					int bCol = backgroundValues[y*wid+x];					int fCol = foregroundValues[y*wid+x];					if ((fCol&0xFFFFFF) != 0xFFFFFF) bCol = fCol;					bi.setRGB(x, y, bCol);				}			}			return new ImageIcon(bi);		}	}	private class TreeHandler implements MouseListener, MouseMotionListener, TreeSelectionListener	{        private ExplorerTree tree;        private boolean draggingCell;		private MouseEvent currentMouseEvent;		private TreePath [] currentPaths;		private TreePath [] originalPaths;        TreeHandler (ExplorerTree t) {tree = t;}        public void mouseClicked(MouseEvent e) {}		public void mouseEntered(MouseEvent e) {}		public void mouseExited(MouseEvent e) {}		public void mouseMoved(MouseEvent e) {}		public void mousePressed(MouseEvent e)		{			draggingCell = false;			// popup menu event (right click)			if (e.isPopupTrigger())			{            	selectTreeElement(e.getX(), e.getY());                cacheEvent(e);				doContextMenu();				return;			}            cacheEvent(e);			WindowFrame wf = WindowFrame.getCurrentWindowFrame();			// double click			if (e.getClickCount() == 2)			{				Object clickedObject = null;				TreePath cp = getPathForLocation(e.getX(), e.getY());				if (cp != null)				{	                Object obj = cp.getLastPathComponent();	                if (obj instanceof DefaultMutableTreeNode)	                	clickedObject = ((DefaultMutableTreeNode)obj).getUserObject();				}				// handle things that can accomodate multiple selections				boolean didSomething = false;				boolean clickedIsSelected = false;				for(int i=0; i<numCurrentlySelectedObjects(); i++)				{					Object obj = getCurrentlySelectedObject(i);					if (obj == clickedObject) clickedIsSelected = true;					if (obj instanceof Signal)					{						Signal sig = (Signal)obj;						if (wf.getContent() instanceof WaveformWindow)						{							WaveformWindow ww = (WaveformWindow)wf.getContent();							ww.addSignal(sig);						}						didSomething = true;					}					if (obj instanceof SweepSignal)					{						SweepSignal ss = (SweepSignal)obj;						if (ss == null) return;						ss.setIncluded(!ss.isIncluded(), true);						updateUI();						didSomething = true;					}				}				if (didSomething) return;				if (!clickedIsSelected) return;				// must have only 1 selection                if (numCurrentlySelectedObjects() == 0)                    return;                if (numCurrentlySelectedObjects() != 1)				{					Job.getUserInterface().showErrorMessage("Must select just one entry in the explorer tree", "Too Much Selected");					return;				}				Object nodeObj = getCurrentlySelectedObject(0);				if (nodeObj instanceof ExplorerTreeModel.CellAndCount)				{					ExplorerTreeModel.CellAndCount cc = (ExplorerTreeModel.CellAndCount)nodeObj;					wf.setCellWindow(cc.getCell(), null);					return;				}				if (nodeObj instanceof Cell)				{					Cell cell = (Cell)nodeObj;					wf.setCellWindow(cell, null);					return;				}				if (nodeObj instanceof ExplorerTreeModel.MultiPageCell)				{					ExplorerTreeModel.MultiPageCell mpc = (ExplorerTreeModel.MultiPageCell)nodeObj;					Cell cell = mpc.getCell();					wf.setCellWindow(cell, null);					if (wf.getContent() instanceof EditWindow)					{						EditWindow wnd = (EditWindow)wf.getContent();						wnd.setMultiPageNumber(mpc.getPageNo());					}					return;				}				if (nodeObj instanceof Library || nodeObj instanceof Cell.CellGroup ||					nodeObj instanceof String || nodeObj instanceof ErrorLoggerTree.ErrorLoggerTreeNode)				{					for(int i=0; i<currentPaths.length; i++)					{						if (isExpanded(currentPaths[i])) collapsePath(currentPaths[i]); else							expandPath(currentPaths[i]);					}					return;				}				if (nodeObj instanceof JobTree.JobTreeNode)				{					System.out.println(((JobTree.JobTreeNode)nodeObj).getInfo());					return;				}				if (nodeObj instanceof ErrorLogger.MessageLog)				{                    ErrorLogger.MessageLog el = (ErrorLogger.MessageLog)nodeObj;                    Object tree = cp.getParentPath().getLastPathComponent(); // flat method                    if (!(tree instanceof ErrorLoggerTree.ErrorLoggerDefaultMutableTreeNode))                        tree = cp.getParentPath().getParentPath().getLastPathComponent();                    if (!(tree instanceof ErrorLoggerTree.ErrorLoggerDefaultMutableTreeNode))                        assert(false); // should this happen?                    {                        ErrorLoggerTree.ErrorLoggerDefaultMutableTreeNode er = (ErrorLoggerTree.ErrorLoggerDefaultMutableTreeNode)tree;                        Object obj = er.getUserObject();                        ErrorLoggerTree.ErrorLoggerTreeNode node = (ErrorLoggerTree.ErrorLoggerTreeNode)obj;                        int index = node.getLogger().getLogIndex(el);                        node.setLogNumber(index);                    }					String msg = Job.getUserInterface().reportLog(el,true, null);					System.out.println(msg);					return;				}				// dragging: remember original object				if (nodeObj instanceof Cell)				{					Cell cell = (Cell)nodeObj;					if (cell.getNewestVersion() == cell)					{						originalPaths = new TreePath[currentPaths.length];						for(int i=0; i<currentPaths.length; i++)							originalPaths[i] = new TreePath(currentPaths[i].getPath());						draggingCell = true;					}				}			}		}		public void mouseReleased(MouseEvent e)		{            // popup menu event (right click)            if (e.isPopupTrigger())            {            	selectTreeElement(e.getX(), e.getY());                cacheEvent(e);                doContextMenu();            }		}		public void mouseDragged(MouseEvent e)		{			if (!draggingCell) return;			cacheEvent(e);			clearSelection();			for(int i=0; i<originalPaths.length; i++)				addSelectionPath(originalPaths[i]);			for(int i=0; i<currentPaths.length; i++)				addSelectionPath(currentPaths[i]);			updateUI();		}		public void valueChanged(TreeSelectionEvent e)		{			currentPaths = getSelectionPaths();			if (currentPaths == null) currentPaths = new TreePath[0];			if (currentPaths.length > 0)			{			    Rectangle bounds = getPathBounds(currentPaths[0]);			    if (bounds != null)			    {					bounds.x = 0;					bounds.y -= bounds.height;				    bounds.width = 0;				    bounds.height *= 3;				    scrollRectToVisible(bounds);			    }			}			currentSelectedPaths = new TreePath[currentPaths.length];			for(int i=0; i<currentPaths.length; i++)			{                currentSelectedPaths[i] = currentPaths[i];			}			// update highlighting to match this selection			for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); )			{				WindowFrame wf = it.next();				if (wf.getExplorerTab() == ExplorerTree.this)				{					// initiate crossprobing from WaveformWindow					if (wf.getContent() instanceof WaveformWindow)					{						WaveformWindow ww = (WaveformWindow)wf.getContent();						ww.crossProbeWaveformToEditWindow();					}				}			}		}		private void selectTreeElement(int x, int y)		{			TreePath cp = getPathForLocation(x, y);			if (cp != null)			{				Object obj = getObjectInTreePath(cp);				boolean selected = false;				for(int i=0; i<numCurrentlySelectedObjects(); i++)				{					if (getCurrentlySelectedObject(i) == obj) { selected = true;   break; }				}				if (!selected)				{

⌨️ 快捷键说明

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