📄 comparisonstree.java
字号:
/* -*- tab-width: 4 -*-** Electric(tm) VLSI Design System** File: ComparisonsTree.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.Color;import java.awt.Component;import java.awt.Dimension;import java.awt.FlowLayout;import java.awt.Font;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.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import javax.swing.BorderFactory;import javax.swing.Icon;import javax.swing.JLabel;import javax.swing.JMenuItem;import javax.swing.JPanel;import javax.swing.JPopupMenu;import javax.swing.JTree;import javax.swing.SwingConstants;import javax.swing.border.Border;import javax.swing.event.TreeSelectionEvent;import javax.swing.event.TreeSelectionListener;import javax.swing.tree.DefaultMutableTreeNode;import javax.swing.tree.DefaultTreeCellRenderer;import javax.swing.tree.TreeCellRenderer;import javax.swing.tree.TreePath;import com.sun.electric.tool.ncc.netlist.NetObject;import com.sun.electric.tool.ncc.processing.LocalPartitionResult;import com.sun.electric.tool.ncc.result.EquivRecReport;import com.sun.electric.tool.ncc.result.NetObjReport;import com.sun.electric.tool.ncc.trees.Circuit;/** * This class implements the mismatch comparin tree displayed in the right pane * of the NCC GUI window. */class ComparisonsTree extends JTree implements ActionListener, TreeSelectionListener { /* --- size restrictions --- */ public static final int MAX_COMP_NODES = 100; public static final int MAX_ZEROS = 100; public static final int MAX_CLASSES = 200; public static final int MAX_LIST_ELEMENTS = 200; public static final int MAX_NAME_LEN = 100; /* --- GUI variables --- */ private ComparisonsPane parentPane; private DefaultMutableTreeNode root; private TreeNode rootTreeNode; private WireClassNode wireClassNodes[][]; protected JPopupMenu popup; protected String clipboard; private static Border border = BorderFactory.createEmptyBorder(); private boolean updateInProgress = true; /** list of current comparison mismatches */ private NccGuiInfo[] mismatches; protected ComparisonsTree(ComparisonsPane pane, DefaultMutableTreeNode root) { super(root); this.root = root; rootTreeNode = (TreeNode)root.getUserObject(); parentPane = pane; setMinimumSize(new Dimension(0,0)); setShowsRootHandles(true); addMouseListener(new TreeMouseAdapter()); addTreeSelectionListener(this); createPopup(); setCellRenderer(new MyRenderer()); } /** * Create a right-click popup for tree nodes */ private void createPopup() { popup = new JPopupMenu(); JMenuItem menuItem = new JMenuItem("Copy Node Title To Clipboard"); menuItem.addActionListener(this); popup.add(menuItem); } /** * Update the tree with the provided list of comparison mismatches * @param misms list of comparison mismatches */ protected void update(NccGuiInfo[] misms) { updateInProgress = true; mismatches = misms; wireClassNodes = new WireClassNode[misms.length][]; root.removeAllChildren(); DefaultMutableTreeNode compNode; EquivRecReport[] mismEqRecs; // for each comparison in the list for (int compNdx = 0; compNdx < mismatches.length && compNdx < MAX_COMP_NODES; compNdx++) { NccGuiInfo cm = mismatches[compNdx]; // compute node name from cell names String titles[] = cm.getNames(); String title0 = titles[0].substring(0,titles[0].length()-5); String title1 = titles[1].substring(0,titles[1].length()-5); String title; if (title1.equals(title0)) title = title0 + "{sch,lay}"; else title = titles[0] + " & " + titles[1]; // create top-level tree node TreeNode compTreeNode = new TreeNode(rootTreeNode, title + " [" + cm.getTotalMismatchCount() + "]", compNdx, -1, TreeNode.COMP_TITLE); compTreeNode.setShortName(title); compNode = new DefaultMutableTreeNode(compTreeNode); root.add(compNode); // add exports entry if necessary int exportMismCount = cm.getValidExportMismatchCount(); String exportsTitle = null; if (exportMismCount > 0) { if (exportMismCount > ExportTable.MAXROWS) { exportsTitle = "Exports [first " + ExportTable.MAXROWS + " of " + exportMismCount + "]"; exportMismCount = ExportTable.MAXROWS; } else if (exportMismCount > 0) { exportsTitle = "Exports [" + exportMismCount + "]"; } compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, exportsTitle, compNdx, -1, TreeNode.EXPORTS))); } boolean isHashChecked = cm.isHashFailuresPrinted(); // collect part/wire equiv records int size = cm.getWireRecReports().size() + cm.getPartRecReports().size(); mismEqRecs = new EquivRecReport[size]; int i=0; for (EquivRecReport r : cm.getPartRecReports()) mismEqRecs[i++] = r; for (EquivRecReport r : cm.getWireRecReports()) mismEqRecs[i++] = r; parentPane.setMismatchEquivRecs(compNdx, mismEqRecs); if (mismEqRecs != null && mismEqRecs.length > 0) { // add parts entry addPartClasses(compTreeNode, compNdx, compNode, mismEqRecs, isHashChecked); // add wires entry addWireClasses(compTreeNode, compNdx, compNode, mismEqRecs, isHashChecked); } // add sizes entry, if necessary int sizeMismCount = cm.getSizeMismatches().size(); String sizeTitle = null; if (sizeMismCount > SizeMismatchPane.MAXROWS) { sizeTitle = "Sizes [first " + SizeMismatchPane.MAXROWS + " of " + sizeMismCount + "]"; sizeMismCount = SizeMismatchPane.MAXROWS; } else if (sizeMismCount > 0){ sizeTitle = "Sizes [" + sizeMismCount + "]"; } if (sizeMismCount > 0) compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, sizeTitle, compNdx, -1, TreeNode.SIZES))); // add "export assertion failures" entry, if necessary int exportAssrtCount = cm.getExportAssertionFailures().size(); String exportAssrtTitle = null; if (exportAssrtCount > ExportTable.MAXROWS) { exportAssrtTitle = "Export Assertions [first " + ExportTable.MAXROWS + " of " + exportAssrtCount + "]"; exportAssrtCount = ExportTable.MAXROWS; } else if (exportAssrtCount > 0) { exportAssrtTitle = "Export Assertions [" + exportAssrtCount + "]"; } if (exportAssrtCount > 0) compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, exportAssrtTitle, compNdx, -1, TreeNode.EXPORT_ASSERTS))); // add "export network conflicts", if necessary int exportNetConflictCount = cm.getNetworkExportConflicts().size(); String exportNetConfTitle = null; if (exportNetConflictCount > ExportTable.MAXROWS) { exportNetConfTitle = "Export/Global Network Conflicts [first " + ExportTable.MAXROWS + " of " + exportNetConflictCount + "]"; exportNetConflictCount = ExportTable.MAXROWS; } else if (exportNetConflictCount > 0) { exportNetConfTitle = "Export/Global Network Conflicts [" + exportNetConflictCount + "]"; } if (exportNetConflictCount > 0) compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, exportNetConfTitle, compNdx, -1, TreeNode.EXPORT_NET_CONF))); // add "export characteristics conflicts", if necessary int exportChrConflictCount = cm.getCharactExportConflicts().size(); String exportChrConfTitle = null; if (exportChrConflictCount > ExportTable.MAXROWS) { exportChrConfTitle = "Export/Global Characteristics Conflicts [first " + ExportTable.MAXROWS + " of " + exportChrConflictCount + "]"; exportChrConflictCount = ExportTable.MAXROWS; } else if (exportChrConflictCount > 0) { exportChrConfTitle = "Export/Global Characteristics Conflicts [" + exportChrConflictCount + "]"; } if (exportChrConflictCount > 0) compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, exportChrConfTitle, compNdx, -1, TreeNode.EXPORT_CHR_CONF))); // add "unrecognized Parts", if necessary int unrecPartsCount = cm.getUnrecognizedParts().size(); String unrecPartsTitle = null; if (unrecPartsCount > ExportTable.MAXROWS) { unrecPartsTitle = "Unrecognized Parts [first " + ExportTable.MAXROWS + " of " + unrecPartsCount + "]"; unrecPartsCount = ExportTable.MAXROWS; } else if (unrecPartsCount > 0) { unrecPartsTitle = "Unrecognized Parts [" + unrecPartsCount + "]"; } if (unrecPartsCount > 0) compNode.add(new DefaultMutableTreeNode( new TreeNode(compTreeNode, unrecPartsTitle, compNdx, -1, TreeNode.UNRECOG_PART))); } setRootVisible(true); updateUI(); expandRow(0); // expand root expandRow(1); // expand first comparison setRootVisible(false); // hide root addSelectionRow(0); // select first comparison requestFocusInWindow(); updateInProgress = false; } /** * Add Part equiv. classes nodes * @param compTreeNode top-level comparison node * @param compNdx comparison index * @param inode tree node to add to * @param mismEqRecs equiv. classes
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -