📄 getinfomulti.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: GetInfoMulti.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.dialogs;import com.sun.electric.database.change.DatabaseChangeEvent;import com.sun.electric.database.change.DatabaseChangeListener;import com.sun.electric.database.geometry.EGraphics;import com.sun.electric.database.geometry.Orientation;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.CodeExpression;import com.sun.electric.database.variable.DisplayedText;import com.sun.electric.database.variable.ElectricObject;import com.sun.electric.database.variable.MutableTextDescriptor;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Client;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.user.Highlight2;import com.sun.electric.tool.user.HighlightListener;import com.sun.electric.tool.user.Highlighter;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.UserInterfaceMain;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.TopLevel;import java.awt.Dimension;import java.awt.Font;import java.awt.Frame;import java.awt.GraphicsEnvironment;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.geom.Point2D;import java.io.Serializable;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Set;import javax.swing.BoxLayout;import javax.swing.DefaultListModel;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JComponent;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JList;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.ListSelectionModel;/** * Class to handle the "Multi-object Get Info" dialog. */public class GetInfoMulti extends EModelessDialog implements HighlightListener, DatabaseChangeListener{ private enum ChangeType { CHANGEXSIZE, CHANGEYSIZE, CHANGEXPOS, CHANGEYPOS, CHANGEROTATION, CHANGEMIRRORLR, CHANGEMIRRORUD, CHANGEEXPANDED, CHANGEEASYSELECT, CHANGEINVOUTSIDECELL, CHANGELOCKED, CHANGEWIDTH, CHANGERIGID, CHANGEFIXANGLE, CHANGESLIDABLE, CHANGEEXTENSION, CHANGEDIRECTION, CHANGENEGATION, CHANGECHARACTERISTICS, CHANGEBODYONLY, CHANGEALWAYSDRAWN, CHANGEPOINTSIZE, CHANGEUNITSIZE, CHANGEXOFF, CHANGEYOFF, CHANGETEXTROT, CHANGEANCHOR, CHANGEFONT, CHANGECOLOR, CHANGEBOLD, CHANGEITALIC, CHANGEUNDERLINE, CHANGECODE, CHANGEUNITS, CHANGESHOW } private static GetInfoMulti theDialog = null; private DefaultListModel listModel; private JList list; private JPanel changePanel; private ChangeType [] currentChangeTypes; private JComponent [] currentChangeValues; private List<Highlight2> highlightList; List<NodeInst> nodeList; List<ArcInst>arcList; List<Export> exportList; List<DisplayedText> textList; List<DisplayedText> annotationTextList; private EditWindow wnd; private static final ChangeType [] nodeChanges = { ChangeType.CHANGEXSIZE, ChangeType.CHANGEYSIZE, ChangeType.CHANGEXPOS, ChangeType.CHANGEYPOS, ChangeType.CHANGEROTATION, ChangeType.CHANGEMIRRORLR, ChangeType.CHANGEMIRRORUD, ChangeType.CHANGEEXPANDED, ChangeType.CHANGEEASYSELECT, ChangeType.CHANGEINVOUTSIDECELL, ChangeType.CHANGELOCKED}; private static final ChangeType [] arcChanges = { ChangeType.CHANGEWIDTH, ChangeType.CHANGERIGID, ChangeType.CHANGEFIXANGLE, ChangeType.CHANGESLIDABLE, ChangeType.CHANGEEXTENSION, ChangeType.CHANGEDIRECTION, ChangeType.CHANGENEGATION, ChangeType.CHANGEEASYSELECT}; private static final ChangeType [] exportChanges = { ChangeType.CHANGECHARACTERISTICS, ChangeType.CHANGEBODYONLY, ChangeType.CHANGEALWAYSDRAWN, ChangeType.CHANGEPOINTSIZE, ChangeType.CHANGEUNITSIZE, ChangeType.CHANGEXOFF, ChangeType.CHANGEYOFF, ChangeType.CHANGETEXTROT, ChangeType.CHANGEANCHOR, ChangeType.CHANGEFONT, ChangeType.CHANGECOLOR, ChangeType.CHANGEBOLD, ChangeType.CHANGEITALIC, ChangeType.CHANGEUNDERLINE, ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] textChanges = { ChangeType.CHANGEPOINTSIZE, ChangeType.CHANGEUNITSIZE, ChangeType.CHANGEXOFF, ChangeType.CHANGEYOFF, ChangeType.CHANGETEXTROT, ChangeType.CHANGEANCHOR, ChangeType.CHANGEFONT, ChangeType.CHANGECOLOR, ChangeType.CHANGECODE, ChangeType.CHANGEUNITS, ChangeType.CHANGESHOW, ChangeType.CHANGEBOLD, ChangeType.CHANGEITALIC, ChangeType.CHANGEUNDERLINE, ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] annotationChanges = { ChangeType.CHANGEPOINTSIZE, ChangeType.CHANGEUNITSIZE, ChangeType.CHANGEXPOS, ChangeType.CHANGEYPOS, ChangeType.CHANGETEXTROT, ChangeType.CHANGEANCHOR, ChangeType.CHANGEFONT, ChangeType.CHANGECOLOR, ChangeType.CHANGECODE, ChangeType.CHANGEUNITS, ChangeType.CHANGESHOW, ChangeType.CHANGEBOLD, ChangeType.CHANGEITALIC, ChangeType.CHANGEUNDERLINE, ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] textAnnotationChanges = { ChangeType.CHANGEPOINTSIZE, ChangeType.CHANGEUNITSIZE, ChangeType.CHANGETEXTROT, ChangeType.CHANGEANCHOR, ChangeType.CHANGEFONT, ChangeType.CHANGECOLOR, ChangeType.CHANGECODE, ChangeType.CHANGEUNITS, ChangeType.CHANGESHOW, ChangeType.CHANGEBOLD, ChangeType.CHANGEITALIC, ChangeType.CHANGEUNDERLINE, ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] nodeArcChanges = {ChangeType.CHANGEEASYSELECT}; private static final ChangeType [] nodeTextChanges = {ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] nodeExportChanges = {ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] nodeTextExportChanges = {ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [] textExportChanges = { ChangeType.CHANGEPOINTSIZE, ChangeType.CHANGEUNITSIZE, ChangeType.CHANGEXOFF, ChangeType.CHANGEYOFF, ChangeType.CHANGETEXTROT, ChangeType.CHANGEANCHOR, ChangeType.CHANGEFONT, ChangeType.CHANGECOLOR, ChangeType.CHANGEBOLD, ChangeType.CHANGEITALIC, ChangeType.CHANGEUNDERLINE, ChangeType.CHANGEINVOUTSIDECELL}; private static final ChangeType [][] changeCombos = { null, // nodeChanges, // nodes arcChanges, // arcs nodeArcChanges, // nodes arcs exportChanges, // exports nodeExportChanges, // nodes exports null, // arcs exports null, // nodes arcs exports textChanges, // text nodeTextChanges, // nodes text null, // arcs text null, // nodes arcs text textExportChanges, // exports text nodeTextExportChanges, // nodes exports text null, // arcs exports text null, // nodes arcs exports text annotationChanges, // annotation null, // nodes annotation null, // arcs annotation null, // nodes arcs annotation null, // exports annotation null, // nodes exports annotation null, // arcs exports annotation null, // nodes arcs exports annotation textAnnotationChanges, // text annotation null, // nodes text annotation null, // arcs text annotation null, // nodes arcs text annotation null, // exports text annotation null, // nodes exports text annotation null, // arcs exports text annotation null, // nodes arcs exports text annotation }; /** * Method to show the Multi-object Get-Info dialog. */ public static void showDialog() { if (Client.getOperatingSystem() == Client.OS.UNIX) { // JKG 07Apr2006: // On Linux, if a dialog is built, closed using setVisible(false), // and then requested again using setVisible(true), it does // not appear on top. I've tried using toFront(), requestFocus(), // but none of that works. Instead, I brute force it and // rebuild the dialog from scratch each time. if (theDialog != null) theDialog.dispose(); theDialog = null; } if (theDialog == null) { JFrame jf = null; if (TopLevel.isMDIMode()) jf = TopLevel.getCurrentJFrame(); theDialog = new GetInfoMulti(jf); } theDialog.loadMultiInfo(); theDialog.pack(); theDialog.ensureProperSize(); theDialog.setVisible(true); theDialog.toFront(); } /** * Reloads the dialog when Highlights change */ public void highlightChanged(Highlighter which) { if (!isVisible()) return; Dimension oldDim = listPane.getSize(); loadMultiInfo(); listPane.setPreferredSize(oldDim); pack(); ensureProperSize(); } /** * Called when by a Highlighter when it loses focus. The argument * is the Highlighter that has gained focus (may be null). * @param highlighterGainedFocus the highlighter for the current window (may be null). */ public void highlighterLostFocus(Highlighter highlighterGainedFocus) { if (!isVisible()) return; loadMultiInfo(); } /** * Respond to database changes we care about * @param e database change event */ public void databaseChanged(DatabaseChangeEvent e) { if (!isVisible()) return; boolean reload = false; // reload if any objects that changed are part of our list of highlighted objects for (Highlight2 h : highlightList) { if (e.objectChanged(h.getElectricObject())) { reload = true; break; } } if (reload) { // update dialog loadMultiInfo(); pack(); ensureProperSize(); } } /** Creates new form Multi-Object Get Info */ private GetInfoMulti(Frame parent) { super(parent, false); highlightList = new ArrayList<Highlight2>(); initComponents(); getRootPane().setDefaultButton(ok); UserInterfaceMain.addDatabaseChangeListener(this); Highlighter.addHighlightListener(this); // make the list of selected objects listModel = new DefaultListModel(); list = new JList(listModel); list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); listPane.setViewportView(list); // make the panel for changes changePanel = new JPanel(); changePanel.setLayout(new BoxLayout(changePanel, BoxLayout.Y_AXIS)); possibleChanges.setViewportView(changePanel); loadMultiInfo(); pack(); finishInitialization(); } protected void escapePressed() { cancelActionPerformed(null); } private void loadMultiInfo() { // update current window EditWindow curWnd = EditWindow.getCurrent(); if (curWnd != null) wnd = curWnd; // copy the selected objects to a private list and sort it highlightList.clear(); if (wnd != null) { for(Highlight2 h: wnd.getHighlighter().getHighlights()) highlightList.add(h); Collections.sort(highlightList, new SortMultipleHighlights()); } // show the list nodeList = new ArrayList<NodeInst>(); arcList = new ArrayList<ArcInst>(); exportList = new ArrayList<Export>(); textList = new ArrayList<DisplayedText>(); annotationTextList = new ArrayList<DisplayedText>(); Geometric firstGeom = null, secondGeom = null; double xPositionLow = Double.MAX_VALUE, xPositionHigh = -Double.MAX_VALUE; double yPositionLow = Double.MAX_VALUE, yPositionHigh = -Double.MAX_VALUE; double xSizeLow = Double.MAX_VALUE, xSizeHigh = -Double.MAX_VALUE; double ySizeLow = Double.MAX_VALUE, ySizeHigh = -Double.MAX_VALUE; double widthLow = Double.MAX_VALUE, widthHigh = -Double.MAX_VALUE; double rotLow = Double.MAX_VALUE, rotHigh = -Double.MAX_VALUE; selectionCount.setText(Integer.toString(highlightList.size()) + " selections:"); List<String> displayList = new ArrayList<String>(); for(Highlight2 h : highlightList) { ElectricObject eobj = h.getElectricObject(); displayList.add(h.getInfo()); if (h.isHighlightEOBJ()) { if (eobj instanceof PortInst) eobj = ((PortInst)eobj).getNodeInst(); if (eobj instanceof Geometric) { if (firstGeom == null) firstGeom = (Geometric)eobj; else if (secondGeom == null) secondGeom = (Geometric)eobj; } if (eobj instanceof NodeInst) { NodeInst ni = (NodeInst)eobj; nodeList.add(ni); xPositionLow = Math.min(xPositionLow, ni.getAnchorCenterX()); xPositionHigh = Math.max(xPositionHigh, ni.getAnchorCenterX()); yPositionLow = Math.min(yPositionLow, ni.getAnchorCenterY()); yPositionHigh = Math.max(yPositionHigh, ni.getAnchorCenterY()); double xVal = ni.getLambdaBaseXSize(); double yVal = ni.getLambdaBaseYSize(); double angle = ni.getAngle(); rotLow = Math.min(rotLow, angle); rotHigh = Math.max(rotHigh, angle); if (angle == 900 || angle == 2700) { double swap = xVal; xVal = yVal; yVal = swap; } xSizeLow = Math.min(xSizeLow, xVal); xSizeHigh = Math.max(xSizeHigh, xVal); ySizeLow = Math.min(ySizeLow, yVal); ySizeHigh = Math.max(ySizeHigh, yVal); } else if (eobj instanceof ArcInst) { ArcInst ai = (ArcInst)eobj; arcList.add(ai); double trueWidth = ai.getLambdaBaseWidth(); widthLow = Math.min(widthLow, trueWidth); widthHigh = Math.max(widthHigh, trueWidth); } } else if (h.isHighlightText()) { Variable.Key varKey = h.getVarKey(); if (varKey != null) { if (varKey == Export.EXPORT_NAME) { exportList.add((Export)eobj); } else { boolean isAnnotation = false; if (eobj instanceof NodeInst)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -