📄 cellproperties.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: CellProperties.java * * Copyright (c) 2004 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.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.text.TempPref;import com.sun.electric.database.text.TextUtils;import com.sun.electric.technology.Technology;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.generator.sclibrary.SCLibraryGen;import com.sun.electric.tool.user.User;import java.awt.Frame;import java.awt.GraphicsEnvironment;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import javax.swing.DefaultListModel;import javax.swing.JList;import javax.swing.ListSelectionModel;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** * Class to handle the "Cell Properties" dialog. */public class CellProperties extends EDialog{ private JList cellList; private DefaultListModel cellListModel; private HashMap<Cell,PerCellValues> origValues; private boolean changing = false; private static class PerCellValues { TempPref disAllMod; TempPref disInstMod; TempPref inCellLib; TempPref useTechEditor; TempPref defExpanded; TempPref frameSize; TempPref designerName; TempPref technologyName; TempPref textCellFont; TempPref textCellSize; private PerCellValues(Cell cell) { // remember the cell's toggle flags disAllMod = TempPref.makeBooleanPref(cell.isAllLocked()); disInstMod = TempPref.makeBooleanPref(cell.isInstancesLocked()); inCellLib = TempPref.makeBooleanPref(SCLibraryGen.isStandardCell(cell)); useTechEditor = TempPref.makeBooleanPref(cell.isInTechnologyLibrary()); defExpanded = TempPref.makeBooleanPref(cell.isWantExpanded()); // remember the frame size String fSize = cell.getVarValue(User.FRAME_SIZE, String.class, ""); frameSize = TempPref.makeStringPref(fSize); // remember the designer name String dName = cell.getVarValue(User.FRAME_DESIGNER_NAME, String.class, ""); designerName = TempPref.makeStringPref(dName); // remember the technology String tName = cell.getTechnology().getTechName(); technologyName = TempPref.makeStringPref(tName); // remember text cell font/size String fontName = cell.getVarValue(Cell.TEXT_CELL_FONT_NAME, String.class, "DEFAULT FONT"); textCellFont = TempPref.makeStringPref(fontName); int fontSize = cell.getVarValue(Cell.TEXT_CELL_FONT_SIZE, Integer.class, new Integer(User.getDefaultTextCellSize())).intValue(); textCellSize = TempPref.makeIntPref(fontSize); } } /** Creates new form Cell Properties */ public CellProperties(Frame parent) { super(parent, true); initComponents(); // cache all information origValues = new HashMap<Cell,PerCellValues>(); // build the cell list cellListModel = new DefaultListModel(); cellList = new JList(cellListModel); cellList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); cellPane.setViewportView(cellList); cellList.addListSelectionListener(new javax.swing.event.ListSelectionListener() { public void valueChanged(javax.swing.event.ListSelectionEvent evt) { cellListClick(); } }); // build the technology popup for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext();) { Technology tech = it.next(); whichTechnology.addItem(tech.getTechName()); } // build the font popup GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); String [] fontNames = ge.getAvailableFontFamilyNames(); textCellFont.addItem("DEFAULT FONT"); for(int i=0; i<fontNames.length; i++) textCellFont.addItem(fontNames[i]); // initialize frame information frameSize.addItem("None"); frameSize.addItem("Half-A-Size"); frameSize.addItem("A-Size"); frameSize.addItem("B-Size"); frameSize.addItem("C-Size"); frameSize.addItem("D-Size"); frameSize.addItem("E-Size"); // make a popup of libraries List<Library> libList = Library.getVisibleLibraries(); for(Library lib : libList) { libraryPopup.addItem(lib.getName()); } int curIndex = libList.indexOf(Library.getCurrent()); if (curIndex >= 0) libraryPopup.setSelectedIndex(curIndex); frameDesigner.getDocument().addDocumentListener(new TextFieldListener(this)); textCellSize.getDocument().addDocumentListener(new TextFieldListener(this)); loadCellList(); finishInitialization(); } protected void escapePressed() { cancel(null); } /** * Method called when the library popup changes. * Reloads the list of cells. */ private void loadCellList() { String libName = (String)libraryPopup.getSelectedItem(); Library lib = Library.findLibrary(libName); if (lib == null) return; boolean any = false; cellListModel.clear(); for(Iterator<Cell> it = lib.getCells(); it.hasNext(); ) { Cell cell = it.next(); cellListModel.addElement(cell.noLibDescribe()); any = true; } if (any) { Library curLib = Library.getCurrent(); if (lib == curLib && Job.getUserInterface().getCurrentCell(curLib) != null) { cellList.setSelectedValue(Job.getUserInterface().getCurrentCell(curLib).noLibDescribe(), true); } else { cellList.setSelectedIndex(0); } } else { cellList.setSelectedValue(null, false); } cellListClick(); } /** * Method to figure out the current cell. * Examines the library popup and the cell list. * @return the current cell (null if none). */ private Cell getSelectedCell() { String libName = (String)libraryPopup.getSelectedItem(); Library lib = Library.findLibrary(libName); String cellName = (String)cellList.getSelectedValue(); if (cellName == null) return null; Cell cell = lib.findNodeProto(cellName); return cell; } /** * Lazy caching */ private PerCellValues getPCV(Cell cell) { PerCellValues pcv = origValues.get(cell); if (pcv == null) { pcv = new PerCellValues(cell); origValues.put(cell, pcv); } return pcv; } /** * Method called when a cell name is clicked in the list. * Updates the displayed values for that cell. */ private void cellListClick() { Cell cell = getSelectedCell(); if (cell == null) return; PerCellValues pcv = getPCV(cell); if (pcv == null) return; changing = true; disallowModAnyInCell.setSelected(pcv.disAllMod.getBoolean()); disallowModInstInCell.setSelected(pcv.disInstMod.getBoolean()); partOfCellLib.setSelected(pcv.inCellLib.getBoolean()); useTechEditor.setSelected(pcv.useTechEditor.getBoolean()); expandNewInstances.setSelected(pcv.defExpanded.getBoolean()); frameDesigner.setText(pcv.designerName.getString()); whichTechnology.setSelectedItem(pcv.technologyName.getString()); textCellFont.setSelectedItem(pcv.textCellFont.getString()); textCellSize.setText(Integer.toString(pcv.textCellSize.getInt())); frameSize.setSelectedIndex(0); frameLandscape.setSelected(true); frameTitleBox.setSelected(false); String fs = pcv.frameSize.getString(); if (fs.length() > 0) { char chr = fs.charAt(0); if (chr == 'h') frameSize.setSelectedIndex(1); else if (chr == 'a') frameSize.setSelectedIndex(2); else if (chr == 'b') frameSize.setSelectedIndex(3); else if (chr == 'c') frameSize.setSelectedIndex(4); else if (chr == 'd') frameSize.setSelectedIndex(5); else if (chr == 'e') frameSize.setSelectedIndex(6); frameTitleBox.setSelected(true); for(int i=1; i< fs.length(); i++) { chr = fs.charAt(i); if (chr == 'v') framePortrait.setSelected(true); else if (chr == 'n') frameTitleBox.setSelected(false); } } changing = false; } /** * Class to handle special changes to characteristic spacing. */ private static class TextFieldListener implements DocumentListener { CellProperties dialog; TextFieldListener(CellProperties dialog) { this.dialog = dialog; } public void changedUpdate(DocumentEvent e) { dialog.textInfoChanged(); } public void insertUpdate(DocumentEvent e) { dialog.textInfoChanged(); } public void removeUpdate(DocumentEvent e) { dialog.textInfoChanged(); } } private void textInfoChanged() { if (changing) return; Cell cell = getSelectedCell(); if (cell == null) return; PerCellValues pcv = getPCV(cell); if (pcv == null) return; // get current text fields pcv.designerName.setString(frameDesigner.getText()); pcv.textCellSize.setInt(TextUtils.atoi(textCellSize.getText())); } private void frameInfoChanged() { if (changing) return; Cell cell = getSelectedCell(); if (cell == null) return; PerCellValues pcv = getPCV(cell); if (pcv == null) return; // get current cell frame information String currentFrameSize = ""; int index = frameSize.getSelectedIndex(); if (index > 0) { switch (index) { case 1: currentFrameSize = "h"; break; case 2: currentFrameSize = "a"; break; case 3: currentFrameSize = "b"; break; case 4: currentFrameSize = "c"; break; case 5: currentFrameSize = "d"; break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -