⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texttab.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: TextTab.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.text.TextUtils;import com.sun.electric.database.variable.MutableTextDescriptor;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import com.sun.electric.tool.user.ui.EditWindow;import com.sun.electric.tool.user.ui.TextWindow;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.GraphicsEnvironment;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Iterator;import javax.swing.JPanel;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;/** * Class to handle the "Text" tab of the Preferences dialog. */public class TextTab extends PreferencePanel{	private static final String EXTERNALEDITOR_HEADER = "External editor: ";	private static final String EXTERNALEDITOR_NOTSET = "NOT SET";	/** Creates new form TextTab */	public TextTab(java.awt.Frame parent, boolean modal)	{		super(parent, modal);		initComponents();		// make all text fields select-all when entered	    EDialog.makeTextFieldSelectAllOnTab(textPointSize);	    EDialog.makeTextFieldSelectAllOnTab(textUnitSize);	    EDialog.makeTextFieldSelectAllOnTab(textCellSize);	    EDialog.makeTextFieldSelectAllOnTab(textGlobalScale);	    EDialog.makeTextFieldSelectAllOnTab(textWindowScale);	}	/** return the panel to use for this preferences tab. */	public JPanel getPanel() { return text; }	/** return the name of this preferences tab. */	public String getName() { return "Text"; }	private MutableTextDescriptor initialTextNodeDescriptor, currentTextNodeDescriptor;	private MutableTextDescriptor initialTextArcDescriptor, currentTextArcDescriptor;	private MutableTextDescriptor initialTextExportDescriptor, currentTextExportDescriptor;	private MutableTextDescriptor initialTextAnnotationDescriptor, currentTextAnnotationDescriptor;	private MutableTextDescriptor initialTextInstanceDescriptor, currentTextInstanceDescriptor;	private MutableTextDescriptor initialTextCellDescriptor, currentTextCellDescriptor;	private MutableTextDescriptor currentTextDescriptor;	private boolean textValuesChanging = false;	/**	 * Method called at the start of the dialog.	 * Caches current values and displays them in the Text tab.	 */	public void init()	{		for (Iterator<TextDescriptor.Position> it = TextDescriptor.Position.getPositions(); it.hasNext(); )		{			TextDescriptor.Position pos = it.next();			textAnchor.addItem(pos);		}		// get initial descriptors		initialTextNodeDescriptor = MutableTextDescriptor.getNodeTextDescriptor();		initialTextArcDescriptor = MutableTextDescriptor.getArcTextDescriptor();		initialTextExportDescriptor = MutableTextDescriptor.getExportTextDescriptor();		initialTextAnnotationDescriptor = MutableTextDescriptor.getAnnotationTextDescriptor();		initialTextInstanceDescriptor = MutableTextDescriptor.getInstanceTextDescriptor();		initialTextCellDescriptor = MutableTextDescriptor.getCellTextDescriptor();		// get current descriptors (gets changed by dialog)		currentTextNodeDescriptor = MutableTextDescriptor.getNodeTextDescriptor();		currentTextArcDescriptor = MutableTextDescriptor.getArcTextDescriptor();		currentTextExportDescriptor = MutableTextDescriptor.getExportTextDescriptor();		currentTextAnnotationDescriptor = MutableTextDescriptor.getAnnotationTextDescriptor();		currentTextInstanceDescriptor = MutableTextDescriptor.getInstanceTextDescriptor();		currentTextCellDescriptor = MutableTextDescriptor.getCellTextDescriptor();		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();		String [] fontNames = ge.getAvailableFontFamilyNames();		textFace.addItem("DEFAULT FONT");		for(int i=0; i<fontNames.length; i++)		{			textDefaultFont.addItem(fontNames[i]);			textFace.addItem(fontNames[i]);			textCellFont.addItem(fontNames[i]);		}		textDefaultFont.setSelectedItem(User.getDefaultFont());		textCellFont.setSelectedItem(User.getDefaultTextCellFont());		textCellSize.setText(Integer.toString(User.getDefaultTextCellSize()));		String editor = EXTERNALEDITOR_HEADER;		if (User.getDefaultTextExternalEditor().length() == 0) editor += EXTERNALEDITOR_NOTSET; else			editor += User.getDefaultTextExternalEditor();		textExternalEditor.setText(editor);		textGlobalScale.setText(TextUtils.formatDouble(User.getGlobalTextScale() * 100));		EditWindow wnd = EditWindow.getCurrent();		textWindowScale.setText(wnd == null ? "" : TextUtils.formatDouble(wnd.getGlobalTextScale() * 100));				textNodes.setSelected(true);		textButtonChanged();		textNodes.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textArcs.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textPorts.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textAnnotation.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textInstances.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textCellText.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textButtonChanged(); }		});		textPoints.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textUnits.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textItalic.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textBold.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textUnderline.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textFace.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textAnchor.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textNewVisibleInsideCell.addActionListener(new ActionListener()		{			public void actionPerformed(ActionEvent evt) { textValuesChanged(); }		});		textPointSize.getDocument().addDocumentListener(new TextSizeDocumentListener(this));		textUnitSize.getDocument().addDocumentListener(new TextSizeDocumentListener(this));	}	/**	 * Class to handle special changes to text sizes.	 */	private static class TextSizeDocumentListener implements DocumentListener	{		TextTab dialog;		TextSizeDocumentListener(TextTab dialog) { this.dialog = dialog; }		public void changedUpdate(DocumentEvent e) { dialog.textValuesChanged(); }		public void insertUpdate(DocumentEvent e) { dialog.textValuesChanged(); }		public void removeUpdate(DocumentEvent e) { dialog.textValuesChanged(); }	}	private void textValuesChanged()	{		if (textValuesChanging) return;		if (textPoints.isSelected())		{			int size = TextUtils.atoi(textPointSize.getText());			currentTextDescriptor.setAbsSize(size);		} else		{			double size = TextUtils.atof(textUnitSize.getText());			currentTextDescriptor.setRelSize(size);		}	    currentTextDescriptor.setItalic(textItalic.isSelected());        currentTextDescriptor.setBold(textBold.isSelected());        currentTextDescriptor.setUnderline(textUnderline.isSelected());		currentTextDescriptor.setPos((TextDescriptor.Position)textAnchor.getSelectedItem());        currentTextDescriptor.setInterior(textNewVisibleInsideCell.isSelected());		int face = 0;		if (textFace.getSelectedIndex() != 0)		{			TextDescriptor.ActiveFont af = TextDescriptor.ActiveFont.findActiveFont((String)textFace.getSelectedItem());            if (af != null)                face = af.getIndex();		}		currentTextDescriptor.setFace(face);	}	private void textButtonChanged()	{		currentTextDescriptor = null;		if (textNodes.isSelected())		{			currentTextDescriptor = currentTextNodeDescriptor;		} else if (textArcs.isSelected())		{			currentTextDescriptor = currentTextArcDescriptor;		} else if (textPorts.isSelected())		{			currentTextDescriptor = currentTextExportDescriptor;		} else if (textAnnotation.isSelected())		{			currentTextDescriptor = currentTextAnnotationDescriptor;		} else if (textInstances.isSelected())		{			currentTextDescriptor = currentTextInstanceDescriptor;		} else if (textCellText.isSelected())		{			currentTextDescriptor = currentTextCellDescriptor;		}		loadCurrentDescriptorInfo();	}	private void loadCurrentDescriptorInfo()	{		textValuesChanging = true;		TextDescriptor.Size size = currentTextDescriptor.getSize();		if (size.isAbsolute())		{			textPoints.setSelected(true);			textPointSize.setText(Integer.toString((int)size.getSize()));			textUnitSize.setText("");		} else		{			textUnits.setSelected(true);			textUnitSize.setText(TextUtils.formatDouble(size.getSize()));			textPointSize.setText("");		}		textItalic.setSelected(currentTextDescriptor.isItalic());		textBold.setSelected(currentTextDescriptor.isBold());		textUnderline.setSelected(currentTextDescriptor.isUnderline());			textAnchor.setSelectedItem(currentTextDescriptor.getPos());		textValuesChanging = false;		textNewVisibleInsideCell.setSelected(currentTextDescriptor.isInterior());		int face = currentTextDescriptor.getFace();		if (face == 0)		{			textFace.setSelectedIndex(0);		} else		{			String fontName = TextDescriptor.ActiveFont.findActiveFont(face).getName();			ensureComboBoxFont(textFace, fontName);			textFace.setSelectedItem(fontName);		}	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -