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

📄 viewchanges.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ViewChanges.java * * Copyright (c) 2004 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.user;import com.sun.electric.database.IdMapper;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.geometry.Dimension2D;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.ERectangle;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.geometry.Orientation;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.EDatabase;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.hierarchy.HierarchyEnumerator;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.hierarchy.Nodable;import com.sun.electric.database.hierarchy.View;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortOriginal;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.Name;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.DisplayedText;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.VarContext;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.Layer;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.SizeOffset;import com.sun.electric.technology.Technology;import com.sun.electric.technology.TransistorSize;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.technology.technologies.Schematics;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.generator.layout.GateLayoutGenerator;import com.sun.electric.tool.generator.layout.StdCellParams;import com.sun.electric.tool.generator.layout.Tech;import com.sun.electric.tool.generator.layout.TechType;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.TopLevel;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.io.Serializable;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import javax.swing.JOptionPane;/** * Class for view-related changes to the circuit. */public class ViewChanges{	// constructor, never used	ViewChanges() {}	/****************************** CREATE AND VIEW A CELL ******************************/	/**	 * Class to create a cell and display it in a new window.	 */	public static class CreateAndViewCell extends Job	{		private String cellName;		private Library lib;		private Cell c;		public CreateAndViewCell(String cellName, Library lib)		{			super("Create and View a Cell", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cellName = cellName;			this.lib = lib;			startJob();		}		public boolean doIt() throws JobException		{			c = Cell.makeInstance(lib, cellName);			fieldVariableChanged("c");			return true;		}		public void terminateOK()		{			WindowFrame.createEditWindow(c);		}	}	/****************************** CONVERT OLD-STYLE MULTI-PAGE SCHEMATICS ******************************/	public static void convertMultiPageViews()	{		List<Cell> multiPageCells = new ArrayList<Cell>();		for(Iterator<Library> lIt = Library.getLibraries(); lIt.hasNext(); )		{			Library lib = lIt.next();			if (lib.isHidden()) continue;			for(Iterator<Cell> cIt = lib.getCells(); cIt.hasNext(); )			{				Cell cell = cIt.next();				if (cell.getView().getFullName().startsWith("schematic-page-")) multiPageCells.add(cell);			}		}		if (multiPageCells.size() == 0)		{			System.out.println("No old-style multi-page schematics to convert");			return;		}		Collections.sort(multiPageCells/*, new TextUtils.CellsByName()*/);		new FixOldMultiPageSchematics(multiPageCells, User.getAlignmentToGrid());	}	/**	 * Class to update old-style multi-page schematics in a new thread.	 */	private static class FixOldMultiPageSchematics extends Job	{		private List<Cell> multiPageCells;		private Dimension2D alignment;		protected FixOldMultiPageSchematics(List<Cell> multiPageCells, Dimension2D alignment)		{			super("Repair old-style Multi-Page Schematics", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.multiPageCells = multiPageCells;			this.alignment = alignment;			startJob();		}		public boolean doIt() throws JobException		{			for(Cell cell : multiPageCells)			{				int pageNo = TextUtils.atoi(cell.getView().getFullName().substring(15));				String destCellName = cell.getName() + "{sch}";				Cell destCell = cell.getLibrary().findNodeProto(destCellName);				if (pageNo == 1 || destCell == null)				{					destCell = Cell.makeInstance(cell.getLibrary(), destCellName);					if (destCell == null)					{						System.out.println("Unable to create cell " + cell.getLibrary().getName() + ":" + destCellName);						return false;					}					destCell.setMultiPage(true);					destCell.newVar(User.FRAME_SIZE, "d");				}				// copy this page into the multipage cell				double dY = (pageNo - 1) * 1000;				List<Geometric> geomList = new ArrayList<Geometric>();				List<DisplayedText> textList = new ArrayList<DisplayedText>();				for(Iterator<NodeInst> nIt = cell.getNodes(); nIt.hasNext(); )					geomList.add(nIt.next());				for(Iterator<ArcInst> aIt = cell.getArcs(); aIt.hasNext(); )					geomList.add(aIt.next());				Clipboard.copyListToCell(destCell, geomList, textList, null, null, new Point2D.Double(0, dY),					true, true, alignment, null, null);				// also copy any variables on the cell				for(Iterator<Variable> vIt = cell.getVariables(); vIt.hasNext(); )				{					Variable var = vIt.next();					if (!var.isDisplay()) continue;					destCell.addVar(var.withOff(var.getXOff(), var.getYOff() + dY));				}				// delete the original				cell.kill();			}			return true;		}	}	/****************************** CHANGE A CELL'S VIEW ******************************/	public static void changeCellView(Cell cell, View newView)	{		// stop if already this way		if (cell.getView() == newView) return;		// database can't change icon/schematic views		if (cell.isIcon() || cell.isSchematic()) {			JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(),				"Cannot change view of icon/schematic",					"Change cell view failed", JOptionPane.ERROR_MESSAGE);			return;		}		if (newView == View.ICON || newView == View.SCHEMATIC) {			JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(),				"Cannot change " + cell.getView() + " to icon/schematic " + newView,					"Change cell view failed", JOptionPane.ERROR_MESSAGE);			return;		}		// warn if there is already a cell with that view		for(Iterator<Cell> it = cell.getLibrary().getCells(); it.hasNext(); )		{			Cell other = it.next();			if (other.getView() != newView) continue;			if (!other.getName().equalsIgnoreCase(cell.getName())) continue;			// there is another cell with this name and view: warn that it will become old			int response = JOptionPane.showConfirmDialog(TopLevel.getCurrentJFrame(),				"There is already a cell with that view.  Is it okay to make it an older version, and make this the newest version?");			if (response != JOptionPane.YES_OPTION) return;			break;		}		new ChangeCellView(cell, newView);	}	/**	 * Class to change a cell's view in a new thread.	 */	private static class ChangeCellView extends Job	{		private Cell cell;		private View newView;		private IdMapper idMapper;		protected ChangeCellView(Cell cell, View newView)		{			super("Change View of " + cell + " to " + newView.getFullName(),				User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cell = cell;			this.newView = newView;			startJob();		}		public boolean doIt() throws JobException		{			EDatabase database = cell.getDatabase();			idMapper = cell.setView(newView);			fieldVariableChanged("idMapper");			if (idMapper != null) {				cell = idMapper.get(cell.getId()).inDatabase(database);//				cell.setTechnology(null);			}			return true;		}		public void terminateOK()		{			User.fixStaleCellReferences(idMapper);			EditWindow.repaintAll();		}	}	/****************************** MAKE A SKELETON FOR A CELL ******************************/	public static void makeSkeletonViewCommand()	{		Cell curCell = WindowFrame.needCurCell();		if (curCell == null) return;		// cannot skeletonize text-only views		if (curCell.getView().isTextView())		{			JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(),				"Cannot skeletonize textual views: only layout",					"Skeleton creation failed", JOptionPane.ERROR_MESSAGE);			return;		}		// warn if skeletonizing nonlayout views		if (curCell.getView() != View.UNKNOWN && curCell.getView() != View.LAYOUT)			System.out.println("Warning: skeletonization only makes sense for layout cells, not " +				curCell.getView().getFullName());		new MakeSkeletonView(curCell);	}	private static class MakeSkeletonView extends Job	{		private Cell curCell;		private Cell skeletonCell;		protected MakeSkeletonView(Cell curCell)		{			super("Make Skeleton View", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.curCell = curCell;			startJob();		}		public boolean doIt() throws JobException		{			// create the new icon cell			String skeletonCellName = curCell.getName() + "{lay.sk}";			skeletonCell = Cell.makeInstance(curCell.getLibrary(), skeletonCellName);			if (skeletonCell == null)			{				throw new JobException("Cannot create Skeleton cell " + skeletonCellName);			}			boolean error = skeletonizeCell(curCell, skeletonCell);			if (error) skeletonCell = null;			fieldVariableChanged("skeletonCell");			if (error) return false;			return true;		}		public void terminateOK()		{			if (skeletonCell != null)			{				System.out.println("Cell " + skeletonCell.describe(true) + " created with a skeletal representation of " +					curCell);				WindowFrame.createEditWindow(skeletonCell);			}		}	}	/**	 * Method to copy the skeletonized version of one Cell into another.	 * @param curCell the original Cell to be skeletonized.	 * @param skeletonCell the destination Cell that gets the skeletonized representation.	 * @return true on error.	 */	public static boolean skeletonizeCell(Cell curCell, Cell skeletonCell)	{		// place all exports in the new cell		Map<Export,Export> newPortMap = new HashMap<Export,Export>();		for(Iterator<PortProto> it = curCell.getPorts(); it.hasNext(); )		{			Export pp = (Export)it.next();			// traverse to the bottom of the hierarchy for this Export			PortOriginal fp = new PortOriginal(pp.getOriginalPort());			PortInst bottomPort = fp.getBottomPort();			NodeInst bottomNi = bottomPort.getNodeInst();

⌨️ 快捷键说明

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