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

📄 windowframe.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
		}	}	// ************************** Cell History Traversal  *************************************	/** List of CellHistory objects */                      private List<CellHistory> cellHistory;	/** Location in history (points to valid location) */   private int cellHistoryLocation;	/** History limit */                                    private static final int cellHistoryLimit = 20;	/**	 * Class to track CellHistory and associated values.	 */	public static class CellHistory	{		/** cell */												private Cell cell;		/** context */											private VarContext context;		/** the port that is highlighted */						private PortInst selPort;		/** display attributes (scale, in-place, etc.) */		private DisplayAttributes da;		/** highlights */										private List<Highlight2> highlights;		/** highlight offset*/									private double offX, offY;		public Cell getCell() { return cell; }		public VarContext getContext() { return context; }		public void setContext(VarContext context) { this.context = context; }		public void setSelPort(PortInst selPort) { this.selPort = selPort; }		public DisplayAttributes getDisplayAttributes() { return da; }		public void setDisplayAttributes(DisplayAttributes da) { this.da = da; }	}	/**	 * Method to return the list of cell histories associated with this WindowFrame.	 * @return the list of cell histories associated with this WindowFrame.	 */	public List<CellHistory> getCellHistoryList() { return cellHistory; }	/**	 * Method to return the current position in the cell history list.	 * @return the current position in the cell history list.	 */	public int getCellHistoryLocation() { return cellHistoryLocation; }	/**	 * Go back in history list.	 */	public void cellHistoryGoBack()	{		// at start of history		if (cellHistoryLocation <= 0) return;		setCellByHistory(cellHistoryLocation-1);	}	/**	 * Go forward in history list.	 */	public void cellHistoryGoForward()	{		if (cellHistoryLocation >= (cellHistory.size() - 1)) return; // at end of history		setCellByHistory(cellHistoryLocation+1);	}	/** Returns true if we can go back in history list, false otherwise */	private boolean cellHistoryCanGoBack()	{		if (cellHistoryLocation > 0) return true;		return false;	}	/** Returns true if we can go forward in history list, false otherwise */	private boolean cellHistoryCanGoForward()	{		if (cellHistoryLocation < cellHistory.size() - 1) return true;		return false;	}	/**	 * Method to updates back/forward button states.	 * Used when new tool bar is created with existing edit window	 * (when moving windows across displays).	 */	private void fireCellHistoryStatus()	{		ToolBar toolBar = getToolBar();		if (toolBar == null) return;		toolBar.updateCellHistoryStatus(cellHistoryCanGoBack(), cellHistoryCanGoForward());	}	/**	 * Method to return the ToolBar associated with this WindowFrame.     * In SDI mode this returns this WindowFrame's ToolBar.     * In MDI mode there is only one ToolBar, so this method will     * return that ToolBar.	 * @return the TooolBar associated with this WindowFrame.	 */    private ToolBar getToolBar()    {        TopLevel topLevel = getFrame();        return topLevel != null ? topLevel.getToolBar() : null;    }	/**	 * Adds to cellHistory record list.	 * Should only be called via non-history traversing modifications	 * to history. (such as Edit->New Cell).	 */	public void addToHistory(Cell cell, VarContext context, DisplayAttributes da)	{		if (cell == null) return;		CellHistory history = new CellHistory();		history.cell = cell;		history.context = context;        if (da == null)            da = new DisplayAttributes();		history.da = da;		// when user has moved back through history, and then edits a new cell,		// get rid of forward history		if (cellHistoryLocation < (cellHistory.size() - 1))		{			// inserting into middle of history: get rid of history forward of this			for(int i=cellHistory.size()-1; i>cellHistoryLocation; i--)				cellHistory.remove(i);		}		// update history		cellHistory.add(history);		cellHistoryLocation = cellHistory.size() - 1;		// adjust if we are over the limit		if (cellHistoryLocation > cellHistoryLimit)		{			cellHistory.remove(0);			cellHistoryLocation--;		}		fireCellHistoryStatus();//showHistory("add to history");	}//private void showHistory(String why)//{//	System.out.println("AFTER "+why+", CELL HISTORY:");//	for(int i=0; i<cellHistory.size(); i++)//	{//		CellHistory ch = cellHistory.get(i);//		System.out.print("  HISTORY "+i);//		if (i == cellHistoryLocation) System.out.print("**");//		System.out.println(" cell="+ch.cell.describe(false)+" scale="+ch.da.scale);//	}//}	/**	 * Records current cell state into history	 * Assumes record pointed to by cellHistoryLocation is	 * history record for the current cell/context.	 */	public void saveCurrentCellHistoryState()	{		if (cellHistoryLocation < 0) return;		if (content instanceof EditWindow)		{			EditWindow wnd = (EditWindow)content;			CellHistory current = cellHistory.get(cellHistoryLocation);			current.context = wnd.getVarContext();			// save zoom and pan			// save down-in-place information			current.da = new DisplayAttributes(wnd);			// save selected port            current.selPort = null;			Highlighter highlighter = wnd.getHighlighter();			if (highlighter.getNumHighlights() == 1)			{				Highlight2 h = highlighter.getOneHighlight();		        if (h != null)		        {		        	ElectricObject eobj = h.getElectricObject();			        if (eobj instanceof PortInst)			        	current.selPort = (PortInst)eobj;		        }			}			// save highlighting			current.highlights = new ArrayList<Highlight2>();			Cell cell = content.getCell();			for (Highlight2 h : highlighter.getHighlights()) {				if (h.getCell() == cell)					current.highlights.add(h);			}			Point2D off = highlighter.getHighlightOffset();			if (off != null)			{				current.offX = off.getX();				current.offY = off.getY();			}		}//showHistory("save state");	}	/** Restores cell state from history record */	public void setCellByHistory(int location)	{		// get cell history to go to		CellHistory history = cellHistory.get(location);		// see if cell still valid part of database. If not, nullify entry		if (history.cell == null || !history.cell.isLinked())		{			history.cell = null;			history.context = VarContext.globalContext;			history.selPort = null;			history.da = new WindowFrame.DisplayAttributes();			history.highlights = new ArrayList<Highlight2>();			history.offX = history.offY = 0;		}		// update current cell		setCellWindow(history.cell, history);		if (history.cell != null && !history.cell.getView().isTextView())		{			EditWindow wnd = (EditWindow)content;			if (history.selPort != null)			{				wnd.getHighlighter().addElectricObject(history.selPort, history.cell);			} else if (history.highlights != null)			{				wnd.getHighlighter().setHighlightList(history.highlights);				wnd.getHighlighter().setHighlightOffset((int)history.offX, (int)history.offY);			}			wnd.fullRepaint();		}		// point to new location *after* calling setCell, since setCell updates by current location		cellHistoryLocation = location;		fireCellHistoryStatus();//showHistory("left/right buttons");	}	/**	 * Method to find a CellHistory index that shows a given cell and context.	 * @param cell the cell to find.	 * @param context the cell context to find.	 * @return the CellHistory index associated with that cell/context	 * (-1 if not found).	 */	public int findCellHistoryIndex(Cell cell, VarContext context)	{		for (int i=cellHistory.size()-1; i>-1; i--)		{			CellHistory history = cellHistory.get(i);			if (history.cell == cell && history.context.equals(context))				return i;		}		return -1;	}    //******************************** HANDLERS FOR WINDOW EVENTS ********************************	/**	 * This class handles activation and close events for JFrame objects (used in SDI mode).	 */	private class WindowsEvents extends WindowAdapter	{        /** A weak reference to the WindowFrame */		WeakReference<WindowFrame> wf;		WindowsEvents(WindowFrame wf)		{			super();			this.wf = new WeakReference<WindowFrame>(wf);		}		public void windowActivated(WindowEvent evt)		{			WindowFrame realWF = wf.get();			realWF.usageClock = usageCounter++;			WindowFrame.setCurrentWindowFrame(realWF);			realWF.fireCellHistoryStatus();                // update tool bar history buttons		}		public void windowClosing(WindowEvent evt)		{			wf.get().finished();		}	}	/**	 * This class handles activation and close events for JInternalFrame objects (used in MDI mode).	 */	private class InternalWindowsEvents extends InternalFrameAdapter	{        /** A weak reference to the WindowFrame */		WeakReference<WindowFrame> wf;		InternalWindowsEvents(WindowFrame wf)		{			super();			this.wf = new WeakReference<WindowFrame>(wf);		}		public void internalFrameClosing(InternalFrameEvent evt)		{			(wf.get()).finished();		}		public void internalFrameActivated(InternalFrameEvent evt)		{			WindowFrame realWF = wf.get();			realWF.usageClock = usageCounter++;			WindowFrame.setCurrentWindowFrame(realWF);			realWF.fireCellHistoryStatus();                // update tool bar history buttons		}	}    /**     * Database change listener that updates library trees when needed     */    private static class LibraryTreeUpdater implements DatabaseChangeListener {        private LibraryTreeUpdater() { UserInterfaceMain.addDatabaseChangeListener(this); }        public void databaseChanged(DatabaseChangeEvent e)        {            if (e.cellTreeChanged())                wantToRedoLibraryTree();        }//         public void databaseEndChangeBatch(Undo.ChangeBatch batch)//         {//             boolean changed = false;//             for (Iterator it = batch.getChanges(); it.hasNext(); )//             {//                 Undo.Change change = it.next();//                 if (change.getType() == Undo.Type.LIBRARYKILL ||//                     change.getType() == Undo.Type.LIBRARYNEW ||//                     change.getType() == Undo.Type.CELLKILL ||//                     change.getType() == Undo.Type.CELLNEW ||//                     change.getType() == Undo.Type.CELLGROUPMOD ||//                     (change.getType() == Undo.Type.OBJECTRENAME && change.getObject() instanceof Cell) ||// 					(change.getType() == Undo.Type.VARIABLENEW && change.getObject() instanceof Cell && ((Variable)change.getO1()).getKey() == Cell.MULTIPAGE_COUNT_KEY))//                 {//                     changed = true;//                     break;//                 }//             }//             if (changed)//                 updateLibraryTrees();//         }//         public void databaseChanged(Undo.Change evt) {}//         public boolean isGUIListener() { return true; }    }}

⌨️ 快捷键说明

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