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

📄 printingtab.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: PrintingTab.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.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.text.TextUtils;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.io.IOTool;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.Iterator;import javax.swing.JPanel;/** * Class to handle the "Printing" tab of the Preferences dialog. */public class PrintingTab extends PreferencePanel{	/** Creates new form PrintingTab */	public PrintingTab(java.awt.Frame parent, boolean modal)	{		super(parent, modal);		initComponents();		// make all text fields select-all when entered	    EDialog.makeTextFieldSelectAllOnTab(printResolution);	    EDialog.makeTextFieldSelectAllOnTab(printLineWidth);	    EDialog.makeTextFieldSelectAllOnTab(printWidth);	    EDialog.makeTextFieldSelectAllOnTab(printHeight);	    EDialog.makeTextFieldSelectAllOnTab(printMargin);	    EDialog.makeTextFieldSelectAllOnTab(printEPSScale);	    EDialog.makeTextFieldSelectAllOnTab(printSyncFileName);	}	/** return the panel to use for this preferences tab. */	public JPanel getPanel() { return printing; }	/** return the name of this preferences tab. */	public String getName() { return "Printing"; }	private Cell initialCell;	private double initialEPSScale;	private String initialEPSSyncFile;	/**	 * Method called at the start of the dialog.	 * Caches current values and displays them in the Printing tab.	 */	public void init()	{		// general printing		switch (IOTool.getPlotArea())		{			case 0: printPlotEntireCell.setSelected(true);        break;			case 1: printPlotHighlightedArea.setSelected(true);   break;			case 2: printPlotDisplayedWindow.setSelected(true);   break;		}		printResolution.setText(Integer.toString(IOTool.getPrintResolution()));		printEncapsulated.setSelected(IOTool.isPrintEncapsulated());		printPlotDateInCorner.setSelected(IOTool.isPlotDate());		if (IOTool.isPrintForPlotter()) printUsePlotter.setSelected(true); else			printUsePrinter.setSelected(true);		printWidth.setText(TextUtils.formatDouble(IOTool.getPrintWidth()));		printHeight.setText(TextUtils.formatDouble(IOTool.getPrintHeight()));		printMargin.setText(TextUtils.formatDouble(IOTool.getPrintMargin()));		printLineWidth.setText(TextUtils.formatDouble(IOTool.getPrintPSLineWidth()));		printRotation.addItem("No Rotation");		printRotation.addItem("Rotate plot 90 degrees");		printRotation.addItem("Auto-rotate plot to fit");		printRotation.setSelectedIndex(IOTool.getPrintRotation());		printPostScriptStyle.addItem("Black&White");		printPostScriptStyle.addItem("Color");		printPostScriptStyle.addItem("Color Stippled");		printPostScriptStyle.addItem("Color Merged");		printPostScriptStyle.setSelectedIndex(IOTool.getPrintColorMethod());		initialCell = WindowFrame.getCurrentCell();		initialEPSScale = 1;		initialEPSSyncFile = "";		if (initialCell != null)		{			printCellName.setText("For: " + initialCell);			initialEPSScale = IOTool.getPrintEPSScale(initialCell);			initialEPSSyncFile = IOTool.getPrintEPSSynchronizeFile(initialCell);			printSyncFileName.setText(initialEPSSyncFile);			printSetEPSSync.addActionListener(new ActionListener()			{				public void actionPerformed(ActionEvent evt) { printSetEPSSyncActionPerformed(); }			});		} else		{			printCellName.setEnabled(false);			printEPSScaleLabel.setEnabled(false);			printEPSScale.setEditable(false);			printSynchLabel.setEnabled(false);			printSyncFileName.setEditable(false);			printSetEPSSync.setEnabled(false);		}		printEPSScale.setText(TextUtils.formatDouble(initialEPSScale));	}	private void printSetEPSSyncActionPerformed()	{		String defaultFileName = initialCell.getName() + ".eps";		String fileName = OpenFile.chooseOutputFile(FileType.POSTSCRIPT, "Choose EPS file", defaultFileName);		if (fileName == null) return;		printSyncFileName.setText(fileName);	}	/**	 * Method called when the "OK" panel is hit.	 * Updates any changed fields in the Printing tab.	 */	public void term()	{		// general printing		int currInt = 0;		if (printPlotHighlightedArea.isSelected()) currInt = 1; else			if (printPlotDisplayedWindow.isSelected()) currInt = 2;		if (currInt != IOTool.getPlotArea())			IOTool.setPlotArea(currInt);		currInt = TextUtils.atoi(printResolution.getText());		if (currInt != IOTool.getPrintResolution())			IOTool.setPrintResolution(currInt);		// postScript		boolean currBoolean = printPlotDateInCorner.isSelected();		if (currBoolean != IOTool.isPlotDate())			IOTool.setPlotDate(currBoolean);		currBoolean = printEncapsulated.isSelected();		if (currBoolean != IOTool.isPrintEncapsulated())			IOTool.setPrintEncapsulated(currBoolean);		currBoolean = printUsePlotter.isSelected();		if (currBoolean != IOTool.isPrintForPlotter())			IOTool.setPrintForPlotter(currBoolean);		double currDouble = TextUtils.atof(printWidth.getText());		if (currDouble != IOTool.getPrintWidth())			IOTool.setPrintWidth(currDouble);		currDouble = TextUtils.atof(printHeight.getText());		if (currDouble != IOTool.getPrintHeight())			IOTool.setPrintHeight(currDouble);		currDouble = TextUtils.atof(printMargin.getText());		if (currDouble != IOTool.getPrintMargin())			IOTool.setPrintMargin(currDouble);		currDouble = TextUtils.atof(printLineWidth.getText());		if (currDouble != IOTool.getPrintPSLineWidth())			IOTool.setPrintPSLineWidth(currDouble);		currInt = printRotation.getSelectedIndex();		if (currInt != IOTool.getPrintRotation())			IOTool.setPrintRotation(currInt);		currInt = printPostScriptStyle.getSelectedIndex();		if (currInt != IOTool.getPrintColorMethod())			IOTool.setPrintColorMethod(currInt);		if (initialCell != null)		{			currDouble = TextUtils.atof(printEPSScale.getText());			if (currDouble != initialEPSScale && currDouble != 0)				IOTool.setPrintEPSScale(initialCell, currDouble);			String currentEPSSyncFile = printSyncFileName.getText();			if (!currentEPSSyncFile.equals(initialEPSSyncFile))				IOTool.setPrintEPSSynchronizeFile(initialCell, currentEPSSyncFile);		}	}	/**	 * Method called when the factory reset is requested.	 */	public void reset()	{		if (IOTool.getFactoryPlotArea() != IOTool.getPlotArea())			IOTool.setPlotArea(IOTool.getFactoryPlotArea());		if (IOTool.getFactoryPrintResolution() != IOTool.getPrintResolution())			IOTool.setPrintResolution(IOTool.getFactoryPrintResolution());		if (IOTool.isFactoryPrintEncapsulated() != IOTool.isPrintEncapsulated())			IOTool.setPrintEncapsulated(IOTool.isFactoryPrintEncapsulated());		if (IOTool.isFactoryPlotDate() != IOTool.isPlotDate())			IOTool.setPlotDate(IOTool.isFactoryPlotDate());		if (IOTool.isFactoryPrintForPlotter() != IOTool.isPrintForPlotter())			IOTool.setPrintForPlotter(IOTool.isFactoryPrintForPlotter());		if (IOTool.getFactoryPrintWidth() != IOTool.getPrintWidth())			IOTool.setPrintWidth(IOTool.getFactoryPrintWidth());		if (IOTool.getFactoryPrintHeight() != IOTool.getPrintHeight())			IOTool.setPrintHeight(IOTool.getFactoryPrintHeight());		if (IOTool.getFactoryPrintMargin() != IOTool.getPrintMargin())			IOTool.setPrintMargin(IOTool.getFactoryPrintMargin());		if (IOTool.getFactoryPrintPSLineWidth() != IOTool.getPrintPSLineWidth())			IOTool.setPrintPSLineWidth(IOTool.getFactoryPrintPSLineWidth());		if (IOTool.getFactoryPrintRotation() != IOTool.getPrintRotation())			IOTool.setPrintRotation(IOTool.getFactoryPrintRotation());		if (IOTool.getFactoryPrintColorMethod() != IOTool.getPrintColorMethod())			IOTool.setPrintColorMethod(IOTool.getFactoryPrintColorMethod());		for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )		{			Library lib = it.next();			for(Iterator<Cell> cIt = lib.getCells(); cIt.hasNext(); )			{				Cell cell = cIt.next();				if (IOTool.getPrintEPSScale(cell) != 1)					IOTool.setPrintEPSScale(cell, 1);				if (IOTool.getPrintEPSSynchronizeFile(cell).length() > 0)					IOTool.setPrintEPSSynchronizeFile(cell, "");			}		}	}	/** 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;        printingPlotArea = new javax.swing.ButtonGroup();        printingPlotOrPrint = new javax.swing.ButtonGroup();        printing = new javax.swing.JPanel();        jPanel4 = new javax.swing.JPanel();        printPlotEntireCell = new javax.swing.JRadioButton();        printPlotHighlightedArea = new javax.swing.JRadioButton();        printPlotDisplayedWindow = new javax.swing.JRadioButton();        jLabel19 = new javax.swing.JLabel();        printResolution = new javax.swing.JTextField();        jPanel6 = new javax.swing.JPanel();        printEncapsulated = new javax.swing.JCheckBox();        printPostScriptStyle = new javax.swing.JComboBox();        printUsePrinter = new javax.swing.JRadioButton();        printUsePlotter = new javax.swing.JRadioButton();        jLabel21 = new javax.swing.JLabel();        printWidth = new javax.swing.JTextField();        jLabel22 = new javax.swing.JLabel();        printHeight = new javax.swing.JTextField();        jLabel23 = new javax.swing.JLabel();        printMargin = new javax.swing.JTextField();        printRotation = new javax.swing.JComboBox();        printCellName = new javax.swing.JLabel();        printEPSScaleLabel = new javax.swing.JLabel();        printEPSScale = new javax.swing.JTextField();        jLabel20 = new javax.swing.JLabel();        jSeparator1 = new javax.swing.JSeparator();        printSyncFileName = new javax.swing.JTextField();        printSynchLabel = new javax.swing.JLabel();        printSetEPSSync = new javax.swing.JButton();        jLabel1 = new javax.swing.JLabel();        printLineWidth = new javax.swing.JTextField();        jLabel2 = new javax.swing.JLabel();        printPlotDateInCorner = new javax.swing.JCheckBox();        getContentPane().setLayout(new java.awt.GridBagLayout());        setTitle("IO Options");        setName("");        addWindowListener(new java.awt.event.WindowAdapter() {            public void windowClosing(java.awt.event.WindowEvent evt) {                closeDialog(evt);            }        });        printing.setLayout(new java.awt.GridBagLayout());

⌨️ 快捷键说明

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