📄 layouttext.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: LayoutText.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.hierarchy.Cell;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.Color;import java.awt.Font;import java.awt.Frame;import java.awt.Graphics2D;import java.awt.GraphicsEnvironment;import java.awt.RenderingHints;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.font.FontRenderContext;import java.awt.font.GlyphVector;import java.awt.font.LineMetrics;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.awt.image.BufferedImage;import java.awt.image.DataBufferByte;import java.awt.image.Raster;import java.util.Iterator;/** * Class to handle the "Layout Text" dialog. */public class LayoutText extends EDialog{ private static int lastSize = 12; private static double lastScale = 1; private static double lastSeparation = 0; private static boolean lastItalic = false; private static boolean lastBold = false; private static boolean lastUnderline = false; private static boolean lastInvertDots = false; private static String lastFont = User.getDefaultFont(); private static String lastLayer = null; private static String lastMessage = null; /** Creates new form Layout Text */ public LayoutText(Frame parent) { super(parent, true); initComponents(); getRootPane().setDefaultButton(ok); // make all text fields select-all when entered EDialog.makeTextFieldSelectAllOnTab(textSize); EDialog.makeTextFieldSelectAllOnTab(textScale); EDialog.makeTextFieldSelectAllOnTab(dotSeparation); textSize.setText(Integer.toString(lastSize)); textScale.setText(TextUtils.formatDouble(lastScale)); dotSeparation.setText(TextUtils.formatDouble(lastSeparation)); textItalic.setSelected(lastItalic); textBold.setSelected(lastBold); textUnderline.setSelected(lastUnderline); invertDots.setSelected(lastInvertDots); for(Iterator<PrimitiveNode> it = Technology.getCurrent().getNodes(); it.hasNext(); ) { PrimitiveNode np = it.next(); if (np.getFunction() == PrimitiveNode.Function.NODE) textLayer.addItem(np.getName()); } if (lastLayer != null) textLayer.setSelectedItem(lastLayer); if (lastMessage != null) textMessage.setText(lastMessage); Font[] fonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); for(int i=0; i<fonts.length; i++) textFont.addItem(fonts[i].getFontName()); if (lastFont != null) textFont.setSelectedItem(lastFont); // have fields update the message display textFont.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateMessageField(); } }); textItalic.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateMessageField(); } }); textBold.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateMessageField(); } }); textSize.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { updateMessageField(); } }); finishInitialization(); } protected void escapePressed() { cancel(null); } /** * Method called when a dialog field has changed, and the message area must be redisplayed. */ private void updateMessageField() { String fontName = (String)textFont.getSelectedItem(); int fontStyle = Font.PLAIN; if (textItalic.isSelected()) fontStyle |= Font.ITALIC; if (textBold.isSelected()) fontStyle |= Font.BOLD; int size = TextUtils.atoi(textSize.getText()); Font theFont = new Font(fontName, fontStyle, size); if (theFont != null) textMessage.setFont(theFont); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; cancel = new javax.swing.JButton(); ok = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); textSize = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); textScale = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); dotSeparation = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); textFont = new javax.swing.JComboBox(); textItalic = new javax.swing.JCheckBox(); textBold = new javax.swing.JCheckBox(); jLabel5 = new javax.swing.JLabel(); textLayer = new javax.swing.JComboBox(); jLabel6 = new javax.swing.JLabel(); textUnderline = new javax.swing.JCheckBox(); textMessage = new javax.swing.JTextArea(); invertDots = new javax.swing.JCheckBox(); getContentPane().setLayout(new java.awt.GridBagLayout()); setTitle("Make Layout Text"); setName(""); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(evt); } }); cancel.setText("Cancel"); cancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancel(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = 2; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(cancel, gridBagConstraints); ok.setText("OK"); ok.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ok(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 8; gridBagConstraints.gridwidth = 2; gridBagConstraints.weightx = 0.5; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(ok, gridBagConstraints); jLabel1.setText("Size (max 63):"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(jLabel1, gridBagConstraints); textSize.setColumns(8); textSize.setText(" "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(textSize, gridBagConstraints); jLabel2.setText("Scale factor:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(jLabel2, gridBagConstraints); textScale.setColumns(8); textScale.setText(" "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(textScale, gridBagConstraints); jLabel3.setText("Dot separation (units):"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(jLabel3, gridBagConstraints); dotSeparation.setColumns(8); dotSeparation.setText(" "); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); getContentPane().add(dotSeparation, gridBagConstraints); jLabel4.setText("Font:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -