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

📄 clipboard.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		// put the text in the clipboard        TextUtils.setTextOnClipboard(selected);	}	/****************************** CHANGE JOBS ******************************/	private static class CopyObjects extends Job	{		private List<Geometric> highlightedGeoms;		private List<DisplayedText> highlightedText;		private Dimension2D alignment;		private AffineTransform inPlace;		private Orientation inPlaceOrient;		protected CopyObjects(List<Geometric> highlightedGeoms, List<DisplayedText> highlightedText,			Dimension2D alignment, AffineTransform inPlace, Orientation inPlaceOrient)		{			super("Copy", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.highlightedGeoms = highlightedGeoms;			this.highlightedText = highlightedText;			this.alignment = alignment;			this.inPlace = inPlace;			this.inPlaceOrient = inPlaceOrient;			startJob();		}		public boolean doIt() throws JobException		{			// remove contents of clipboard			clear();			// copy objects to clipboard			copyListToClipboard(highlightedGeoms, highlightedText, alignment, inPlace, inPlaceOrient);			return true;		}	}	private static class CutObjects extends Job	{		private Cell cell;		private List<Geometric> geomList;		private List<DisplayedText> textList;		private Dimension2D alignment;		private boolean reconstructArcsAndExports;		private AffineTransform inPlace;		private Orientation inPlaceOrient;		private List<Geometric> thingsToHighlight;		protected CutObjects(Cell cell, List<Geometric> geomList, List<DisplayedText> textList, Dimension2D alignment,			boolean reconstructArcsAndExports, AffineTransform inPlace, Orientation inPlaceOrient)		{			super("Cut", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cell = cell;			this.geomList = geomList;			this.textList = textList;			this.alignment = alignment;			this.reconstructArcsAndExports = reconstructArcsAndExports;			this.inPlace = inPlace;			this.inPlaceOrient = inPlaceOrient;			startJob();		}		public boolean doIt() throws JobException		{			// remove contents of clipboard			clear();			// make sure deletion is allowed			if (CircuitChangeJobs.cantEdit(cell, null, true, false, true) != 0) return false;			for(Geometric geom : geomList)			{				if (geom instanceof NodeInst)				{					int errorCode = CircuitChangeJobs.cantEdit(cell, (NodeInst)geom, true, false, true);					if (errorCode < 0) return false;					if (errorCode > 0) continue;				}			}			// copy objects to clipboard			copyListToClipboard(geomList, textList,	alignment, inPlace, inPlaceOrient);			// and delete the original objects			Set<ElectricObject> stuffToHighlight = new HashSet<ElectricObject>();			CircuitChangeJobs.eraseObjectsInList(cell, geomList, reconstructArcsAndExports, stuffToHighlight);			thingsToHighlight = new ArrayList<Geometric>();			for(ElectricObject eObj : stuffToHighlight)			{				if (eObj instanceof ArcInst)				{					ArcInst ai = (ArcInst)eObj;					thingsToHighlight.add(ai);				} else if (eObj instanceof Export)				{					Export e = (Export)eObj;					thingsToHighlight.add(e.getOriginalPort().getNodeInst());				}			}			fieldVariableChanged("thingsToHighlight");			// kill exports and variables on cells			for(DisplayedText dt : textList)			{				// deleting variable on object				Variable.Key key = dt.getVariableKey();				ElectricObject eobj = dt.getElectricObject();				if (key == NodeInst.NODE_NAME)				{					// deleting the name of a node					NodeInst ni = (NodeInst)eobj;					ni.setName(null);					ni.move(0, 0);				} else if (key == ArcInst.ARC_NAME)				{					// deleting the name of an arc					ArcInst ai = (ArcInst)eobj;					ai.setName(null);					ai.modify(0, 0, 0, 0);				} else if (key == Export.EXPORT_NAME)				{					// deleting the name of an export					Export pp = (Export)eobj;					pp.kill();				} else				{					// deleting a variable					if (eobj.isParam(key)) {                        if (eobj instanceof Cell)    						((Cell)eobj).getCellGroup().delParam((Variable.AttrKey)key);                        else if (eobj instanceof NodeInst)                            ((NodeInst)eobj).delParameter(key);                    } else {						eobj.delVar(key);                    }				}			}			return true;		}		public void terminateOK()		{			// remove highlighting, show only reconstructed objects			UserInterface ui = Job.getUserInterface();			EditWindow_ wnd = ui.getCurrentEditWindow_();			if (wnd != null)			{				wnd.clearHighlighting();				if (thingsToHighlight != null)				{					for(Geometric geom: thingsToHighlight)						wnd.addElectricObject(geom, cell);				}				wnd.finishedHighlighting();			}		}	}	private static class DuplicateObjects extends Job	{		private Cell cell;		private List<Geometric> geomList, newGeomList;		private List<DisplayedText> textList, newTextList;		private Dimension2D alignment;		private NodeInst lastCreatedNode;		protected DuplicateObjects(Cell cell, List<Geometric> geomList, List<DisplayedText> textList, Dimension2D alignment)		{			super("Duplicate", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cell = cell;			this.geomList = geomList;			this.textList = textList;			this.alignment = alignment;			startJob();		}		public boolean doIt() throws JobException		{			// copy objects to clipboard			newGeomList = new ArrayList<Geometric>();			newTextList = new ArrayList<DisplayedText>();			lastCreatedNode = copyListToCell(cell, geomList, textList, newGeomList, newTextList,				new Point2D.Double(lastDupX, lastDupY), User.isDupCopiesExports(), User.isArcsAutoIncremented(),				alignment, null, null);			fieldVariableChanged("newGeomList");			fieldVariableChanged("newTextList");			fieldVariableChanged("lastCreatedNode");			return true;		}		public void terminateOK()		{			// remember the last node created			lastDup = lastCreatedNode;			// highlight the copy			showCopiedObjects(newGeomList, newTextList);		}	}	private static class PasteArcToArc extends Job	{		private ArcInst src, dst, newArc;		protected PasteArcToArc(ArcInst dst, ArcInst src)		{			super("Paste Arc to Arc", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.src = src;			this.dst = dst;			startJob();		}		public boolean doIt() throws JobException		{			// make sure pasting is allowed			if (CircuitChangeJobs.cantEdit(dst.getParent(), null, true, false, true) != 0) return false;			newArc = pasteArcToArc(dst, src);			if (newArc == null) System.out.println("Nothing was pasted"); else				fieldVariableChanged("newArc");			return true;		}		public void terminateOK()		{			if (newArc != null)			{				EditWindow wnd = EditWindow.getCurrent();				if (wnd != null)				{					Highlighter highlighter = wnd.getHighlighter();					if (highlighter != null)					{						highlighter.clear();						highlighter.addElectricObject(newArc, newArc.getParent());						highlighter.finished();					}				}			}		}	}	private static class PasteNodeToNode extends Job	{		private NodeInst src, dst, newNode;		protected PasteNodeToNode(NodeInst dst, NodeInst src)		{			super("Paste Node to Node", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.src = src;			this.dst = dst;			startJob();		}		public boolean doIt() throws JobException		{			// make sure pasting is allowed			if (CircuitChangeJobs.cantEdit(dst.getParent(), null, true, false, true) != 0) return false;			newNode = pasteNodeToNode(dst, src);			if (newNode == null) System.out.println("Nothing was pasted"); else				fieldVariableChanged("newNode");			return true;		}		public void terminateOK()		{			if (newNode != null)			{				EditWindow wnd = EditWindow.getCurrent();				if (wnd != null)				{					Highlighter highlighter = wnd.getHighlighter();					if (highlighter != null)					{						highlighter.clear();						highlighter.addElectricObject(newNode, newNode.getParent());						highlighter.finished();					}				}			}		}	}	private static class PasteObjects extends Job	{		private Cell cell;		private List<Geometric> geomList, newGeomList;		private List<DisplayedText> textList, newTextList;		private double dX, dY;		private Dimension2D alignment;		private boolean copyExports, uniqueArcs;		private NodeInst lastCreatedNode;		private AffineTransform inPlace;		private Orientation inPlaceOrient;		protected PasteObjects(Cell cell, List<Geometric> geomList, List<DisplayedText> textList,			double dX, double dY, Dimension2D alignment, boolean copyExports, boolean uniqueArcs,			AffineTransform inPlace, Orientation inPlaceOrient)		{			super("Paste", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cell = cell;			this.geomList = geomList;			this.textList = textList;			this.dX = dX;			this.dY = dY;			this.alignment = alignment;			this.copyExports = copyExports;			this.uniqueArcs = uniqueArcs;			this.inPlace = inPlace;			this.inPlaceOrient = inPlaceOrient;			startJob();		}		public boolean doIt() throws JobException		{			// make sure pasting is allowed			if (CircuitChangeJobs.cantEdit(cell, null, true, false, true) != 0) return false;			// paste them into the current cell			newGeomList = new ArrayList<Geometric>();			newTextList = new ArrayList<DisplayedText>();			lastCreatedNode = copyListToCell(cell, geomList, textList, newGeomList, newTextList,				new Point2D.Double(dX, dY), copyExports, uniqueArcs, alignment, inPlace, inPlaceOrient);			fieldVariableChanged("newGeomList");			fieldVariableChanged("newTextList");			fieldVariableChanged("lastCreatedNode");			return true;		}		public void terminateOK()		{			// remember the last node created			lastDup = lastCreatedNode;			// highlight the copy			showCopiedObjects(newGeomList, newTextList);		}	}    private static class PasteSpecialText extends Job	{        private List<DisplayedText> textList;        private String newText;        private Cell cell;        protected PasteSpecialText(List<DisplayedText> tList, String newT, Cell c)        {            super("Paste Text", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.textList = tList;            this.newText = newT;            this.cell = c;            startJob();        }		public boolean doIt() throws JobException		{			// make sure pasting is allowed			if (CircuitChangeJobs.cantEdit(cell, null, true, false, true) != 0) return false;			// paste them into the current cell            for (DisplayedText obj : textList)            {                Variable.Key key = obj.getVariableKey();                ElectricObject eObj = obj.getElectricObject();                if (key == ArcInst.ARC_NAME)                {                    ((ArcInst)eObj).setName(newText);                }                else if (key == NodeInst.NODE_NAME || key == NodeInst.NODE_PROTO)                {                    ((NodeInst)eObj).setName(newText);                }                else if (key == Export.EXPORT_NAME)                {                    Export ex = (Export)((Export)eObj);                    ex.rename(newText);                }            }			return true;		}	}    /****************************** CHANGE JOB SUPPORT ******************************/	/**	 * Method to clear the clipboard.	 */	private static void init()	{		if (clipLib == null)		{			clipLib = Library.newInstance("Clipboard!!", null);			clipLib.setHidden();		}		if (clipCell == null)		{			clipCell = Cell.newInstance(clipLib, "Clipboard!!");		}	}	/**	 * Method to clear the contents of the clipboard.	 */	public static void clear()	{		init();		// delete all arcs in the clipboard		List<ArcInst> arcsToDelete = new ArrayList<ArcInst>();		for(Iterator<ArcInst> it = clipCell.getArcs(); it.hasNext(); )			arcsToDelete.add(it.next());		for(ArcInst ai : arcsToDelete)		{			ai.kill();		}

⌨️ 快捷键说明

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