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

📄 paletteframe.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            }			return (PlaceNodeListener)newListener;		}        return null;	}	/**	 * Class to choose a location for new node placement.	 */	public static class PlaceNodeListener		implements MouseMotionListener, MouseListener, MouseWheelListener, KeyListener	{		private int oldx, oldy;//		private Point2D drawnLoc;//		private boolean doingMotionDrag;		private Object toDraw;		private EventListener oldListener;		private Cursor oldCursor;		private String textNode;		private boolean makePort;        private PlaceNodeEventListener palette;        /**         * Places a new Node.  You should be using the static method         * PaletteFrame.placeInstance() instead of this.         * @param toDraw         * @param oldListener         * @param oldCursor         * @param palette         */		private PlaceNodeListener(Object toDraw, EventListener oldListener, Cursor oldCursor,                                 PlaceNodeEventListener palette)		{			this.toDraw = toDraw;			this.oldListener = oldListener;			this.oldCursor = oldCursor;			this.textNode = null;			this.makePort = false;            this.palette = palette;		}		public void makePortWhenCreated(boolean m) { makePort = m; }		public void setParameter(Object toDraw) { this.toDraw = toDraw; }		public void setTextNode(String varName) { textNode = varName; }		public void mouseReleased(MouseEvent evt)		{			if (!(evt.getSource() instanceof EditWindow)) return;			EditWindow wnd = (EditWindow)evt.getSource();			oldx = evt.getX();			oldy = evt.getY();			Cell cell = wnd.getCell();			if (cell == null)			{				JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(),					"Cannot create node: this window has no cell in it");				return;			}			Point2D where = wnd.screenToDatabase(oldx, oldy);			EditWindow.gridAlign(where);			// schedule the node to be created			NodeInst ni = null;			NodeProto np = null;			if (toDraw instanceof NodeProto)			{				np = (NodeProto)toDraw;			} else if (toDraw instanceof NodeInst)			{				ni = (NodeInst)toDraw;				np = ni.getProto();			}			// if in a technology editor, validate the creation			if (cell.isInTechnologyLibrary())			{				if (Manipulate.invalidCreation(np, cell))				{					// invalid placement: restore the former listener to the edit windows		            finished(wnd, false);					return;				}			}			int defAngle = 0;			String descript = "Create ";			if (np instanceof Cell) descript += ((Cell)np).noLibDescribe(); else			{				descript += np.getName() + " Primitive";				defAngle = User.getNewNodeRotation();			}            wnd.getHighlighter().clear();            new PlaceNewNode(descript, np, ni, defAngle, where, cell, textNode, makePort);			// restore the former listener to the edit windows            finished(wnd, false);		}        public void finished(EditWindow wnd, boolean cancelled)        {            if (wnd != null) {                Highlighter highlighter = wnd.getHighlighter();                highlighter.clear();                highlighter.finished();            }            WindowFrame.setListener(oldListener);            TopLevel.setCurrentCursor(oldCursor);            if (palette != null)                palette.placeNodeFinished(cancelled);        }		public void mousePressed(MouseEvent evt) {}		public void mouseClicked(MouseEvent evt) {}		public void mouseEntered(MouseEvent evt) {}		public void mouseExited(MouseEvent evt) {}		public void mouseMoved(MouseEvent evt)		{			if (evt.getSource() instanceof EditWindow)			{				EditWindow wnd = (EditWindow)evt.getSource();				wnd.showDraggedBox(toDraw, evt.getX(), evt.getY());			}		}		public void mouseDragged(MouseEvent evt)		{			if (evt.getSource() instanceof EditWindow)			{				EditWindow wnd = (EditWindow)evt.getSource();				wnd.showDraggedBox(toDraw, evt.getX(), evt.getY());			}		}		public void mouseWheelMoved(MouseWheelEvent evt) {}		public void keyPressed(KeyEvent evt)		{			int chr = evt.getKeyCode();			if (chr == KeyEvent.VK_A || chr == KeyEvent.VK_ESCAPE)			{                // abort				finished(EditWindow.getCurrent(), true);			}		}		public void keyReleased(KeyEvent evt) {}		public void keyTyped(KeyEvent evt) {}	}	/**	 * Class that creates the node selected from the component menu.	 */	public static class PlaceNewNode extends Job	{		private NodeProto np;		private Variable techEditVar;		private int techBits = 0;        private Orientation defOrient = Orientation.IDENT;        private double [] angles = null;		private EPoint where;		private Cell cell;		private String varName;		private boolean export;		private Variable.Key varKeyToHighlight;		private ElectricObject objToHighlight;		public PlaceNewNode(String description, NodeProto np, NodeInst ni, int defAngle, Point2D where, Cell cell, String varName, boolean export)		{			super(description, User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.np = np;			// get default creation information            if (ni != null)            {                defOrient = ni.getOrient();				techBits = ni.getTechSpecific();                angles = ni.getArcDegrees();                techEditVar = ni.getVar(Info.OPTION_KEY);            } else if (np instanceof PrimitiveNode)			{                defOrient = Orientation.fromJava(defAngle, defAngle >= 3600, false);			}			this.where = EPoint.snap(where);			this.cell = cell;			this.varName = varName;			this.export = export;			startJob();		}		public boolean doIt() throws JobException		{			double width = np.getDefWidth();			double height = np.getDefHeight();			if (varName != null) width = height = 0;			NodeInst newNi = NodeInst.makeInstance(np, where, width, height, cell, defOrient, null, techBits);			if (newNi == null) return false;			if (np == Generic.tech().cellCenterNode || np == Generic.tech().essentialBoundsNode ||                (np instanceof PrimitiveNode && ((PrimitiveNode)np).isPureWellNode()))					newNi.setHardSelect();			if (varName != null)			{				// text object: add initial text				varKeyToHighlight = Variable.newKey(varName);				newNi.newVar(varKeyToHighlight, "text", TextDescriptor.getAnnotationTextDescriptor());				objToHighlight = newNi;				fieldVariableChanged("objToHighlight");				fieldVariableChanged("varKeyToHighlight");			} else			{				if (np == Schematics.tech().resistorNode)				{					newNi.newDisplayVar(Schematics.SCHEM_RESISTANCE, "100");                    // Adding two extra variables: length and width                    if (newNi.getFunction().isPolyOrWellResistor())                    {                        // They will be visible                        TextDescriptor td = TextDescriptor.getNodeTextDescriptor();						if (td.getSize().isAbsolute())							td = td.withAbsSize((int)(td.getSize().getSize() - 1));						else							td = td.withRelSize(td.getSize().getSize() - 0.5);						td = td.withOff(1.5, 0);						newNi.newVar(Schematics.ATTR_WIDTH, "2", td);						td = TextDescriptor.getNodeTextDescriptor();						if (td.getSize().isAbsolute())							td = td.withAbsSize((int)(td.getSize().getSize() - 2));						else							td = td.withRelSize(td.getSize().getSize() - 0.7);						td = td.withOff(-1.5, 0);						newNi.newVar(Schematics.ATTR_LENGTH, "2", td);                    }				} else if (np == Schematics.tech().capacitorNode)				{					newNi.newDisplayVar(Schematics.SCHEM_CAPACITANCE, "100M");				} else if (np == Schematics.tech().inductorNode)				{					newNi.newDisplayVar(Schematics.SCHEM_INDUCTANCE, "100");				} else if (np == Schematics.tech().diodeNode)				{					newNi.newDisplayVar(Schematics.SCHEM_DIODE, "10");				} else if (np == Schematics.tech().transistorNode || np == Schematics.tech().transistor4Node)				{					if (newNi.getFunction().isFET())					{						TextDescriptor td = TextDescriptor.getNodeTextDescriptor().withOff(0.5, -1);						newNi.newVar(Schematics.ATTR_WIDTH, "2", td);						td = TextDescriptor.getNodeTextDescriptor();						if (td.getSize().isAbsolute())							td = td.withAbsSize((int)(td.getSize().getSize() - 2));						else							td = td.withRelSize(td.getSize().getSize() - 0.5);						td = td.withOff(-0.5, -1);						newNi.newVar(Schematics.ATTR_LENGTH, "2", td);					} else					{						newNi.newDisplayVar(Schematics.ATTR_AREA, "10");					}				} else if (np == Artwork.tech().circleNode)				{					if (angles != null)					{						newNi.setArcDegrees(angles[0], angles[1]);					}				}				objToHighlight = newNi;				fieldVariableChanged("objToHighlight");			}			return true;		}        public void terminateOK()        {            EditWindow wnd = EditWindow.getCurrent();            Highlighter highlighter = wnd.getHighlighter();            if (varKeyToHighlight != null)        	{        		highlighter.addText(objToHighlight, cell, varKeyToHighlight);        	} else        	{				highlighter.addElectricObject(objToHighlight, cell);        	}			highlighter.finished();            // regaining focus in editing space            wnd.requestFocus();            			// for technology edit cells, mark the new geometry specially			if (cell.isInTechnologyLibrary())			{				Manipulate.completeNodeCreation((NodeInst)objToHighlight, techEditVar);			}			if (export)			{				new NewExport(TopLevel.getCurrentJFrame());			}        }	}}

⌨️ 快捷键说明

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