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

📄 jchempaintpanel.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* *  $RCSfile$ *  $Author: shk3 $ *  $Date: 2007-06-29 14:15:27 +0200 (Fri, 29 Jun 2007) $ *  $Revision: 8455 $ * *  Copyright (C) 2004-2007  The JChemPaint project * *  Contact: jchempaint-devel@lists.sourceforge.net * *  This program is free software; you can redistribute it and/or *  modify it under the terms of the GNU Lesser General Public License *  as published by the Free Software Foundation; either version 2.1 *  of the License, or (at your option) any later version. *  All we ask is that proper credit is given for our work, which includes *  - but is not limited to - adding the above copyright notice to the beginning *  of your source code files, and to any copyright notice that you may distribute *  with programs based on this work. * *  This program 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 Lesser General Public License for more details. * *  You should have received a copy of the GNU Lesser General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */package org.openscience.cdk.applications.jchempaint;import org.openscience.cdk.ChemFile;import org.openscience.cdk.ChemModel;import org.openscience.cdk.ChemObject;import org.openscience.cdk.ChemSequence;import org.openscience.cdk.applications.jchempaint.action.JCPAction;import org.openscience.cdk.applications.jchempaint.action.SaveAction;import org.openscience.cdk.applications.jchempaint.dialogs.CreateCoordinatesForFileDialog;import org.openscience.cdk.applications.plugin.ICDKEditBus;import org.openscience.cdk.applications.undoredo.ClearAllEdit;import org.openscience.cdk.geometry.GeometryTools;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.interfaces.IMoleculeSet;import org.openscience.cdk.io.IChemObjectReader;import org.openscience.cdk.io.ReaderFactory;import org.openscience.cdk.io.listener.SwingGUIListener;import org.openscience.cdk.renderer.Renderer2DModel;import org.openscience.cdk.tools.LoggingTool;import org.openscience.cdk.tools.manipulator.ChemModelManipulator;import javax.swing.*;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;import javax.swing.filechooser.FileFilter;import javax.swing.undo.UndoManager;import javax.swing.undo.UndoableEditSupport;import javax.vecmath.Point2d;import java.awt.*;import java.awt.event.*;import java.io.File;import java.io.IOException;import java.io.Reader;import java.util.Iterator;import java.util.MissingResourceException;import java.util.StringTokenizer;import java.util.Vector;/** *  JPanel that contains a full JChemPaint program, either viewer or full *  editor. * *@author        steinbeck *@cdk.created       16. Februar 2005 *@cdk.module    jchempaint */public abstract class JChemPaintPanel		 extends JPanel		 implements ChangeListener, ICDKEditBus {	//Static variables hold information if the application is embedded and keep track of instances of JCPPanel	boolean isEmbedded = false;	boolean isOpenedByViewer	= false;	boolean isViewerOnly = false;	static Vector instances = new Vector();	/**	 *  Description of the Field	 */	protected JChemPaintModel jchemPaintModel;	private LoggingTool logger;	private File currentWorkDirectory = null;	private File lastOpenedFile = null;	private File lastSavedFile = null;	private FileFilter currentOpenFileFilter = null;	private FileFilter currentSaveFileFilter = null;	/**	 *  Description of the Field	 */	JPanel mainContainer;    /**     * Holds the toolbar and insert text widget, goes at the top of mainContainer.     */    JPanel topContainer;    /**     * The status bar.     */    StatusBar statusBar;	JChemPaintMenuBar menu;	JToolBar toolBar;    InsertTextPanel insertTextPanel = null;    DrawingPanel drawingPanel;	/**	 *  Description of the Field	 */	public JButton selectButton;	JCPAction jcpaction = null;	/**	 *  Description of the Field	 */	protected File isAlreadyAFile = null;	/**	 *  this is only needed in open action immediately after opening a file	 */	public JChemPaintPanel lastUsedJCPP = null;	/**	 *  remembers last action in toolbar for switching on/off buttons	 *  This is a vector containing only one element, the button last used	 */	public Vector lastAction=new Vector();    Dimension viewerDimension;    //private UndoManager undoManager;    //private UndoableEditSupport undoSupport;    String guiString = "stable";    //we remember the moveButton since this is special    protected JButton moveButton=null;    private JScrollPane scrollPane;    private boolean showscrollbars=true;	/**	 *  Constructor for the JChemPaintPanel object	 */	public JChemPaintPanel() {		this(true);	}	/**	 *  Constructor for the JChemPaintPanel object	 *  @param showscrollbars shall the drawing panel have scrollbars?	 */	public JChemPaintPanel(boolean showscrollbars) {		this.showscrollbars=showscrollbars;		logger = new LoggingTool(this);//        undoManager = new UndoManager();//        undoManager.setLimit(10);//        undoSupport = new UndoableEditSupport();//        undoSupport.addUndoableEditListener(new UndoAdapter(undoManager));        setLayout(new BorderLayout());        mainContainer = new JPanel(new BorderLayout());        topContainer = new JPanel(new BorderLayout());        drawingPanel = new DrawingPanel();		drawingPanel.setOpaque(true);		drawingPanel.setBackground(Color.white);				if(showscrollbars){			scrollPane = new JScrollPane(drawingPanel,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);				mainContainer.add(scrollPane, BorderLayout.CENTER);		}else{			mainContainer.add(drawingPanel,BorderLayout.CENTER);		}		mainContainer.add(topContainer, BorderLayout.NORTH);        add(mainContainer, BorderLayout.CENTER);        //where do 900/400 come frome? doesn't seem to have an effect anyway		//setSize(new Dimension(900, 400));		//setPreferredSize(new Dimension(900, 400));        instances.add(this);	}	/**	 *  Return the JCPAction instance associated with this JCPPanel	 *	 *@return    The jCPAction value	 */	public JCPAction getJCPAction() {		if (jcpaction == null) {			jcpaction = new JCPAction();		}		return jcpaction;	}	/**	 *  Tells if this JCPPanel is part of an embedded program or not.	 *	 *@return    The embedded value	 */	public boolean isEmbedded() {		return isEmbedded;	}	/**	 *  Gets the viewerOnly attribute of the JChemPaintPanel object	 *	 *@return    The viewerOnly value	 */	public boolean isViewerOnly() {		return isViewerOnly;	}	/**	 *  Sets JCP as embedded application	 */	public void setEmbedded() {		isEmbedded = true;	}		/**	 * Returns the value of isOpenedByViewer.	 */	public boolean getIsOpenedByViewer()	{		return isOpenedByViewer;	}	/**	 * Sets the value of isOpenedByViewer.	 * @param isOpenedByViewer The value to assign isOpenedByViewer.	 */	public void setIsOpenedByViewer(boolean isOpenedByViewer)	{		this.isOpenedByViewer = isOpenedByViewer;	}			/**	 *  Sets the viewerOnly attribute of the JChemPaintPanel object	 */	public void setViewerOnly() {		isEmbedded = true;		isViewerOnly = true;	}	/**	 *  Sets JCP as standalone-program	 */	public void setNotEmbedded() {		isEmbedded = false;	}	/**	 *  Returns a vector containing all JFrames containing JCPPanels currently	 *  running	 *	 *@return    Vector of JFrames	 */	public Vector getInstances() {		return instances;	}	/**	 *  Sets the file currently used for saving this Panel.	 *	 *@param  value  The new isAlreadyAFile value	 */	public void setIsAlreadyAFile(File value) {		isAlreadyAFile = value;	}	/**	 *  Returns the file currently used for saving this Panel, null if not yet	 *  saved	 *	 *@return    The currently used file	 */	public File isAlreadyAFile() {		return isAlreadyAFile;	}	/**	 *  Creates a new localized string that can be used as a title for the new	 *  frame.	 *	 *@return    The newFrameName value	 */	public static String getNewFrameName() {		return JCPLocalizationHandler.getInstance().getString("Untitled-") + Integer.toString(instances.size() + 1);	}	public Image takeSnapshot() {		return null;	}	/**	 *  Gets the currentWorkDirectory attribute of the JChemPaintPanel object	 *	 *@return    The currentWorkDirectory value	 */	public File getCurrentWorkDirectory() {		return currentWorkDirectory;	}	/**	 *  Sets the currentWorkDirectory attribute of the JChemPaintPanel object	 *	 *@param  cwd  The new currentWorkDirectory value	 */	public void setCurrentWorkDirectory(File cwd) {		this.currentWorkDirectory = cwd;	}	/**	 *  Gets the currentOpenFileFilter attribute of the JChemPaintPanel object	 *	 *@return    The currentOpenFileFilter value	 */	public FileFilter getCurrentOpenFileFilter() {		return currentOpenFileFilter;	}	/**	 *  Sets the currentOpenFileFilter attribute of the JChemPaintPanel object	 *	 *@param  ff  The new currentOpenFileFilter value	 */	public void setCurrentOpenFileFilter(FileFilter ff) {		this.currentOpenFileFilter = ff;	}	/**	 *  Gets the currentSaveFileFilter attribute of the JChemPaintPanel object	 *	 *@return    The currentSaveFileFilter value	 */	public FileFilter getCurrentSaveFileFilter() {		return currentSaveFileFilter;	}	/**	 *  Sets the currentSaveFileFilter attribute of the JChemPaintPanel object	 *	 *@param  ff  The new currentSaveFileFilter value	 */	public void setCurrentSaveFileFilter(FileFilter ff) {		this.currentSaveFileFilter = ff;	}	/**	 *  Gets the lastOpenedFile attribute of the JChemPaintPanel object	 *	 *@return    The lastOpenedFile value	 */	public File getLastOpenedFile() {		return lastOpenedFile;	}	/**	 *  Sets the lastOpenedFile attribute of the JChemPaintPanel object	 *	 *@param  lof  The new lastOpenedFile value	 */	public void setLastOpenedFile(File lof) {		this.lastOpenedFile = lof;	}	/**	 *  Gets the lastSavedFile attribute of the JChemPaintPanel object	 *	 *@return    The lastSavedFile value	 */	public File getLastSavedFile() {		return lastSavedFile;	}

⌨️ 快捷键说明

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