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

📄 explorertree.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		public boolean canImport(JComponent comp, DataFlavor[] transferFlavors) { return real.canImport(comp, transferFlavors); }		public void exportAsDrag(JComponent comp, InputEvent e, int action)  { real.exportAsDrag(comp, e, action); }		protected void exportDone(JComponent source, Transferable data, int action)  {  }		public void exportToClipboard(JComponent comp, Clipboard clip, int action)  { real.exportToClipboard(comp, clip, action); }		public int getSourceActions(JComponent c)  { return real.getSourceActions(c); }		public Icon getVisualRepresentation(Transferable t)  { return real.getVisualRepresentation(t); }		public boolean importData(JComponent comp, Transferable t) { return real.importData(comp, t); }	}//	public void dragGestureRecognized(DragGestureEvent e)//	{//		if (numCurrentlySelectedObjects() == 0) return;////		// handle signal dragging when in a WaveformWindow setting//		if (getCurrentlySelectedObject(0) instanceof Signal)//		{//			// Get the Transferable Object//			StringBuffer buf = new StringBuffer();//			for(int i=0; i<numCurrentlySelectedObjects(); i++)//			{//				Signal sSig = (Signal)getCurrentlySelectedObject(i);//				String sigName = sSig.getFullName();//				if (sSig instanceof AnalogSignal)//				{//					AnalogSignal as = (AnalogSignal)sSig;//					if (as.getAnalysis().getAnalysisType() == Analysis.ANALYSIS_TRANS) sigName = "TRANS " + sigName; else//						if (as.getAnalysis().getAnalysisType() == Analysis.ANALYSIS_AC) sigName = "AC " + sigName; else//							if (as.getAnalysis().getAnalysisType() == Analysis.ANALYSIS_DC) sigName = "DC " + sigName; else//								if (as.getAnalysis().getAnalysisType() == Analysis.ANALYSIS_MEAS) sigName = "MEASUREMENT " + sigName;//				}//				buf.append(sigName);//				buf.append("\n");//			}//			Transferable transferable = new StringSelection(buf.toString());////			// begin the drag//			dragSource.startDrag(e, DragSource.DefaultLinkDrop, transferable, this);//			return;//		}////		// cells and groups must be dragged one-at-a-time//		if (numCurrentlySelectedObjects() > 1)//		{//			Job.getUserInterface().showErrorMessage("Can drag only one Cell or Group", "Too Much Selected");//			return;//		}////		// make a Transferable object//		EditWindow.NodeProtoTransferable transferable = new EditWindow.NodeProtoTransferable(getCurrentlySelectedObject(0), this);//		if (!transferable.isValid()) return;////		// find out the offset of the cursor to the selected tree node//		Point pt = e.getDragOrigin();//		TreePath path = getPathForLocation(pt.x, pt.y);//		Rectangle pathRect = getPathBounds(path);//		if (pathRect == null) return;//		dragOffset = new Point(pt.x-pathRect.x, pt.y-pathRect.y);////		// render the dragged stuff//		Component comp = getCellRenderer().getTreeCellRendererComponent(this, path.getLastPathComponent(),//			false, isExpanded(path), getModel().isLeaf(path.getLastPathComponent()), 0, false);//		int wid = (int)pathRect.getWidth();//		int hei = (int)pathRect.getHeight();////		subCells = false;//		if (e.getTriggerEvent() instanceof MouseEvent)//			subCells = ClickZoomWireListener.isRightMouse((MouseEvent)e.getTriggerEvent());//		if (subCells) hei *= 2;//		comp.setSize(wid, hei);//		dragImage = new BufferedImage(wid, hei, BufferedImage.TYPE_INT_ARGB_PRE);//		Graphics2D g2 = dragImage.createGraphics();//		g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 0.5f));//		AffineTransform saveAT = g2.getTransform();//		if (subCells) g2.translate(0, -hei/4);//		comp.paint(g2);//		g2.setTransform(saveAT);//		if (subCells)//		{//			g2.setColor(Color.BLACK);//			g2.drawLine(wid/2, hei/2, 0, hei);//			g2.drawLine(wid/2, hei/2, wid/3, hei);//			g2.drawLine(wid/2, hei/2, wid/3*2, hei);//			g2.drawLine(wid/2, hei/2, wid, hei);//		}//		g2.dispose();////		// begin the drag//		e.startDrag(null, dragImage, new Point(0, 0), transferable, this);//	}	public void dragEnter(DragSourceDragEvent e) {}	public void dragOver(DragSourceDragEvent e) {}	public void dragExit(DragSourceEvent e) {}	public void dragDropEnd(DragSourceDropEvent e) {}	public void dropActionChanged (DragSourceDragEvent e) {}	/**	 * Class for catching drags into the explorer tree.	 * These drags come from elsewhere in the Explorer tree (cross-library copy, etc).	 */	private static class ExplorerTreeDropTarget implements DropTargetListener	{		private Rectangle lastDrawn = null;		public void dragEnter(DropTargetDragEvent e)		{			dragAction(e);		}		public void dragOver(DropTargetDragEvent e)		{			DropTarget dt = (DropTarget)e.getSource();			ExplorerTree tree = (ExplorerTree)dt.getComponent();			Graphics2D g2 = (Graphics2D)tree.getGraphics();			// erase former drawing			eraseDragImage(dt);			// get the original cell that was dragged			Object obj = getDraggedObject(e.getCurrentDataFlavors());			ExplorerTree originalTree = getOriginalTree(e.getCurrentDataFlavors());			if (originalTree == null) return;			if (obj instanceof Cell.CellGroup) obj = ((Cell.CellGroup)obj).getCells().next();			if (!(obj instanceof Cell)) return;			Cell origCell = (Cell)obj;			// draw the image of what is being dragged			if (!DragSource.isDragImageSupported())			{				// Remember where you are about to draw the new ghost image				lastDrawn = new Rectangle(e.getLocation().x - originalTree.dragOffset.x,					e.getLocation().y - originalTree.dragOffset.y,					originalTree.dragImage.getWidth(), originalTree.dragImage.getHeight());				// Draw the ghost image				g2.drawImage(originalTree.dragImage, AffineTransform.getTranslateInstance(lastDrawn.getX(), lastDrawn.getY()), null);			}			// see what the drop is over			TreePath cp = tree.getPathForLocation(e.getLocation().x, e.getLocation().y);			Library destLib = findLibrary(cp);			if (destLib == null) return;			// must be a cross-library drag			if (destLib == origCell.getLibrary()) return;			// highlight the destination			Rectangle path = tree.getPathBounds(cp);			if (path == null) return;			g2.setColor(Color.RED);			g2.drawRect(path.x, path.y, path.width-1, path.height-1);			if (lastDrawn == null) lastDrawn = path; else				Rectangle.union(lastDrawn, path, lastDrawn);			dragAction(e);		}		public void dropActionChanged(DropTargetDragEvent e)		{			e.acceptDrag(e.getDropAction());		}		public void dragExit(DropTargetEvent e)		{			eraseDragImage((DropTarget)e.getSource());		}		public void drop(DropTargetDropEvent dtde)		{			dtde.acceptDrop(DnDConstants.ACTION_LINK);			// erase former drawing			eraseDragImage((DropTarget)dtde.getSource());			// get the original cell that was dragged			Object obj = getDraggedObject(dtde.getCurrentDataFlavors());			if (obj != null)			{				Cell origCell = null;				if (obj instanceof Cell) origCell = (Cell)obj; else				if (obj instanceof Cell.CellGroup) origCell = ((Cell.CellGroup)obj).getCells().next();				if (origCell != null)				{					// see what the drop is over					DropTarget dt = (DropTarget)dtde.getSource();					ExplorerTree tree = (ExplorerTree)dt.getComponent();					TreePath cp = tree.getPathForLocation(dtde.getLocation().x, dtde.getLocation().y);					Library destLib = findLibrary(cp);					if (destLib != null)					{						// must be a cross-library copy						if (origCell.getLibrary() != destLib)						{							ExplorerTree originalTree = getOriginalTree(dtde.getCurrentDataFlavors());							if (originalTree != null)							{                                List<Cell> fromCells = new ArrayList<Cell>();                                fromCells.add(origCell);                                new CrossLibCopy.CrossLibraryCopyJob(fromCells, destLib, null, false,                                    obj instanceof Cell.CellGroup, originalTree.subCells, true);								dtde.dropComplete(true);								return;							}						}					}				}			}			dtde.dropComplete(false);		}		private Library findLibrary(TreePath cp)		{			if (cp == null) return null;			Object obj = cp.getLastPathComponent();			if (obj instanceof DefaultMutableTreeNode)			{				obj = ((DefaultMutableTreeNode)obj).getUserObject();				if (obj instanceof Library) return (Library)obj;				if (obj instanceof Cell.CellGroup) return ((Cell.CellGroup)obj).getCells().next().getLibrary();				if (obj instanceof Cell) return ((Cell)obj).getLibrary();			}			return null;		}		private Object getDraggedObject(DataFlavor [] flavors)		{			if (flavors.length > 0)			{				if (flavors[0] instanceof EditWindow.NodeProtoDataFlavor)				{					EditWindow.NodeProtoDataFlavor npdf = (EditWindow.NodeProtoDataFlavor)flavors[0];					Object obj = npdf.getFlavorObject();					return obj;				}			}			return null;		}		private ExplorerTree getOriginalTree(DataFlavor [] flavors)		{			if (flavors.length > 0)			{				if (flavors[0] instanceof EditWindow.NodeProtoDataFlavor)				{					EditWindow.NodeProtoDataFlavor npdf = (EditWindow.NodeProtoDataFlavor)flavors[0];					return npdf.getOriginalTree();				}			}			return null;		}		private void dragAction(DropTargetDragEvent e)		{			Object obj = getDraggedObject(e.getCurrentDataFlavors());			if (obj != null)				e.acceptDrag(e.getDropAction());		}		private void eraseDragImage(DropTarget dt)		{			if (lastDrawn == null) return;			ExplorerTree tree = (ExplorerTree)dt.getComponent();			tree.paintImmediately(lastDrawn);			lastDrawn = null;		}	}	// *********************************** DISPLAY ***********************************	private class MyRenderer extends DefaultTreeCellRenderer	{		private Font plainFont, boldFont;		public MyRenderer()		{			plainFont = new Font("arial", Font.PLAIN, 11);			boldFont = new Font("arial", Font.BOLD, 11);		}		public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel,			boolean expanded, boolean leaf, int row, boolean hasFocus)		{			super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);			// setIcon(icon)			//setToolTipText(value.toString());			setFont(plainFont);            if (!(value instanceof DefaultMutableTreeNode))                return this;            DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;			Object nodeInfo = node.getUserObject();			if (nodeInfo instanceof Library)			{				Library lib = (Library)nodeInfo;				if (iconLibraryNormal == null)					iconLibraryNormal = Resources.getResource(getClass(), "IconLibrary.gif");                if (iconLibrary == null)                    iconLibrary = iconLibraryNormal;				if (lib.isChanged()) setFont(boldFont);                if (CVS.isEnabled()) setForeground(CVSLibrary.getColor(lib));				setIcon(iconLibrary);			}			if (nodeInfo instanceof ExplorerTreeModel.CellAndCount)			{				ExplorerTreeModel.CellAndCount cc = (ExplorerTreeModel.CellAndCount)nodeInfo;				nodeInfo = cc.getCell();                if (cc.getCell().isModified()) setFont(boldFont);			}			if (nodeInfo instanceof Cell)			{				Cell cell = (Cell)nodeInfo;                if (cell.isModified()) setFont(boldFont);                if (CVS.isEnabled()) setForeground(CVSLibrary.getColor(cell));				IconGroup ig;				if (cell.isIcon()) ig = findIconGroup(View.ICON); else					if (cell.getView() == View.LAYOUT) ig = findIconGroup(View.LAYOUT); else						if (cell.isSchematic()) ig = findIconGroup(View.SCHEMATIC); else							if (cell.getView().isTextView()) ig = findIconGroup(View.DOC); else								ig = findIconGroup(View.UNKNOWN);				if (cell.getNewestVersion() != cell) setIcon(ig.old); else				{					switch (Project.getCellStatus(cell))					{						case Project.NOTMANAGED:         setIcon(ig.regular);     break;						case Project.CHECKEDIN:          setIcon(ig.available);   break;						case Project.CHECKEDOUTTOOTHERS: setIcon(ig.locked);      break;						case Project.CHECKEDOUTTOYOU:    setIcon(ig.unlocked);    break;					}				}			}			if (nodeInfo instanceof ExplorerTreeModel.MultiPageCell)			{				if (iconViewMultiPageSchematics == null)					iconViewMultiPageSchematics = Resources.getResource(getClass(), "IconViewMultiPageSchematics.gif");				setIcon(iconViewMultiPageSchematics);			}			if (nodeInfo instanceof Cell.CellGroup)			{                Cell.CellGroup cg = (Cell.CellGroup)nodeInfo;                boolean changed = false;                for (Iterator<Cell> it = cg.getCells(); it.hasNext();)                {                    Cell c = it.next();                    if (c.isModified())                    {                        changed = true;                        break;  // no need of checking the rest                    }                }                if (changed) setFont(boldFont);                if (CVS.isEnabled()) setForeground(CVSLibrary.getColor(cg));				if (iconGroup == null)					iconGroup = Resources.getResource(getClass(), "IconGroup.gif");				setIcon(iconGroup);			}			if (nodeInfo instanceof String)			{

⌨️ 快捷键说明

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