📄 windowframe.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: WindowFrame.java * * Copyright (c) 2003 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.ui;import com.sun.electric.database.change.DatabaseChangeEvent;import com.sun.electric.database.change.DatabaseChangeListener;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.VarContext;import com.sun.electric.technology.Technology;import com.sun.electric.tool.Client;import com.sun.electric.tool.Job;import com.sun.electric.tool.simulation.Stimuli;import com.sun.electric.tool.user.*;import com.sun.electric.tool.user.menus.FileMenu;import com.sun.electric.tool.user.menus.WindowMenu;import com.sun.electric.tool.user.ui.WindowFrame.DisplayAttributes;import com.sun.electric.tool.user.waveform.WaveformWindow;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.event.MouseListener;import java.awt.event.MouseMotionListener;import java.awt.event.MouseWheelListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.lang.ref.WeakReference;import java.util.ArrayList;import java.util.Collections;import java.util.EventListener;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Observable;import java.beans.PropertyVetoException;import javax.swing.*;import javax.swing.event.InternalFrameAdapter;import javax.swing.event.InternalFrameEvent;import javax.swing.tree.MutableTreeNode;/** * This class defines an edit window, with a cell explorer on the left side. */public class WindowFrame extends Observable{ /** offset between newly created windows */ private static final int WINDOW_OFFSET = 0; // was 150 /** the nature of the main window part (from above) */ private WindowContent content; /** the split pane that shows explorer and edit. */ private JSplitPane js; /** the internal frame (if MDI). */ private JInternalFrame jif = null; /** the top-level frame (if SDI). */ private TopLevel jf = null; /** the internalframe listener */ private InternalWindowsEvents internalWindowsEvents; /** the window event listener */ private WindowsEvents windowsEvents; /** the side bar (explorer, components, etc) */ private JTabbedPane sideBar; /** true if sidebar is on the left */ private boolean sideBarOnLeft; /** the explorer tab */ private ExplorerTree explorerTab; /** the component tab */ private PaletteFrame paletteTab; /** the layers tab */ private LayerTab layersTab; /** true if this window is finished */ private boolean finished = false; /** the index of this window */ private int index; /** indicator of the most recent used window */ private int usageClock; /** the dynamic menu to hold WindowMenus */ private JMenu dynamicMenu; /** the overall usage counter */ private static int usageCounter = 0; /** the unique index number of all windows */ private static int windowIndexCounter = 0; /** the offset of each new windows from the last */ private static int windowOffset = 0; /** the list of all windows on the screen */ private static List<WindowFrame> windowList = new ArrayList<WindowFrame>(); /** the current windows. */ private static WindowFrame curWindowFrame = null; /** current mouse listener */ public static MouseListener curMouseListener = ClickZoomWireListener.theOne; /** current mouse motion listener */ public static MouseMotionListener curMouseMotionListener = ClickZoomWireListener.theOne; /** current mouse wheel listener */ public static MouseWheelListener curMouseWheelListener = ClickZoomWireListener.theOne; /** current key listener */ public static KeyListener curKeyListener = ClickZoomWireListener.theOne; /** * Use by highlight tools to bring the frame to the front. * @param wf */ public static void showFrame(WindowFrame wf) { if (TopLevel.isMDIMode()) { JInternalFrame jif = wf.getInternalFrame(); try { jif.setIcon(false); jif.setSelected(true); } catch (PropertyVetoException e) {} if (!jif.isVisible()) { jif.toFront(); TopLevel.addToDesktop(jif); } else jif.toFront(); } else { JFrame jf = wf.getFrame(); jf.setState(Frame.NORMAL); if (!jf.isVisible()) { jf.toFront(); assert !Job.BATCHMODE; jf.setVisible(true); } else jf.toFront(); } } public static void repaintAllWindows() { for(Iterator<WindowFrame> it = getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); WindowContent content = wf.getContent(); content.fullRepaint(); } for(Iterator<WindowFrame> it = getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); wf.loadComponentMenuForTechnology(); } } /** library tree updater */ static { new LibraryTreeUpdater(); } public static class DisplayAttributes { /** the window scale */ public final double scale; /** the window offset */ public final double offX, offY; /** path to cell being edited (down-in-place) */ public final List<NodeInst> inPlaceDescent; public DisplayAttributes() { this(1, 0, 0, Collections.<NodeInst>emptyList()); } public DisplayAttributes(EditWindow wnd) { this(wnd.getScale(), wnd.getOffset().getX(), wnd.getOffset().getY(), wnd.getInPlaceEditNodePath()); } public DisplayAttributes(double scale, double offX, double offY, List<NodeInst> inPlaceDescent) { this.scale = scale; this.offX = offX; this.offY = offY; this.inPlaceDescent = new ArrayList<NodeInst>(inPlaceDescent); } public AffineTransform getIntoCellTransform() { AffineTransform intoCell = new AffineTransform(); for (NodeInst ni : inPlaceDescent) intoCell.preConcatenate(ni.rotateIn(ni.translateIn())); return intoCell; } public AffineTransform getOutofCellTransform() { AffineTransform outofCell = new AffineTransform(); for (NodeInst ni : inPlaceDescent) outofCell.concatenate(ni.translateOut(ni.rotateOut())); return outofCell; } } //******************************** CONSTRUCTION ******************************** // constructor public WindowFrame() { index = windowIndexCounter++; cellHistory = new ArrayList<CellHistory>(); cellHistoryLocation = -1; } /** * Method to set the dynamic menu where * @param menu */ public void setDynamicMenu(JMenu menu) {dynamicMenu = menu;} public JMenu getDynamicMenu() { return dynamicMenu; } /** * Method to create a new circuit-editing window on the screen that displays a Cell. * @param cell the cell to display. * @return the WindowFrame that shows the Cell. */ public static WindowFrame createEditWindow(final Cell cell) { final WindowFrame frame = new WindowFrame(); if (cell != null && cell.getView().isTextView()) { TextWindow tWnd = new TextWindow(cell, frame); frame.finishWindowFrameInformation(tWnd, cell); tWnd.fillScreen(); } else { EditWindow eWnd = EditWindow.CreateElectricDoc(cell, frame, null); frame.finishWindowFrameInformation(eWnd, cell); eWnd.fillScreen(); eWnd.fullRepaint(); } removeUIBinding(frame.js, KeyStroke.getKeyStroke(KeyEvent.VK_F6, 0)); removeUIBinding(frame.js, KeyStroke.getKeyStroke(KeyEvent.VK_F8, 0)); if (cell != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { frame.explorerTab.openLibraryInExplorerTree(cell.getLibrary(), cell, true); } }); } return frame; } /** * Method to get the unique index number of this WindowFrame. * @return the unique index number of this WindowFrame. */ public int getIndex() { return index; } /** * Method to find the WindowFrame associated with an index number. * @param index the index number. * @return the associated WindowFrame (null if none found). */ public static WindowFrame findFromIndex(int index) { for (WindowFrame wf: windowList) if (wf.index == index) return wf; return null; } /** * Method to finish with frame pointers. */ public void finishWindowFrameInformation(WindowContent wnd, Cell cell) { buildWindowStructure(wnd, cell, null); setCurrentWindowFrame(this); populateJFrame(); // Adding into WindowMenu WindowMenu.setDynamicMenus(); } /***************************************************************************** * 3D Stuff * *****************************************************************************/ /** * Method to access 3D view and highligh elements if view is available */ public static void show3DHighlight() { for(Iterator<WindowFrame> it = getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); wf.setChanged(); wf.notifyObservers(wf.getContent()); wf.clearChanged(); } } /***************************************************************************** * END OF 3D Stuff * *****************************************************************************/ /** * Method to create a new waveform window on the screen given the simulation data. * @param sd the simulation data to use in the waveform window. * @return the WindowFrame that shows the waveforms. */ public static WindowFrame createWaveformWindow(Stimuli sd) { WindowFrame frame = new WindowFrame(); WaveformWindow wWnd = new WaveformWindow(sd, frame); frame.finishWindowFrameInformation(wWnd, sd.getCell()); wWnd.fillScreen(); // open the "SIGNALS" part of the explorer panel SwingUtilities.invokeLater(new Runnable() { public void run() { WindowFrame.wantToOpenCurrentLibrary(false, null); }}); return frame; } /** * Method to update all technology popup selectors. * Called when a new technology has been created. */ public static void updateTechnologyLists() { for(Iterator<WindowFrame> it = WindowFrame.getWindows(); it.hasNext(); ) { WindowFrame wf = it.next(); wf.paletteTab.loadTechnologies(false); wf.layersTab.loadTechnologies(false); } } /** * Class to handle changes the "Technology" selection of either the Layer tab or the Component tab of the side bar. */ public static class CurTechControlListener implements ActionListener { private WindowFrame wf; CurTechControlListener(WindowFrame wf) { this.wf = wf; } public void actionPerformed(ActionEvent evt) { JComboBox source = (JComboBox)evt.getSource(); String techName = (String)source.getSelectedItem(); Technology tech = Technology.findTechnology(techName); if (tech != null) { // change the technology tech.setCurrent(); wf.getPaletteTab().loadForTechnology(tech, wf); wf.getLayersTab().updateLayersTab(); } } } public List<MutableTreeNode> loadDefaultExplorerTree() { MutableTreeNode libraryExplorerNode = ExplorerTreeModel.makeLibraryTree(); return Collections.singletonList(libraryExplorerNode); } private Dimension buildWindowStructure(WindowContent content, Cell cell, GraphicsConfiguration gc) { this.content = content; // the left half: an explorer tree in a scroll pane explorerTab = new ExplorerTree(content.loadExplorerTrees()); JScrollPane scrolledTree = new JScrollPane(explorerTab);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -