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

📄 viewchanges.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
			PortProto bottomPp = bottomPort.getPortProto();			AffineTransform subRot = fp.getTransformToTop();			Orientation newOrient = fp.getOrientToTop();			// create this node			Point2D center = new Point2D.Double(bottomNi.getAnchorCenterX(), bottomNi.getAnchorCenterY());			subRot.transform(center, center);			NodeInst newNi = NodeInst.makeInstance(bottomNi.getProto(), center, bottomNi.getXSize(), bottomNi.getYSize(),				skeletonCell, newOrient, null, 0);			if (newNi == null)			{				System.out.println("Cannot create node in this cell");				return true;			}			// export the port from the node			PortInst newPi = newNi.findPortInstFromProto(bottomPp);			Export npp = Export.newInstance(skeletonCell, newPi, pp.getName(), pp.getCharacteristic());			if (npp == null)			{				System.out.println("Could not create port " + pp.getName());				return true;			}			npp.copyTextDescriptorFrom(pp, Export.EXPORT_NAME);			npp.copyVarsFrom(pp);			newPortMap.put(pp, npp);		}		// connect electrically-equivalent ports		Netlist netlist = curCell.acquireUserNetlist();		if (netlist == null)		{			System.out.println("Sorry, a deadlock aborted skeletonization (network information unavailable).  Please try again");			return true;		}		// map exports in the original cell to networks		Map<Export,Network> netMap = new HashMap<Export,Network>();		for(Iterator<Export> it = curCell.getExports(); it.hasNext(); )		{			Export e = it.next();			Network net = netlist.getNetwork(e, 0);			netMap.put(e, net);		}		int numPorts = curCell.getNumPorts();		for(int i=0; i<numPorts; i++)		{			Export pp = curCell.getPort(i);			Network net = netMap.get(pp);			for(int j=i+1; j<numPorts; j++)			{				Export oPp = curCell.getPort(j);				Network oNet = netMap.get(oPp);				if (net != oNet) continue;				Export newPp = newPortMap.get(pp);				Export newOPp = newPortMap.get(oPp);				if (newPp == null || newOPp == null) continue;				ArcProto univ = Generic.tech().universal_arc;				ArcInst newAI = ArcInst.makeInstance(univ, newPp.getOriginalPort(), newOPp.getOriginalPort());				if (newAI == null)				{					System.out.println("Could not create connecting arc");					return true;				}				newAI.setFixedAngle(false);				break;			}		}		// copy the essential-bounds nodes if they exist		for(Iterator<NodeInst> it = curCell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			NodeProto np = ni.getProto();			if (np != Generic.tech().essentialBoundsNode) continue;			NodeInst newNi = NodeInst.makeInstance(np, ni.getAnchorCenter(),				ni.getXSize(), ni.getYSize(), skeletonCell, ni.getOrient(), null, 0);			if (newNi == null)			{				System.out.println("Cannot create node in this cell");				return true;			}			newNi.setHardSelect();			if (np == Generic.tech().cellCenterNode) newNi.setVisInside();		}		// place an outline around the skeleton		Rectangle2D bounds = curCell.getBounds();		NodeInst boundNi = NodeInst.makeInstance(Generic.tech().invisiblePinNode,			new Point2D.Double(bounds.getCenterX(), bounds.getCenterY()), bounds.getWidth(), bounds.getHeight(), skeletonCell);		if (boundNi == null)		{			System.out.println("Cannot create boundary node");			return true;		}		boundNi.setHardSelect();		return false;	}	/****************************** MAKE AN ICON FOR A CELL ******************************/	public static void makeIconViewCommand()	{		Cell curCell = WindowFrame.needCurCell();		if (curCell == null) return;		if (!curCell.isSchematic())		{			JOptionPane.showMessageDialog(TopLevel.getCurrentJFrame(),				"The current cell must be a schematic in order to generate an icon",					"Icon creation failed", JOptionPane.ERROR_MESSAGE);			return;		}		// see if the icon already exists and issue a warning if so		Cell iconCell = curCell.iconView();		if (iconCell != null)		{			int response = JOptionPane.showConfirmDialog(TopLevel.getCurrentJFrame(),				"Warning: Icon " + iconCell.describe(true) + " already exists.  Create a new version?");			if (response != JOptionPane.YES_OPTION) return;		}		makeIconViewNoGUI(curCell, false, false);	}	public static void makeIconViewNoGUI(Cell curCell, boolean doItNow, boolean fixedValues)	{		if (!fixedValues)		{			IconParameters ip = new IconParameters();			ip.initFromUserDefaults();			new MakeIconView(curCell, User.getAlignmentToGrid(), User.getIconGenInstanceLocation(), ip, doItNow);		}		else		{			// in case of debugging mode, better to draw the body and leads			IconParameters ip = new IconParameters();			new MakeIconView(curCell, new Dimension2D.Double(0.05, 0.05), 0, ip, doItNow);		}	}	private static class MakeIconView extends Job	{		private Cell curCell;		private Dimension2D alignment;		private int exampleLocation;		private IconParameters ip;		private NodeInst iconNode;		private boolean doItNow;		// get icon style controls		private MakeIconView(Cell cell, Dimension2D alignment, int exampleLocation, IconParameters ip, boolean doItNow)		{			super("Make Icon View", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.curCell = cell;			this.alignment = alignment;			this.exampleLocation = exampleLocation;			this.ip = ip;			this.doItNow = doItNow;			if (doItNow)			{			   try {doIt();} catch (Exception e) {e.printStackTrace();}			}			else				startJob();		}		public boolean doIt() throws JobException		{			Cell iconCell = ip.makeIconForCell(curCell);			if (iconCell == null) return false;			// Check user preference to see if an instance should be made in the original schematic			if (exampleLocation != 4)			{				// place an icon in the schematic				Point2D iconPos = new Point2D.Double(0,0);				Rectangle2D cellBounds = curCell.getBounds();				Rectangle2D iconBounds = iconCell.getBounds();				double halfWidth = iconBounds.getWidth() / 2;				double halfHeight = iconBounds.getHeight() / 2;				switch (exampleLocation)				{					case 0:		// upper-right						iconPos.setLocation(cellBounds.getMaxX()+halfWidth, cellBounds.getMaxY()+halfHeight);						break;					case 1:		// upper-left						iconPos.setLocation(cellBounds.getMinX()-halfWidth, cellBounds.getMaxY()+halfHeight);						break;					case 2:		// lower-right						iconPos.setLocation(cellBounds.getMaxX()+halfWidth, cellBounds.getMinY()-halfHeight);						break;					case 3:		// lower-left						iconPos.setLocation(cellBounds.getMinX()-halfWidth, cellBounds.getMinY()-halfHeight);						break;				}				DBMath.gridAlign(iconPos, alignment);				double px = iconCell.getBounds().getWidth();				double py = iconCell.getBounds().getHeight();				iconNode = NodeInst.makeInstance(iconCell, iconPos, px, py, curCell);			}			if (!doItNow)				fieldVariableChanged("iconNode");			return true;		}		public void terminateOK()		{			if (iconNode != null && !doItNow)			{				EditWindow wnd = EditWindow.getCurrent();				if (wnd != null)				{					if (wnd.getCell() == curCell)					{						Highlighter highlighter = wnd.getHighlighter();						highlighter.clear();						highlighter.addElectricObject(iconNode, curCell);						highlighter.finished();					}				}			}		}	}	/**	 * Class to define parameters for automatic icon generation	 */	public static class IconParameters implements Serializable	{		/** length of leads from body to export */							double leadLength;		/** spacing between leads (or exports) */							double leadSpacing;		/** true to place exports by location in original cell */			boolean placeByCellLocation;		/** true to place exports exactly by location in original cell */   boolean useExactLocation;		/** true to reverse placement of exports */							boolean reverseIconExportOrder;		/** true to draw an icon body (a rectangle) */						boolean drawBody;		/** size (in units) of text on body */								double bodyTextSize;		/** true to draw leads between the body and exports */				boolean drawLeads;		/** true to place a cell-center in the icon */						boolean placeCellCenter;		/** technology: 0=generic, 1=schematic */							int exportTech;		/** text style: 0=centered, 1=inward, 2=outward */					int exportStyle;		/** text location: 0=on body, 1=end of lead, 2=middle of lead */	int exportLocation;		/** true to make exports "always drawn" */							boolean alwaysDrawn;		/** side for input ports (when placeByCellLocation false) */		int inputSide;		/** side for output ports (when placeByCellLocation false) */		int outputSide;		/** side for bidir ports (when placeByCellLocation false) */		int bidirSide;		/** side for power ports (when placeByCellLocation false) */		int pwrSide;		/** side for ground ports (when placeByCellLocation false) */		int gndSide;		/** side for clock ports (when placeByCellLocation false) */		int clkSide;		/** rotation of input text (when placeByCellLocation false) */		int inputRot;		/** rotation of output text (when placeByCellLocation false) */		int outputRot;		/** rotation of bidir text (when placeByCellLocation false) */		int bidirRot;		/** rotation of power text (when placeByCellLocation false) */		int pwrRot;		/** rotation of ground text (when placeByCellLocation false) */		int gndRot;		/** rotation of clock text (when placeByCellLocation false) */		int clkRot;		/** rotation of top text (when placeByCellLocation true) */			int topRot;		/** rotation of bottom text (when placeByCellLocation true) */		int bottomRot;		/** rotation of left text (when placeByCellLocation true) */		int leftRot;		/** rotation of right text (when placeByCellLocation true) */		int rightRot;		public IconParameters()		{			boolean drawBodyAndLeads = Job.getDebug();			leadLength = 2.0;			leadSpacing = 2.0;			placeByCellLocation = false;			useExactLocation = false;			reverseIconExportOrder = false;			drawBody = drawBodyAndLeads;			bodyTextSize = 1.0;			drawLeads = drawBodyAndLeads;			placeCellCenter = true;			exportTech = 0;			exportStyle = 1;			exportLocation = 1;			alwaysDrawn = false;			inputSide = 0;			outputSide = 1;			bidirSide = 2;			pwrSide = 3;			gndSide = 3;			clkSide = 0;			inputRot = 0;			outputRot = 0;			bidirRot = 0;			pwrRot = 0;			gndRot = 0;			clkRot = 0;			topRot = 0;			bottomRot = 0;			leftRot = 0;			rightRot = 0;		}		public void initFromUserDefaults()		{			leadLength = User.getIconGenLeadLength();			leadSpacing = User.getIconGenLeadSpacing();			placeByCellLocation = User.getIconGenExportPlacement() == 1;			useExactLocation = User.getIconGenExportPlacementExact();			reverseIconExportOrder = User.isIconGenReverseExportOrder();			drawBody = User.isIconGenDrawBody();			bodyTextSize = User.getIconGenBodyTextSize();			drawLeads = User.isIconGenDrawLeads();			placeCellCenter = User.isPlaceCellCenter();			exportTech = User.getIconGenExportTech();			exportStyle = User.getIconGenExportStyle();			exportLocation = User.getIconGenExportLocation();			alwaysDrawn = User.isIconsAlwaysDrawn();			inputSide = User.getIconGenInputSide();			outputSide = User.getIconGenOutputSide();			bidirSide = User.getIconGenBidirSide();			pwrSide = User.getIconGenPowerSide();			gndSide = User.getIconGenGroundSide();			clkSide = User.getIconGenClockSide();			inputRot = User.getIconGenInputRot();			outputRot = User.getIconGenOutputRot();			bidirRot = User.getIconGenBidirRot();			pwrRot = User.getIconGenPowerRot();			gndRot = User.getIconGenGroundRot();			clkRot = User.getIconGenClockRot();			topRot = User.getIconGenTopRot();			bottomRot = User.getIconGenBottomRot();			leftRot = User.getIconGenLeftRot();			rightRot = User.getIconGenRightRot();		}		/**		 * Method to create an icon for a cell.		 * @param curCell the cell to turn into an icon.		 * @return the icon cell (null on error).		 */		public Cell makeIconForCell(Cell curCell)			throws JobException		{			// create the new icon cell			String iconCellName = curCell.getName() + "{ic}";			Cell iconCell = Cell.makeInstance(curCell.getLibrary(), iconCellName);			if (iconCell == null)				throw new JobException("Cannot create Icon cell " + iconCellName);			iconCell.setWantExpanded();			// determine number of ports on each side			int leftSide = 0, rightSide = 0, bottomSide = 0, topSide = 0;			Map<Export,Integer> portIndex = new HashMap<Export,Integer>();			Map<Export,Integer> portSide = new HashMap<Export,Integer>();			Map<Export,Integer> portRotation = new HashMap<Export,Integer>();			// make a sorted list of exports			List<Export> exportList = new ArrayList<Export>();			for(Iterator<PortProto> it = curCell.getPorts(); it.hasNext(); )			{				Export pp = (Export)it.next();				if (pp.isBodyOnly()) continue;				exportList.add(pp);			}			if (placeByCellLocation)			{				// place exports according to their location in the cell				Collections.sort(exportList, new ExportsByAngle());				// figure out how many exports go on each side				int numExports = exportList.size();				leftSide = rightSide = topSide = bottomSide = numExports / 4;				if (leftSide + rightSide + topSide + bottomSide < numExports) leftSide++;				if (leftSide + rightSide + topSide + bottomSide < numExports) rightSide++;				if (leftSide + rightSide + topSide + bottomSide < numExports) topSide++;				// cache the location of each export				Map<Export,Point2D> portCenters = new HashMap<Export,Point2D>();				for(int i=0; i<numExports; i++)				{					Export pp = exportList.get(i);					portCenters.put(pp, pp.getOriginalPort().getCenter());

⌨️ 快捷键说明

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