📄 layerstab.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: LayersTab.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.options;import com.sun.electric.database.geometry.EGraphics;import com.sun.electric.database.text.TextUtils;import com.sun.electric.technology.Layer;import com.sun.electric.technology.Technology;import com.sun.electric.tool.user.Resources;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.ColorPatternPanel;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Color;import java.awt.Frame;import java.awt.GridBagConstraints;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.Collections;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.swing.JPanel;/** * Class to handle the "Colors and Layers" tab of the Preferences dialog. */public class LayersTab extends PreferencePanel{ private Map<Layer,ColorPatternPanel.Info> layerMap; private Map<String,ColorPatternPanel.Info> transAndSpecialMap; private Map<User.ColorPrefType, String> nameTypeSpecialMap; private Map<Technology,Color []> colorMapMap; private ColorPatternPanel colorAndPatternPanel; private void resetColorPanelInfo(ColorPatternPanel.Info cpi) { int factoryColor = -1; if (cpi.graphics != null) { cpi.useStippleDisplay = cpi.graphics.isFactoryPatternedOnDisplay(); cpi.useStipplePrinter = cpi.graphics.isFactoryPatternedOnPrinter(); cpi.outlinePatternDisplay = cpi.graphics.getFactoryOutlined(); cpi.transparentLayer = cpi.graphics.getFactoryTransparentLayer(); cpi.pattern = cpi.graphics.getFactoryPattern(); cpi.opacity = cpi.graphics.getFactoryOpacity(); factoryColor = cpi.graphics.getFactoryColor(); // color given by graphics for the rest of layers } else factoryColor = cpi.theColor.getIntFactoryValue(); // factory color for special layers cpi.red = (factoryColor>>16) & 0xFF; cpi.green = (factoryColor>>8) & 0xFF; cpi.blue = factoryColor & 0xFF; } /** Creates new form LayerTab */ public LayersTab(Frame parent, boolean modal) { super(parent, modal); initComponents(); // make the color/pattern panel colorAndPatternPanel = new ColorPatternPanel(true); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.weightx = 1; gbc.weighty = 1; gbc.gridwidth = 4; gbc.gridheight = 1; gbc.insets = new java.awt.Insets(4, 4, 4, 4); layers.add(colorAndPatternPanel, gbc); layerMap = new HashMap<Layer,ColorPatternPanel.Info>(); transAndSpecialMap = new HashMap<String,ColorPatternPanel.Info>(); nameTypeSpecialMap = new HashMap<User.ColorPrefType, String>(); colorMapMap = new HashMap<Technology,Color []>(); layerName.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { layerSelected(); } }); for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext(); ) { Technology tech = it.next(); technology.addItem(tech.getTechName()); } technology.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { setTechnology(); } }); } /** return the panel to use for this preferences tab. */ public JPanel getPanel() { return layers; } /** return the name of this preferences tab. */ public String getName() { return "Layers"; } /** * Method called at the start of the dialog. * Caches current values and displays them in the tab. */ public void init() { // make a map of all layers for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext(); ) { Technology tech = it.next(); for(Iterator<Layer> lIt = tech.getLayers(); lIt.hasNext(); ) { Layer layer = lIt.next(); if (layer.isPseudoLayer() && layer.getNonPseudoLayer() != layer) continue; layerName.addItem(layer.getName()); ColorPatternPanel.Info li = new ColorPatternPanel.Info(layer.getGraphics()); layerMap.put(layer, li); } // make an entry for the technology's color map Color [] map = new Color[tech.getNumTransparentLayers()]; Color [] fullMap = tech.getColorMap(); for(int i=0; i<map.length; i++) map[i] = fullMap[1<<i]; colorMapMap.put(tech, map); } // add the special layers nameTypeSpecialMap.put(User.ColorPrefType.BACKGROUND, "Special: BACKGROUND"); nameTypeSpecialMap.put(User.ColorPrefType.GRID, "Special: GRID"); nameTypeSpecialMap.put(User.ColorPrefType.HIGHLIGHT, "Special: HIGHLIGHT"); nameTypeSpecialMap.put(User.ColorPrefType.NODE_HIGHLIGHT, "Special: NODE HIGHLIGHT"); nameTypeSpecialMap.put(User.ColorPrefType.MOUSEOVER_HIGHLIGHT, "Special: MOUSE-OVER HIGHLIGHT"); nameTypeSpecialMap.put(User.ColorPrefType.PORT_HIGHLIGHT, "Special: PORT HIGHLIGHT"); nameTypeSpecialMap.put(User.ColorPrefType.TEXT, "Special: TEXT"); nameTypeSpecialMap.put(User.ColorPrefType.INSTANCE, "Special: INSTANCE OUTLINES"); nameTypeSpecialMap.put(User.ColorPrefType.ARTWORK, "Special: DEFAULT ARTWORK"); nameTypeSpecialMap.put(User.ColorPrefType.DOWNINPLACEBORDER, "Special: DOWN-IN-PLACE BORDER"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_BACKGROUND, "Special: WAVEFORM BACKGROUND"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_FOREGROUND, "Special: WAVEFORM FOREGROUND"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_STIMULI, "Special: WAVEFORM STIMULI"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_OFF_STRENGTH, "Special: WAVEFORM OFF STRENGTH"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_NODE_STRENGTH, "Special: WAVEFORM NODE (WEAK) STRENGTH"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_GATE_STRENGTH, "Special: WAVEFORM GATE STRENGTH"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_POWER_STRENGTH, "Special: WAVEFORM POWER STRENGTH"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_CROSS_LOW, "Special: WAVEFORM CROSSPROBE LOW"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_CROSS_HIGH, "Special: WAVEFORM CROSSPROBE HIGH"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_CROSS_UNDEF, "Special: WAVEFORM CROSSPROBE UNDEFINED"); nameTypeSpecialMap.put(User.ColorPrefType.WAVE_CROSS_FLOAT, "Special: WAVEFORM CROSSPROBE FLOATING"); for (User.ColorPrefType type : User.ColorPrefType.values()) { transAndSpecialMap.put(nameTypeSpecialMap.get(type), new ColorPatternPanel.Info(User.getColorPref(type))); } // 3D Stuff try { Class<?> j3DUtilsClass = Resources.get3DClass("utils.J3DUtils"); if (j3DUtilsClass != null) { Method setMethod = j3DUtilsClass.getDeclaredMethod("get3DColorsInTab", new Class[] {Map.class}); setMethod.invoke(j3DUtilsClass, new Object[]{transAndSpecialMap}); } else System.out.println("Cannot call 3D plugin method get3DColorsInTab"); } catch (Exception e) { System.out.println("Cannot call 3D plugin method get3DColorsInTab"); e.printStackTrace(); } technology.setSelectedItem(Technology.getCurrent().getTechName()); } /** * Method called when the Technology popup changes. */ private void setTechnology() { String techName = (String)technology.getSelectedItem(); Technology tech = Technology.findTechnology(techName); if (tech == null) return; // report the map for the technology Color [] map = colorMapMap.get(tech); colorAndPatternPanel.setColorMap(map); layerName.removeAllItems(); // add all layers in the technology for(Iterator<Layer> lIt = tech.getLayers(); lIt.hasNext(); ) { Layer layer = lIt.next(); if (layer.isPseudoLayer() && layer.getNonPseudoLayer() != layer) continue; layerName.addItem(layer.getName()); } // add special layer names List<String> specialList = new ArrayList<String>(); for(String name : transAndSpecialMap.keySet()) specialList.add(name); Collections.sort(specialList, TextUtils.STRING_NUMBER_ORDER); for(String name : specialList) { layerName.addItem(name); } layerSelected(); } /** * Method called when the Layer popup changes. */ private void layerSelected() { String techName = (String)technology.getSelectedItem(); Technology tech = Technology.findTechnology(techName); if (tech == null) return; String name = (String)layerName.getSelectedItem(); ColorPatternPanel.Info li = transAndSpecialMap.get(name); Layer layer = null; if (li == null) { layer = tech.findLayer(name); li = layerMap.get(layer); } if (li == null) return; colorAndPatternPanel.setColorPattern(li); // see if this layer is transparent and shares with another layer String otherLayers = null; if (li.transparentLayer > 0 && layer != null) { for(Iterator<Layer> it = tech.getLayers(); it.hasNext(); ) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -