📄 comparisonspane.java
字号:
/* -*- tab-width: 4 -*-** Electric(tm) VLSI Design System** File: ComparisonsPane.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.ncc;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Component;import java.awt.Toolkit;import java.awt.datatransfer.Clipboard;import java.awt.datatransfer.StringSelection;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.Vector;import javax.swing.BorderFactory;import javax.swing.JLabel;import javax.swing.JMenuItem;import javax.swing.JPanel;import javax.swing.JPopupMenu;import javax.swing.JScrollPane;import javax.swing.JSplitPane;import javax.swing.border.Border;import javax.swing.tree.DefaultMutableTreeNode;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.text.CellName;import com.sun.electric.database.variable.VarContext;import com.sun.electric.tool.ncc.result.EquivRecReport;import com.sun.electric.tool.ncc.result.NccResult;import com.sun.electric.tool.ncc.result.NetObjReport;import com.sun.electric.tool.ncc.result.PartReport;import com.sun.electric.tool.ncc.result.WireReport;import com.sun.electric.tool.user.Highlighter;import com.sun.electric.tool.user.ncc.ComparisonsTree.TreeNode;/** * This class implements the right side of the NCC GUI window. * It is a placeholder for tables of different types, such as Exports, * Equivalence Classes, Sizes, etc. */class ComparisonsPane extends JSplitPane implements ActionListener { /* what is currently displayed */ private static final int EMPTY = 0; private static final int COMP_SUMMARY = 1; private static final int EXPORTS = 2; private static final int PARTS_WIRES = 3; private static final int SIZES = 4; private static final int EXPORT_ASSERTS = 5; private static final int EXPORT_NET_CONF = 6; private static final int EXPORT_CHR_CONF = 7; private static final int UNRECOG_PART = 8; /** max number of concurrent equiv. classes */ private static final int MAX_CONCUR_EQ_RECS = 5; private static final String emptyStr = " "; private static final String LSEP = System.getProperty("line.separator"); /* --- GUI variables --- */ protected String defaultTitles[] = {emptyStr, emptyStr}; private String treeTitle = " Mismatched Comparisons"; private JLabel treeLabel = new JLabel(treeTitle); private ComparisonsTree tree; private JScrollPane treeScrollPane; private int dispOnRight = EMPTY; private static Border border = BorderFactory.createEmptyBorder(); /* tables corresponding to different tree node types */ private JScrollPane exportsPanes[]; private JScrollPane exportAssertionsPanes[]; private JScrollPane exportNetConflictPanes[]; private JScrollPane exportChrConflictPanes[]; private JScrollPane unrecognizedPartsPanes[]; private EquivClassSplitPane rightSplPanes[]; private JPanel sizesPanes[]; /** Right-click popup for a tree node */ protected JPopupMenu treePopup; /** Right-click popup for a table cell */ protected JPopupMenu cellPopup; protected String clipboard; /* --- Data holders --- */ /** Current list of mismatched comparisons */ private NccGuiInfo mismatches[]; /** Current list of Wire/Part equiv. classes with mismatches */ private EquivRecReport mismEqRecs[][]; /** Mismatched NetObjects in current EquivRecords */ private List<NetObjReport>[] mismNetObjs[][]; /** Matched NetObjects in current EquivRecords */ private List<NetObjReport>[] matchedNetObjs[][]; /** Vector of currently selected equiv. class TreeNode objects */ private Vector<TreeNode> curEqRecNodes = new Vector<TreeNode>(); /** Vector of equiv. class TreeNode objects that should be displayed */ private Vector<TreeNode> curEqRecNodesToDisplay = new Vector<TreeNode>(); /** Vector of currently selected exclusive TreeNode objects Exclusive nodes are those requiring exclusive access to the right pane. All nodes except for EquivRecord and TITLE are exclusive. */ private Vector<TreeNode> curExlusiveNodes = new Vector<TreeNode>(); public ComparisonsPane() { super(JSplitPane.HORIZONTAL_SPLIT); setOneTouchExpandable(true); setDividerLocation(0.5); // after a resize the right half gets more resized setResizeWeight(0.2); createCellPopup(); rightSplPanes = new EquivClassSplitPane[MAX_CONCUR_EQ_RECS]; for (int i=0; i<MAX_CONCUR_EQ_RECS; i++) rightSplPanes[i] = new EquivClassSplitPane(this, i+1); setRightComponent(rightSplPanes[0]); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(treeLabel, BorderLayout.NORTH); leftPanel.setBorder(border); TreeNode rootNode = new TreeNode(null, treeTitle, -1, -1, TreeNode.TITLE); tree = new ComparisonsTree(this, new DefaultMutableTreeNode(rootNode)); treeScrollPane = new JScrollPane(tree); leftPanel.add(treeScrollPane, BorderLayout.CENTER); setLeftComponent(leftPanel); } /** Set the current set of mismatches to the provided one */ public void setMismatches(List<NccGuiInfo> misms) { mismatches = misms.toArray(new NccGuiInfo[0]); // allocate arrays of for tables mismEqRecs = new EquivRecReport[mismatches.length][]; mismNetObjs = new ArrayList[mismatches.length][][]; matchedNetObjs = new ArrayList[mismatches.length][][]; exportsPanes = new JScrollPane[mismatches.length]; exportAssertionsPanes = new JScrollPane[mismatches.length]; exportNetConflictPanes = new JScrollPane[mismatches.length]; exportChrConflictPanes = new JScrollPane[mismatches.length]; unrecognizedPartsPanes = new JScrollPane[mismatches.length]; sizesPanes = new JPanel[mismatches.length]; // clear lists of selected/displayed TreeNode objects curEqRecNodes.clear(); curEqRecNodesToDisplay.clear(); curExlusiveNodes.clear(); // display summary of the first comparison int divPos = getDividerLocation(); dispOnRight = COMP_SUMMARY; displayComparisonSummary(0); setDividerLocation(divPos); // update tree StringBuffer buf = new StringBuffer(treeTitle + " ["); if (mismatches.length > ComparisonsTree.MAX_COMP_NODES) buf.append("first " + ComparisonsTree.MAX_COMP_NODES + " of "); buf.append(mismatches.length + "]"); treeLabel.setText(buf.toString()); tree.update(mismatches); treeScrollPane.getVerticalScrollBar().setValue(0); getExportsPane(0); // preload exports of the first comparison } /** * Set the array of Part/Wire equiv. classes for comparison number compNdx * @param compNdx index of the comparison * @param equivRecs array of equiv. classes */ protected void setMismatchEquivRecs(int compNdx, EquivRecReport[] equivRecs) { mismEqRecs[compNdx] = equivRecs; mismNetObjs[compNdx] = new ArrayList[equivRecs.length][]; matchedNetObjs[compNdx] = new ArrayList[equivRecs.length][]; } /** * Get the array of Part/Wire equiv. classes for comparison number compNdx * @param compNdx index of the comparison * @return array of equiv. classes */ protected EquivRecReport[] getMismatchEquivRecs(int compNdx) { return mismEqRecs[compNdx]; } /** * Reset the content of the right pane to empty */ private void resetRightPane() { // reset right pane view int divPos = getDividerLocation(); for (int j=0; j<2; j++) { rightSplPanes[0].setLabelText(0,j,defaultTitles[j]); rightSplPanes[0].setCellText(0,j,emptyStr); } setRightComponent(rightSplPanes[0]); setDividerLocation(divPos); dispOnRight = EMPTY; } /** * Get the Exports table for comparison number compNdx * @param compNdx comparison index * @return Exports table wrapped into a JScrollPane */ private JScrollPane getExportsPane(int compNdx) { if (compNdx < 0 || compNdx >= exportsPanes.length) return null; if (exportsPanes[compNdx] == null) { ExportMismatchTable table = new ExportMismatchTable(mismatches[compNdx]); exportsPanes[compNdx] = new JScrollPane(table); exportsPanes[compNdx].setBackground(Color.WHITE); } return exportsPanes[compNdx]; } /**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -