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

📄 techpalette.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, "SIM_spice_declaration"));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Verilog Code");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, "VERILOG_code"));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Verilog Declaration");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, "VERILOG_declaration"));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Verilog Parameter");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, "VERILOG_parameter"));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Verilog External Code");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, "VERILOG_external_code"));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Simulation Probe");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().simProbeNode));				specialMenu.add(menuItem);				menuItem = new JMenuItem("DRC Exclusion");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().drcNode));				specialMenu.add(menuItem);				menuItem = new JMenuItem("AFG Exclusion");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().afgNode));				specialMenu.add(menuItem);				specialMenu.addSeparator();				menuItem = new JMenuItem("Invisible Pin");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().invisiblePinNode));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Universal Pin");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().universalPinNode));				specialMenu.add(menuItem);				menuItem = new JMenuItem("Unrouted Pin");				menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, Generic.tech().unroutedPinNode));				specialMenu.add(menuItem);				specialMenu.show(panel, e.getX(), e.getY());			} else if (msg.equals(Technology.SPECIALMENUPURE))			{//				JPopupMenu pureMenu = new JPopupMenu("pure");//				for(PrimitiveNode np : Technology.getCurrent().getNodesSortedByName())//				{//					if (np.isNotUsed()) continue;//					if (np.getFunction() != PrimitiveNode.Function.NODE) continue;//					Technology.NodeLayer layer = np.getLayers()[0];//					if (layer.getLayer().getFunction().isContact()) continue;//					menuItem = new JMenuItem(np.describe(false));//					menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, np));//					pureMenu.add(menuItem);//				}//				pureMenu.show(panel, e.getX(), e.getY());				new PurePopup(panel, e.getX(), e.getY());			} if (msg.equals(Technology.SPECIALMENUSPICE))			{				JPopupMenu cellMenu = new JPopupMenu("Spice");				String currentSpiceLib = Simulation.getSpicePartsLibrary();				Library spiceLib = Library.findLibrary(currentSpiceLib);				if (spiceLib == null)				{					// must read the Spice library from disk					URL fileURL = LibFile.getLibFile(currentSpiceLib + ".jelib");					new TechPalette.ReadSpiceLibrary(fileURL, cellMenu, panel, e.getX(), e.getY());				} else				{					ReadSpiceLibrary.loadSpiceCells(spiceLib, panel, cellMenu);					cellMenu.show(panel, e.getX(), e.getY());				}			} if (msg.equals(Technology.SPECIALMENUEXPORT))			{				JPopupMenu specialMenu = new JPopupMenu("Export");				menuItem = new JMenuItem("Wire");				menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { makeExport("wire"); } });				specialMenu.add(menuItem);				menuItem = new JMenuItem("Bus");				menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { makeExport("bus"); } });				specialMenu.add(menuItem);				menuItem = new JMenuItem("Universal");				menuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { makeExport("universal"); } });				specialMenu.add(menuItem);				specialMenu.show(panel, e.getX(), e.getY());			} if (msg.equals(Technology.SPECIALMENUTEXT))			{				// place a piece of text				PaletteFrame.placeInstance("ART_message", panel, false);			} if (msg.equals(Technology.SPECIALMENUHIGH))			{				// place a technology-edit highlight box				NodeInst ni = NodeInst.makeDummyInstance(Artwork.tech().boxNode);				ni.newVar(Info.OPTION_KEY, new Integer(Info.HIGHLIGHTOBJ));				PaletteFrame.placeInstance(ni, panel, false);			} if (msg.equals(Technology.SPECIALMENUPORT))			{				// place a technology-edit port				PaletteFrame.placeInstance(Generic.tech().portNode, panel, false);			}		}		repaint();	}    /**     * Class to display a list of pure-layer nodes.     * Created when the "Pure" entry is selected in the component menu.     * This class must be used (instead of a normal JPopupMenu) because the list     * of pure-layer nodes may be very large, and JPopupMenu doesn't show a scroll-bar     * or otherwise shorten the list.     */    private static class PurePopup extends EDialog    {    	private JList pureList;		private TechPalette panel;		private List<PrimitiveNode> popupPures;       	private PurePopup(TechPalette panel, int x, int y)        {    		super(TopLevel.getCurrentJFrame(), false);    		this.panel = panel;    		Point los = TopLevel.getCurrentJFrame().getLocationOnScreen();    		setLocation(los.x+x, los.y+y);    		setUndecorated(true);            getContentPane().setLayout(new GridBagLayout());            DefaultListModel pureModel = new DefaultListModel();            pureList = new JList(pureModel);            pureList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);            JScrollPane pureScrollPane = new JScrollPane();            pureScrollPane.setMinimumSize(new Dimension(200, 200));            pureScrollPane.setPreferredSize(new Dimension(200, 200));            pureScrollPane.setViewportView(pureList);            JPanel purePanel = new JPanel();            purePanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));            purePanel.setLayout(new GridBagLayout());            GridBagConstraints gbc = new GridBagConstraints();            gbc.gridx = 0;   gbc.gridy = 0;            purePanel.add(pureScrollPane, gbc);            gbc = new GridBagConstraints();            gbc.gridx = 0;   gbc.gridy = 0;            getContentPane().add(purePanel, gbc);            pureList.addMouseListener(new MouseAdapter()    		{    			public void mouseClicked(MouseEvent evt) { entryClicked(); }    		});  			pureList.addKeyListener(new KeyAdapter()			{				public void keyReleased(KeyEvent ke)				{					if (ke.getKeyCode() == KeyEvent.VK_ENTER)					{						entryClicked();						ke.consume();					} 				}			});			addWindowFocusListener(new DialogFocusHandler());            popupPures = new ArrayList<PrimitiveNode>();			for(PrimitiveNode np : Technology.getCurrent().getNodesSortedByName())			{				if (np.isNotUsed()) continue;				if (np.getFunction() != PrimitiveNode.Function.NODE) continue;				Technology.NodeLayer layer = np.getLayers()[0];				Layer.Function lf = layer.getLayer().getFunction();				if (lf.isContact()) continue;				popupPures.add(np);			}			Collections.sort(popupPures, new LayersByImportance());			for(PrimitiveNode np : popupPures)				pureModel.addElement(np.describe(false));			pureList.setSelectedIndex(0);            pack();            setVisible(true);        }    	/**    	 * Class to handle clicks outside of the window (which close it)    	 */		private class DialogFocusHandler implements WindowFocusListener		{			public void windowGainedFocus(WindowEvent e) {}			public void windowLostFocus(WindowEvent e) { setVisible(false); }		}		/**		 * Comparator class for sorting pure-layer-nodes by their importance.		 */		public static class LayersByImportance implements Comparator<PrimitiveNode>		{			/**			 * Method to sort pure-layer-nodes by their importance.			 */			public int compare(PrimitiveNode np1, PrimitiveNode np2)			{				Technology.NodeLayer layer1 = np1.getLayers()[0];				Technology.NodeLayer layer2 = np2.getLayers()[0];				int imp1 = getCode(layer1.getLayer());				int imp2 = getCode(layer2.getLayer());				if (imp1 == 3 && imp2 == 3)				{					String en1 = Layer.Function.getExtraName(layer1.getLayer().getFunctionExtras());					String en2 = Layer.Function.getExtraName(layer2.getLayer().getFunctionExtras());					return en1.compareTo(en2);				}				return imp1 - imp2;			}			private int getCode(Layer layer)			{				Layer.Function lf = layer.getFunction();				if (lf.isWell()) return 1;				if (lf.isImplant())				{					if (layer.getFunctionExtras() == 0) return 2;					return 3;				}				if (lf == Layer.Function.ART) return 4;				return 5;			}		}		/**    	 * Method called when the ESCAPE key is pressed.    	 */    	protected void escapePressed()    	{            setVisible(false);    	}    	/**    	 * Method to handle clicks on an entry in the pure-layer-node list.    	 */    	private void entryClicked()    	{            String selected = (String)pureList.getSelectedValue();			for(int i=0; i<popupPures.size(); i++)			{				PrimitiveNode np = popupPures.get(i);				if (np.describe(false).equals(selected))					PaletteFrame.placeInstance(np, panel, false);			}            setVisible(false);    	}    }//    private static class PurePopupOld//	{//		private List<PrimitiveNode> popupPures;//		private BasicComboPopup myPopup;//		private JComboBox comboBox;//		private TechPalette panel;////		PurePopupOld(TechPalette panel, int x, int y)//		{//			this.panel = panel;//			popupPures = new ArrayList<PrimitiveNode>();//			for(PrimitiveNode np : Technology.getCurrent().getNodesSortedByName())//			{//				if (np.isNotUsed()) continue;//				if (np.getFunction() != PrimitiveNode.Function.NODE) continue;//				Technology.NodeLayer layer = np.getLayers()[0];//				if (layer.getLayer().getFunction().isContact()) continue;//				popupPures.add(np);//			}//			String[] popupStringArray = new String[popupPures.size()];//			for(int i=0; i<popupPures.size(); i++) popupStringArray[i] = popupPures.get(i).describe(false);//			comboBox = new JComboBox(popupStringArray);//			myPopup = new BasicComboPopup(comboBox);//			comboBox.addActionListener(new ActionListener()//			{//				public void actionPerformed(ActionEvent e) { clickedOnEntry(); }//			});//			myPopup.show(panel, x, y);//		}////		private void clickedOnEntry()//		{//			for(int i=0; i<popupPures.size(); i++)//			{//				PrimitiveNode np = popupPures.get(i);//				if (np.describe(false).equals(comboBox.getSelectedItem()))//					PaletteFrame.placeInstance(np, panel, false);//			}//			myPopup.hide();//		}//	}	private void makeExport(String type)	{		if (type.equals("wire")) PaletteFrame.placeInstance(Schematics.tech().wirePinNode, this, true); else		if (type.equals("bus")) PaletteFrame.placeInstance(Schematics.tech().busPinNode, this, true); else		if (type.equals("universal")) PaletteFrame.placeInstance(Generic.tech().invisiblePinNode, this, true);	}	public void makeLayoutTextCommand()	{		LayoutText dialog = new LayoutText(TopLevel.getCurrentJFrame());		if (!Job.BATCHMODE) dialog.setVisible(true);	}	public void placeNodeStarted(Object nodeToBePlaced) {		highlightedNode = nodeToBePlaced;	}	public void placeNodeFinished(boolean cancelled) {		highlightedNode = null;		repaint();	}	// ************************************************ DRAG-AND-DROP CODE ************************************************	public void dragGestureRecognized(DragGestureEvent e)	{		Object obj = getObjectUnderCursor(e.getDragOrigin().x, e.getDragOrigin().y);		// make a Transferable Object		EditWindow.NodeProtoTransferable transferable = new EditWindow.NodeProtoTransferable(obj, null);		// begin the drag		dragSource.startDrag(e, DragSource.DefaultLinkDrop, 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 to read a Spice library in a new thread.	 */	private static class ReadSpiceLibrary extends Job	{		private URL fileURL;		private transient JPopupMenu cellMenu;		private transient TechPalette panel;		private transient int x, y;        private Library lib;    	protected ReadSpiceLibrary(URL fileURL, JPopupMenu cellMenu, TechPalette panel, int x, int y)        {            super("Read Spice Library", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.fileURL = fileURL;            this.cellMenu = cellMenu;            this.panel = panel;            this.x = x;            this.y = y;            startJob();        }        public boolean doIt() throws JobException        {            lib = LibraryFiles.readLibrary(fileURL, null, FileType.JELIB, false);//            Undo.noUndoAllowed();            if (lib == null) return false;			fieldVariableChanged("lib");            return true;        }        public void terminateOK()        {            if (lib == null) return;            loadSpiceCells(lib, panel, cellMenu);            cellMenu.show(panel, x, y);        }        public static void loadSpiceCells(Library lib, TechPalette panel, JPopupMenu cellMenu)        {            for(Iterator<Cell> it = lib.getCells(); it.hasNext(); )            {                Cell cell = it.next();                // only access to icons of those cells                if (!cell.isIcon()) continue;                JMenuItem menuItem = new JMenuItem(cell.getName());                menuItem.addActionListener(new TechPalette.PlacePopupListener(panel, cell));                cellMenu.add(menuItem);            }        }    }    static class PlacePopupListener implements ActionListener    {        TechPalette panel;        Object obj;        PlacePopupListener(TechPalette panel, Object obj) { super();  this.panel = panel;   this.obj = obj; }        public void actionPerformed(ActionEvent evt)        {            PaletteFrame.placeInstance(obj, panel, false);        }    }    static class PlacePopupListListener extends PlacePopupListener        implements ActionListener    {

⌨️ 快捷键说明

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