From: <sh...@us...> - 2008-11-21 15:06:14
|
Revision: 13181 http://cdk.svn.sourceforge.net/cdk/?rev=13181&view=rev Author: shk3 Date: 2008-11-21 15:06:11 +0000 (Fri, 21 Nov 2008) Log Message: ----------- moved classes to jcp, added module declarations Modified Paths: -------------- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AWTFontManager.java cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AbstractFontManager.java Removed Paths: ------------- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/CDKPopupMenu.java cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/JCPAction2D.java Deleted: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/CDKPopupMenu.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/CDKPopupMenu.java 2008-11-21 14:39:47 UTC (rev 13180) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/controller/CDKPopupMenu.java 2008-11-21 15:06:11 UTC (rev 13181) @@ -1,63 +0,0 @@ -/* $RCSfile$ - * $Author$ - * $Date$ - * $Revision$ - * - * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project - * - * Contact: cdk...@li... - * - * 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 I ask is that proper credit is given for my 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.controller; - -import javax.swing.JPopupMenu; - -import org.openscience.cdk.interfaces.IChemObject; - -/** - * Basically, identical to the JPopupMenu class, except that this menu - * can also contain the source for which it was poped up. - * - * <p>IMPORTANT: The very nature of this design can lead to race conditions. - * It would be better that the Event passed to the popup menu would define - * the IChemObject source. - * - * @author Egon Willighagen <eg...@sc...> - * @cdk.created 2003-07-36 - * @cdk.require swing - * @cdk.module controlold - * @cdk.svnrev $Revision$ - */ -public class CDKPopupMenu extends JPopupMenu { - - private static final long serialVersionUID = -235498895062628065L; - - private IChemObject source; - - public void setSource(IChemObject object) { - this.source = object; - } - - public IChemObject getSource() { - return this.source; - } - -} Modified: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AWTFontManager.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AWTFontManager.java 2008-11-21 14:39:47 UTC (rev 13180) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AWTFontManager.java 2008-11-21 15:06:11 UTC (rev 13181) @@ -3,6 +3,9 @@ import java.awt.Font; import java.util.HashMap; +/** + * @cdk.module render + */ public class AWTFontManager extends AbstractFontManager { public static final String FONT_FAMILY_NAME = "Arial"; Modified: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AbstractFontManager.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AbstractFontManager.java 2008-11-21 14:39:47 UTC (rev 13180) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/AbstractFontManager.java 2008-11-21 15:06:11 UTC (rev 13181) @@ -2,6 +2,9 @@ import java.util.HashMap; +/** + * @cdk.module render + */ public abstract class AbstractFontManager { private HashMap<Double, Integer> scaleToFontSizeMap; Deleted: cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/JCPAction2D.java =================================================================== --- cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/JCPAction2D.java 2008-11-21 14:39:47 UTC (rev 13180) +++ cdk/branches/jchempaint-primary/src/main/org/openscience/cdk/renderer/JCPAction2D.java 2008-11-21 15:06:11 UTC (rev 13181) @@ -1,357 +0,0 @@ -/* - * $RCSfile$ - * $Author: egonw $ - * $Date: 2007-01-04 18:26:00 +0100 (do, 04 jan 2007) $ - * $Revision: 7634 $ - * - * Copyright (C) 1997-2007 The JChemPaint project - * - * Contact: jch...@li... - * - * 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.Container; -import java.awt.event.ActionEvent; -import java.util.Hashtable; - -import javax.swing.AbstractAction; -import javax.swing.JMenuItem; -import javax.swing.JPopupMenu; -import javax.swing.JFrame; - -import org.openscience.cdk.interfaces.IChemObject; -//import org.openscience.cdk.applications.jchempaint.JChemPaintMenuBar; -//import org.openscience.cdk.applications.jchempaint.JChemPaintPanel; -import org.openscience.cdk.controller.CDKPopupMenu; -import org.openscience.cdk.tools.LoggingTool; - -/** - * Superclass of all JChemPaint GUI actions - * - * @cdk.module jchempaint - * @cdk.svnrev $Revision: 9162 $ - * @author steinbeck - */ -public class JCPAction2D extends AbstractAction -{ - - private static final long serialVersionUID = -4056416630614934238L; - - /** - * Description of the Field - */ - public final static String actionSuffix = "Action"; - /** - * Description of the Field - */ - public final static String imageSuffix = "Image"; - /** - * Description of the Field - */ - public final static String labelSuffix = "Label"; - - /** - * Description of the Field - */ - protected static LoggingTool logger = null; - - private Hashtable actions = null; - private Hashtable popupActions = null; - - /** - * Description of the Field - */ - protected String type; - - /** - * Description of the Field - */ - //protected JChemPaintPanel jcpPanel = null; - protected JFrame jcpPanel = null; - - /** - * Is this popup action assiociated with a PopupMenu or not. - */ - private boolean isPopupAction; - - - /** - * Constructor for the JCPAction object - * - *@param jcpPanel Description of the Parameter - *@param type Description of the Parameter - *@param isPopupAction Description of the Parameter - */ - public JCPAction2D(JFrame jcpPanel, String type, boolean isPopupAction) - { - super(); - //logger.debug("JCPAction->type: " + type); - if (JCPAction2D.logger == null) - { - JCPAction2D.logger = new LoggingTool(this); - } - if (this.actions == null) - { - this.actions = new Hashtable(); - } - if (this.popupActions == null) - { - this.popupActions = new Hashtable(); - } - this.type = ""; - this.isPopupAction = isPopupAction; - // this.jcpPanel = jcpPanel; - } - - - /** - * Constructor for the JCPAction object - * - *@param jcpPanel Description of the Parameter - *@param isPopupAction Description of the Parameter - */ - public JCPAction2D(JFrame jcpPanel, boolean isPopupAction) - { - this(jcpPanel, "", isPopupAction); - } - - - /** - * Constructor for the JCPAction object - * - *@param jcpPanel Description of the Parameter - */ - public JCPAction2D(JFrame jcpPanel) - { - this(jcpPanel, false); - } - - - /** - * Constructor for the JCPAction object - */ - public JCPAction2D() - { - this(null); - } - - - /** - * Sets the type attribute of the JCPAction object - * - *@param type The new type value - */ - public void setType(String type) - { - this.type = type; - } - - - /** - * Sets the jChemPaintPanel attribute of the JCPAction object - * - *@param jcpPanel The new jChemPaintPanel value - */ - public void setJChemPaintPanel(JFrame jcpPanel) - { - this.jcpPanel = jcpPanel; - } - - - /** - * Is this action runnable? - * - *@return The enabled value - */ - public boolean isEnabled() - { - return true; - } - - - /** - * Gets the popupAction attribute of the JCPAction object - * - *@return The popupAction value - */ - public boolean isPopupAction() - { - return isPopupAction; - } - - - /** - * Sets the isPopupAction attribute of the JCPAction object - * - *@param isPopupAction The new isPopupAction value - */ - public void setIsPopupAction(boolean isPopupAction) - { - this.isPopupAction = isPopupAction; - } - - - /** - * Dummy method. - * - *@param e Description of the Parameter - */ - public void actionPerformed(ActionEvent e) - { - } - - - /** - * Gets the source attribute of the JCPAction object - * - *@param event Description of the Parameter - *@return The source value - */ - public IChemObject getSource(ActionEvent event) - { - Object source = event.getSource(); - logger.debug("event source: ", source); - if (source instanceof JMenuItem) - { - Container parent = ((JMenuItem) source).getComponent().getParent(); - // logger.debug("event source parent: " + parent); - if (parent instanceof CDKPopupMenu) - { - return ((CDKPopupMenu) parent).getSource(); - } else if (parent instanceof JPopupMenu) - { - // assume that the top menu is indeed a CDKPopupMenu - logger.debug("Submenu... need to recurse into CDKPopupMenu..."); - while (!(parent instanceof CDKPopupMenu)) - { - logger.debug(" Parent instanceof ", parent.getClass().getName()); - if (parent instanceof JPopupMenu) - { - parent = ((JPopupMenu) parent).getInvoker().getParent(); - } /*else if (parent instanceof JChemPaintMenuBar) - { - logger.warn(" Source is MenuBar. MenuBar items don't know about the source"); - return null; - }*/ else - { - logger.error(" Cannot get parent!"); - return null; - } - } - return ((CDKPopupMenu) parent).getSource(); - } - } - return null; - } - - - /** - * Gets the action attribute of the JCPAction class - * - *@param jcpPanel Description of the Parameter - *@param actionname Description of the Parameter - *@param isPopupAction Description of the Parameter - *@return The action value - */ - public JCPAction2D getAction(JFrame jcpPanel, String actionname, boolean isPopupAction) - { - // make sure logger and actions are instantiated - JCPAction2D dummy = new JCPAction2D(jcpPanel); - - // extract type - String type = ""; - String classname = ""; - int index = actionname.indexOf("@"); - if (index >= 0) - { - classname = actionname.substring(0, index); - // FIXME: it should actually properly check whether there are more chars - // than just the "@". - type = actionname.substring(index + 1); - } else - { - classname = actionname; - } - logger.debug("Action class: ", classname); - logger.debug("Action type: ", type); - - // now get actual JCPAction class - if (!isPopupAction && actions.containsKey(actionname)) - { - logger.debug("Taking JCPAction from action cache for:", actionname); - return (JCPAction2D) actions.get(actionname); - } else if (isPopupAction && popupActions.containsKey(actionname)) - { - logger.debug("Taking JCPAction from popup cache for:", actionname); - return (JCPAction2D) popupActions.get(actionname); - } else - { - logger.debug("Loading JCPAction class for:", classname); - Object o = null; - try - { - // because 'this' is static, it cannot be used to get a classloader, - // therefore use logger instead - o = dummy.getClass().getClassLoader().loadClass(classname).newInstance(); - } catch (Exception exc) - { - logger.error("Could not find/instantiate class: ", classname); - logger.debug(exc); - return dummy; - } - if (o instanceof JCPAction2D) - { - JCPAction2D a = (JCPAction2D) o; - a.setJChemPaintPanel(jcpPanel); - if (type.length() > 0) - { - a.setType(type); - } - if (isPopupAction) - { - popupActions.put(actionname, a); - } else - { - actions.put(actionname, a); - } - return a; - } else - { - logger.error("Action is not a JCPAction!"); - } - } - return dummy; - } - - - /** - * Gets the action attribute of the JCPAction class - * - *@param jcpPanel Description of the Parameter - *@param actionname Description of the Parameter - *@return The action value - */ - public JCPAction2D getAction(JFrame jcpPanel, String actionname) - { - return getAction(jcpPanel, actionname, false); - } -} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |