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

📄 renderer2dmodel.java

📁 化学图形处理软件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* $Revision: 7636 $ $Author: egonw $ $Date: 2007-01-04 18:46:10 +0100 (Thu, 04 Jan 2007) $ *  * Copyright (C) 1997-2007  The Chemistry Development Kit (CDK) project *  * Contact: cdk-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.renderer;import java.awt.Color;import java.awt.Dimension;import java.awt.Font;import java.awt.Point;import java.awt.Polygon;import java.util.EventObject;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;import java.util.Vector;import javax.vecmath.Point2d;import org.openscience.cdk.event.ICDKChangeListener;import org.openscience.cdk.interfaces.IAtom;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.interfaces.IBond;import org.openscience.cdk.renderer.color.CDK2DAtomColors;import org.openscience.cdk.renderer.color.IAtomColorer;/** * Model for Renderer2D that contains settings for drawing objects. * * @cdk.module render */public class Renderer2DModel implements java.io.Serializable, Cloneable{        // private LoggingTool logger = new LoggingTool("org.openscience.cdk.render.Renderer2DModel");        private static final long serialVersionUID = -4420308906715213445L;    private double scaleFactor = 60.0;        /** Determines how much the image is zoomed into on. */    private double zoomFactor = 1.0;		private double bondWidth = 2.0;	private double bondDistance = 6.0;	private double bondLength = 36.0;	private Color backColor = Color.white;	private Color foreColor = Color.black;	private Color mappingColor = Color.gray;    	private Color hoverOverColor = Color.lightGray;	private Color selectedPartColor = Color.lightGray;	private Color externalHighlightColor = Color.orange;			private double highlightRadius = 10.0;	private boolean willDrawNumbers = false;		private boolean showAtomTypeNames = false;    private boolean showAtomAtomMapping = true;    private boolean useAntiAliasing = true;        private boolean showReactionBoxes = true;    private boolean showMoleculeTitle = false;	private int atomRadius = 8;		private IAtom highlightedAtom = null;		private IBond highlightedBond = null;	    /**      * The color hash is used to color substructures.     * @see #getColorHash()     */	private Hashtable colorHash = new Hashtable();    private IAtomColorer colorer = new CDK2DAtomColors();		private transient Vector listeners = new Vector();		private Point pointerVectorStart = null;		private Point pointerVectorEnd = null;		private Polygon selectRect = null;		private IAtomContainer selectedPart = null;	private IAtomContainer externalSelectedPart = null;	private IAtomContainer clipboardContent = null;		private Vector lassoPoints = new Vector();        /** Determines wether structures should be drawn as Kekule structures,     *  thus giving each carbon element explicitely, instead of not displaying     *  the element symbol. Example C-C-C instead of /\.     */    private boolean kekuleStructure = false;    /** Determines wether methyl carbons' symbols should be drawn explicit     *  for methyl carbons. Example C/\C instead of /\.      */    private boolean showEndCarbons = false;    /** Determines wether implicit hydrogens should be drawn. */    private boolean showImplicitHydrogens = true;    /** Determines wether implicit hydrogens should be drawn. */    private boolean showExplicitHydrogens = true;    /** Determines wether rings should be drawn with a circle if they are aromatic. */    private boolean showAromaticity = false;    private boolean showAromaticityInCDKStyle = false;    /** Determines wether atoms are colored by type. */    private boolean colorAtomsByType = true;    private Dimension backgroundDimension = new Dimension(794,1123);        private boolean showTooltip = false;        private HashMap toolTipTextMap = new HashMap();        private Font customFont = null;        private boolean compact=false;    	private HashMap merge=new HashMap();		private double[] rotateCenter=null;	private double rotateRadius=0;		private HashMap renderingCoordinates=new HashMap();		private boolean notification = true;		/**	 * Area on each of the four margins to keep white.	 */	private double margin = 0.05;		public void setRenderingCoordinate(IAtom atom, Point2d point){		this.renderingCoordinates.put(atom,point);	}		public Point2d getRenderingCoordinate(IAtom atom){		return (Point2d)this.renderingCoordinates.get(atom);	}		public HashMap getRenderingCoordinates(){		return this.renderingCoordinates;	}        /**     * @return null if no custom font set     */    public Font getFont() {        return customFont;    }        public void setFont(Font font) {        this.customFont = font;        fireChange();    }        public boolean getIsCompact() {        return compact;    }        public void setIsCompact(boolean compact) {        this.compact=compact;    }    public boolean getUseAntiAliasing() {        return useAntiAliasing;    }        public void setUseAntiAliasing(boolean bool) {        this.useAntiAliasing = bool;        fireChange();    }        public boolean getShowReactionBoxes() {        return showReactionBoxes;    }        public void setShowReactionBoxes(boolean bool) {        this.showReactionBoxes = bool;        fireChange();    }        public boolean getShowMoleculeTitle() {        return showMoleculeTitle;    }        public void setShowMoleculeTitle(boolean bool) {        this.showMoleculeTitle = bool;        fireChange();    }        /**     * Returns the active background dimensions, thus applying the zoom     * factor.     *     * @see #getUnzoomedBackgroundDimension     */    public Dimension getBackgroundDimension() {        return new Dimension((int)((double)backgroundDimension.getWidth() * zoomFactor),                             (int)((double)backgroundDimension.getHeight() * zoomFactor));    }        /**     * Returns the unzoomed background dimensions.     *     * @see #getBackgroundDimension     */    public Dimension getUnzoomedBackgroundDimension() {        return backgroundDimension;    }        /**     * Sets the background dimensions in an unzoomed state.     */    public void setBackgroundDimension(Dimension dim) {        this.backgroundDimension = dim;        fireChange();    }    	/**	 * Returns the distance between two lines in a double or triple bond	 *	 * @return     the distance between two lines in a double or triple bond	 */	public double getBondDistance() {		return this.bondDistance;	}	/**	 * Sets the distance between two lines in a double or triple bond	 *	 * @param   bondDistance  the distance between two lines in a double or triple bond	 */	public void setBondDistance(double bondDistance) {		this.bondDistance = bondDistance;        fireChange();	}		/**	 * Returns the thickness of a bond line.	 *	 * @return     the thickness of a bond line	 */	public double getBondWidth()	{		return this.bondWidth;	}	/**	 * Sets the thickness of a bond line.	 *	 * @param   bondWidth  the thickness of a bond line	 */	public void setBondWidth(double bondWidth)	{		this.bondWidth = bondWidth;        fireChange();	}	/**	 * Returns the length of a bond line.	 *	 * @return     the length of a bond line	 */	public double getBondLength()	{		return this.bondLength;	}	/**	 * Sets the length of a bond line.	 *	 * @param   bondLength  the length of a bond line	 */	public void setBondLength(double bondLength)	{		this.bondLength = bondLength;        fireChange();	}		/**	 * A scale factor for the drawing.	 *	 * @return a scale factor for the drawing	 */	public double getScaleFactor()	{		return this.scaleFactor;	}	/**	 * Returns the scale factor for the drawing	 *	 * @param   scaleFactor  the scale factor for the drawing	 */	public void setScaleFactor(double scaleFactor)	{		this.scaleFactor = scaleFactor;        fireChange();	}	/**	 * A zoom factor for the drawing.	 *	 * @return a zoom factor for the drawing	 */	public double getZoomFactor() {		return this.zoomFactor;	}	/**	 * Returns the zoom factor for the drawing.	 *	 * @param   zoomFactor  the zoom factor for the drawing	 */	public void setZoomFactor(double zoomFactor) {		this.zoomFactor = zoomFactor;        fireChange();	}		/**	 * Returns the foreground color for the drawing.	 *	 * @return the foreground color for the drawing    	 */	public Color getForeColor()	{		return this.foreColor;	}	/**	 * Sets the foreground color with which bonds and atoms are drawn	 *	 * @param   foreColor  the foreground color with which bonds and atoms are drawn	 */	public void setForeColor(Color foreColor)	{		this.foreColor = foreColor;        fireChange();	}		/**	 * Returns the background color 	 *	 * @return the background color     	 */	public Color getBackColor()	{		return this.backColor;	}	/**	 * Sets the background color 	 *	 * @param   backColor the background color  	 */	public void setBackColor(Color backColor)	{		this.backColor = backColor;        fireChange();	}    /**     * Returns the atom-atom mapping line color      *     * @return the atom-atom mapping line color          */    public Color getAtomAtomMappingLineColor() {        return this.mappingColor;    }    /**     * Sets the atom-atom mapping line color      *     * @param   mappingColor the atom-atom mapping line color       */    public void setAtomAtomMappingLineColor(Color mappingColor) {        this.mappingColor = mappingColor;        fireChange();    }		/**	 * Returns if the drawing of atom numbers is switched on for this model	 *	 * @return  true if the drawing of atom numbers is switched on for this model   	 */	public boolean drawNumbers()	{		return this.willDrawNumbers;	}	public boolean getKekuleStructure() {		return this.kekuleStructure;	}	public void setKekuleStructure(boolean kekule) {		this.kekuleStructure = kekule;        fireChange();	}    public boolean getColorAtomsByType() {        return this.colorAtomsByType;    }        public void setColorAtomsByType(boolean bool) {        this.colorAtomsByType = bool;        fireChange();    }    public boolean getShowEndCarbons() {        return this.showEndCarbons;    }        public void setShowEndCarbons(boolean showThem) {        this.showEndCarbons = showThem;        fireChange();    }        public boolean getShowImplicitHydrogens() {        return this.showImplicitHydrogens;    }        public void setShowImplicitHydrogens(boolean showThem) {        this.showImplicitHydrogens = showThem;        fireChange();    }        public boolean getShowExplicitHydrogens() {        return this.showExplicitHydrogens;    }        public void setShowExplicitHydrogens(boolean showThem) {        this.showExplicitHydrogens = showThem;        fireChange();    }        public boolean getShowAromaticity() {        return this.showAromaticity;    }        public void setShowAromaticity(boolean showIt) {        this.showAromaticity = showIt;        fireChange();    }        public boolean getShowAromaticityInCDKStyle() {        return this.showAromaticityInCDKStyle;    }        public void setShowAromaticityInCDKStyle(boolean showIt) {        this.showAromaticityInCDKStyle = showIt;        fireChange();    }    	/**	 * Sets if the drawing of atom numbers is switched on for this model.	 *	 * @param   drawNumbers  true if the drawing of atom numbers is to be switched on for this model	 */	public void setDrawNumbers(boolean drawNumbers)	{		this.willDrawNumbers = drawNumbers;        fireChange();	}	/**	 * Returns true if atom numbers are drawn.	 */	public boolean getDrawNumbers() {		return willDrawNumbers;	}	/**	 * Returns the radius around an atoms, for which the atom is 	 * marked highlighted if a pointer device is placed within this radius.	 * 	 * @return The highlight radius for all atoms   	 */	public double getHighlightRadius()	{		return this.highlightRadius;	}	/**	 * Sets the radius around an atoms, for which the atom is 	 * marked highlighted if a pointer device is placed within this radius.	 *	 * @param   highlightRadius  the highlight radius of all atoms	 */	public void setHighlightRadius(double highlightRadius)	{		this.highlightRadius = highlightRadius;        fireChange();	}    /**     * Returns whether Atom-Atom mapping must be shown.     */     public boolean getShowAtomAtomMapping() {         return this.showAtomAtomMapping;     }

⌨️ 快捷键说明

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