From: <sh...@us...> - 2008-12-04 11:54:56
|
Revision: 13461 http://cdk.svn.sourceforge.net/cdk/?rev=13461&view=rev Author: shk3 Date: 2008-12-04 11:54:51 +0000 (Thu, 04 Dec 2008) Log Message: ----------- most of the applet parameters are handled properly Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2008-12-04 11:14:33 UTC (rev 13460) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2008-12-04 11:54:51 UTC (rev 13461) @@ -35,13 +35,19 @@ import java.io.StringReader; import java.io.StringWriter; import java.net.URL; +import java.util.Iterator; +import java.util.List; +import java.util.StringTokenizer; import javax.swing.JApplet; import javax.vecmath.Vector2d; import org.openscience.cdk.ChemModel; import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.controller.IControllerModel; import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.interfaces.IAtom; +import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.ISimpleChemObjectReader; @@ -49,7 +55,10 @@ import org.openscience.cdk.io.MDLWriter; import org.openscience.cdk.io.ReaderFactory; import org.openscience.cdk.layout.StructureDiagramGenerator; +import org.openscience.cdk.renderer.Renderer2DModel; import org.openscience.cdk.smiles.SmilesParser; +import org.openscience.cdk.tools.CDKHydrogenAdder; +import org.openscience.cdk.tools.manipulator.ChemModelManipulator; import org.openscience.jchempaint.AbstractJChemPaintPanel; import org.openscience.jchempaint.InsertTextPanel; import org.openscience.jchempaint.action.CreateSmilesAction; @@ -71,13 +80,13 @@ { "atomNumbersVisible", "true or false", "should atom numbers be shown"}, { "load", "url", "URL of the chemical data" }, { "compact", "true or false", "compact means elements shown as dots, no figures etc. (default false)"}, - { "tooltips", "string like 'atomumber|test|atomnumber|text", "the texts will be used as tooltips for the respective atoms (leave out if none required"}, + { "tooltips", "string like 'atomumber|test|atomnumber|text'", "the texts will be used as tooltips for the respective atoms (leave out if none required"}, { "impliciths", "true or false", "the implicit hs will be added from start (default false)"}, - { "spectrumRenderer", "string", "name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom"}, - { "hightlightTable", "true or false", "if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableid$atomnumber (default false)"}, + { "spectrumRenderer", "string", "TODO name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom"}, + { "hightlightTable", "true or false", "TODO if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableid$atomnumber (default false)"}, { "smiles", "string", "a structure to load as smiles"}, { "scrollbars", "true or false", "if the molecule is too big to be displayed in normal size, shall scrollbars be used (default) or the molecule be resized - only for viewer applet"}, - { "detachable", "true or false", "should the applet be detacheable by a double click (default false)"} + { "detachable", "true or false", "TODO should the applet be detacheable by a double click (default false)"} }; @Override @@ -109,94 +118,7 @@ // jcpp.registerModel(theModel); // if(detacheable) // jcpp.addFilePopUpMenu(); -// if(getParameter("compact")!=null && getParameter("compact").equals("true")){ -// theModel.getRendererModel().setIsCompact(true); // } -// if(getParameter("impliciths")!=null && getParameter("impliciths").equals("false")){ -// theModel.getControllerModel().setAutoUpdateImplicitHydrogens(false); -// theModel.getRendererModel().setShowImplicitHydrogens(false); -// theModel.getRendererModel().setShowEndCarbons(false); -// }else{ -// theModel.getControllerModel().setAutoUpdateImplicitHydrogens(true); -// theModel.getRendererModel().setShowImplicitHydrogens(true); -// theModel.getRendererModel().setShowEndCarbons(true); -// -// HydrogenAdder hydrogenAdder = new HydrogenAdder("org.openscience.cdk.tools.ValencyChecker"); -// if(theModel.getChemModel()!=null && theModel.getChemModel().getMoleculeSet()!=null){ -// java.util.Iterator mols = theModel.getChemModel().getMoleculeSet().molecules(); -// while (mols.hasNext()) -// { -// org.openscience.cdk.interfaces.IMolecule molecule = (IMolecule)mols.next(); -// if (molecule != null) -// -// { -// try{ -// hydrogenAdder.addImplicitHydrogensToSatisfyValency(molecule); -// }catch(Exception ex){ -// //do nothing -// } -// } -// } -// } -// -// } -// if(getParameter("tooltips")!=null){ -// StringTokenizer st=new StringTokenizer(getParameter("tooltips"),"|"); -// IAtomContainer container = theModel.getChemModel().getBuilder().newAtomContainer(); -// Iterator containers = ChemModelManipulator.getAllAtomContainers(theModel.getChemModel()).iterator(); -// while (containers.hasNext()) { -// container.add((IAtomContainer)containers.next()); -// } -// while(st.hasMoreTokens()){ -// IAtom atom = container.getAtom(Integer.parseInt(st.nextToken())-1); -// theModel.getRendererModel().getToolTipTextMap().put(atom,st.nextToken()); -// } -// theModel.getRendererModel().setShowTooltip(true); -// } -// if(theJcpp.getJChemPaintModel()!=null){ -// jcpp.scaleAndCenterMolecule(theModel.getChemModel(),new Dimension((int)this.getSize().getWidth()-100,(int)this.getSize().getHeight()-100)); -// if(theModel.getChemModel().getMoleculeSet()!=null){ -// int smallestX=Integer.MAX_VALUE; -// int largestX=Integer.MIN_VALUE; -// int smallestY=Integer.MAX_VALUE; -// int largestY=Integer.MIN_VALUE; -// for(int i=0;i<theModel.getChemModel().getMoleculeSet().getMoleculeCount();i++){ -// for(int k=0;k<theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtomCount();k++){ -// if(((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).x<smallestX) -// smallestX=(int)((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).x; -// if(((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).x>largestX) -// largestX=(int)((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).x; -// if(((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).y<smallestY) -// smallestY=(int)((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).y; -// if(((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).y>largestY) -// largestY=(int)((Point2d)theModel.getRendererModel().getRenderingCoordinate(theModel.getChemModel().getMoleculeSet().getMolecule(i).getAtom(k))).y; -// } -// } -// if(!theModel.getRendererModel().getIsCompact()){ -// if(jcpp.isShowscrollbars()){ -// int x=largestX-smallestX+30; -// int y=largestY - smallestY+30; -// if(x<300) -// x=300; -// if(y<300) -// y=300; -// //the -60 is to prevent the vertical scrollbar to display even if not needed -// theModel.getRendererModel().setBackgroundDimension(new Dimension(x,y-60)); -// } -// jcpp.scaleAndCenterMolecule(theModel.getChemModel(),theModel.getRendererModel().getBackgroundDimension()); -// }else{ -// theModel.getRendererModel().setBackgroundDimension(new Dimension((int)(.9*this.getSize().getWidth()),(int)(.9*this.getSize().getHeight()))); -// IAtomContainer atomContainer = theModel.getChemModel().getBuilder().newAtomContainer(); -// Iterator containers = ChemModelManipulator.getAllAtomContainers(theModel.getChemModel()).iterator(); -// while (containers.hasNext()) { -// atomContainer.add((IAtomContainer)containers.next()); -// } -// GeometryTools.translateAllPositive(atomContainer,theModel.getRendererModel().getRenderingCoordinates()); -// GeometryTools.scaleMolecule(atomContainer, theModel.getRendererModel().getBackgroundDimension(), 0.8,theModel.getRendererModel().getRenderingCoordinates()); -// GeometryTools.center(atomContainer, theModel.getRendererModel().getBackgroundDimension(),theModel.getRendererModel().getRenderingCoordinates()); -// -// } -// } // } // //embedded means that additional instances can't be created, which is // // needed for applet as well @@ -285,6 +207,9 @@ @Override public void start() { + Renderer2DModel rendererModel = theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel(); + IChemModel chemModel = theJcpp.getChemModel(); + IControllerModel controllerModel = theJcpp.get2DHub().getController2DModel(); //Parameter parsing goes here loadModelFromParam(); String atomNumbers=getParameter("atomNumbersVisible"); @@ -299,6 +224,42 @@ else theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel().setBackColor(new Color(Integer.parseInt(background))); } + if(getParameter("compact")!=null && getParameter("compact").equals("true")){ + theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel().setIsCompact(true); + } + if(getParameter("tooltips")!=null){ + StringTokenizer st=new StringTokenizer(getParameter("tooltips"),"|"); + IAtomContainer container = theJcpp.getChemModel().getBuilder().newAtomContainer(); + Iterator containers = ChemModelManipulator.getAllAtomContainers(theJcpp.getChemModel()).iterator(); + while (containers.hasNext()) { + container.add((IAtomContainer)containers.next()); + } + while(st.hasMoreTokens()){ + IAtom atom = container.getAtom(Integer.parseInt(st.nextToken())-1); + theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel().getToolTipTextMap().put(atom,st.nextToken()); + } + theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel().setShowTooltip(true); + } + if(getParameter("impliciths")!=null && getParameter("impliciths").equals("false")){ + controllerModel.setAutoUpdateImplicitHydrogens(false); + rendererModel.setShowImplicitHydrogens(false); + rendererModel.setShowEndCarbons(false); + }else{ + controllerModel.setAutoUpdateImplicitHydrogens(true); + rendererModel.setShowImplicitHydrogens(true); + rendererModel.setShowEndCarbons(true); + if(chemModel!=null){ + List<IAtomContainer> atomContainers = ChemModelManipulator.getAllAtomContainers(chemModel); + for(int i=0;i<atomContainers.size();i++) + { + try { + CDKHydrogenAdder.getInstance(atomContainers.get(i).getBuilder()).addImplicitHydrogens(atomContainers.get(i)); + } catch (CDKException e) { + //do nothing + } + } + } + } } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2008-12-04 12:22:02
|
Revision: 13463 http://cdk.svn.sourceforge.net/cdk/?rev=13463&view=rev Author: shk3 Date: 2008-12-04 12:21:58 +0000 (Thu, 04 Dec 2008) Log Message: ----------- cleanup Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2008-12-04 12:00:21 UTC (rev 13462) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2008-12-04 12:21:58 UTC (rev 13463) @@ -99,33 +99,6 @@ return paramInfo; } - - public void initPanelAndModel(AbstractJChemPaintPanel jcpp) { -// getContentPane().removeAll(); -// getContentPane().setLayout(new BorderLayout()); -//TODO try{ -// theModel.setTitle("JCP Applet" /* getNewFrameName() */); -// theModel.setAuthor(JCPPropertyHandler.getInstance().getJCPProperties().getProperty("General.UserName")); -// }catch(NullPointerException ex){ -// //It seems we get an npe here sometimes. the line is not necessary -// } -// // Package self = Package.getPackage("org.openscience.cdk.applications.jchempaint"); -// // String version = self.getImplementationVersion(); -// // model.setSoftware("JChemPaint " + version); -// theModel.setSoftware("JChemPaint " /*+ version */); -// theModel.setGendate((Calendar.getInstance()).getTime().toString()); -// jcpp.setJChemPaintModel(theModel,new Dimension((int)this.getWidth()-100,(int)this.getHeight()-100)); -// jcpp.registerModel(theModel); -// if(detacheable) -// jcpp.addFilePopUpMenu(); -// } -// } -// //embedded means that additional instances can't be created, which is -// // needed for applet as well -// jcpp.setEmbedded(); -// getContentPane().add(jcpp, BorderLayout.CENTER); - } - /** * loads a molecule from url or smiles */ @@ -173,7 +146,6 @@ }else{ theJcpp.setChemModel(new ChemModel()); } - initPanelAndModel(theJcpp); theJcpp.repaint(); } @@ -202,7 +174,6 @@ System.out.println("Cannot parse model: " + exception.toString()); exception.printStackTrace(); } - initPanelAndModel(theJcpp); } @Override @@ -230,9 +201,9 @@ if(getParameter("tooltips")!=null){ StringTokenizer st=new StringTokenizer(getParameter("tooltips"),"|"); IAtomContainer container = theJcpp.getChemModel().getBuilder().newAtomContainer(); - Iterator containers = ChemModelManipulator.getAllAtomContainers(theJcpp.getChemModel()).iterator(); + Iterator<IAtomContainer> containers = ChemModelManipulator.getAllAtomContainers(theJcpp.getChemModel()).iterator(); while (containers.hasNext()) { - container.add((IAtomContainer)containers.next()); + container.add(containers.next()); } while(st.hasMoreTokens()){ IAtom atom = container.getAtom(Integer.parseInt(st.nextToken())-1); @@ -392,13 +363,15 @@ repaint(); } -// TODO public void selectAtom(int atom){ -// theJcpp.getJChemPaintModel().getRendererModel().setExternalHighlightColor(Color.RED); -// IAtomContainer ac=theJcpp.getJChemPaintModel().getChemModel().getMoleculeSet().getBuilder().newAtomContainer(); -// ac.addAtom(theJcpp.getJChemPaintModel().getChemModel().getMoleculeSet().getMolecule(0).getAtom(atom)); -// theJcpp.getJChemPaintModel().getRendererModel().setExternalSelectedPart(ac); -// getTheJcpp().repaint(); -// } + public void selectAtom(int atom){ + Renderer2DModel rendererModel = theJcpp.get2DHub().getIJava2DRenderer().getRenderer2DModel(); + IChemModel chemModel = theJcpp.getChemModel(); + rendererModel.setExternalHighlightColor(Color.RED); + IAtomContainer ac=chemModel.getMoleculeSet().getBuilder().newAtomContainer(); + ac.addAtom(chemModel.getMoleculeSet().getMolecule(0).getAtom(atom)); + rendererModel.setExternalSelectedPart(ac); + getTheJcpp().repaint(); + } /** * @return Returns the jexf. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-05-05 17:49:29
|
Revision: 14585 http://cdk.svn.sourceforge.net/cdk/?rev=14585&view=rev Author: shk3 Date: 2009-05-05 17:48:32 +0000 (Tue, 05 May 2009) Log Message: ----------- better comment Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-05-05 17:22:48 UTC (rev 14584) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-05-05 17:48:32 UTC (rev 14585) @@ -81,7 +81,7 @@ + "for more information"; private static String[][] paramInfo = { - { "background", "color", "Background color as integer" }, + { "background", "color", "Background color as integer or hex starting with #" }, { "atomNumbersVisible", "true or false", "should atom numbers be shown"}, { "load", "url", "URL of the chemical data" }, { "compact", "true or false", "compact means elements shown as dots, no figures etc. (default false)"}, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mar...@us...> - 2009-08-20 12:54:36
|
Revision: 14747 http://cdk.svn.sourceforge.net/cdk/?rev=14747&view=rev Author: mark_rynbeek Date: 2009-08-20 12:54:26 +0000 (Thu, 20 Aug 2009) Log Message: ----------- Source code formatted with Eclipse Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-08-20 12:28:58 UTC (rev 14746) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-08-20 12:54:26 UTC (rev 14747) @@ -74,395 +74,433 @@ * */ public abstract class JChemPaintAbstractApplet extends JApplet { - private AbstractJChemPaintPanel theJcpp = null; - private JExternalFrame jexf; - protected boolean debug=false; + private AbstractJChemPaintPanel theJcpp = null; + private JExternalFrame jexf; + protected boolean debug = false; - private static String appletInfo = "JChemPaint Applet. See http://cdk.sourceforge.net " - + "for more information"; + private static String appletInfo = "JChemPaint Applet. See http://cdk.sourceforge.net " + + "for more information"; - private static String[][] paramInfo = { - { "background", "color", "Background color as integer or hex starting with #" }, - { "atomNumbersVisible", "true or false", "should atom numbers be shown"}, - { "load", "url", "URL of the chemical data" }, - { "compact", "true or false", "compact means elements shown as dots, no figures etc. (default false)"}, - { "tooltips", "string like 'atomumber|test|atomnumber|text'", "the texts will be used as tooltips for the respective atoms (leave out if none required"}, - { "impliciths", "true or false", "the implicit hs will be added from start (default true)"}, - { "spectrumRenderer", "string", "TODO name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom"}, - { "hightlightTable", "true or false", "TODO if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableid$atomnumber (default false)"}, - { "smiles", "string", "a structure to load as smiles"}, - { "scrollbars", "true or false", "if the molecule is too big to be displayed in normal size, shall scrollbars be used (default) or the molecule be resized - only for viewer applet"}, - { "dotranslate", "true or false", "should user interface be translated (default) or not (e. g. if you want an English-only webpage)"}, - { "detachable", "true or false", "should the applet be detacheable by a double click (default false)"}, - { "debug", "true or false", "switches on debug output (default false)"} - }; + private static String[][] paramInfo = { + { "background", "color", + "Background color as integer or hex starting with #" }, + { "atomNumbersVisible", "true or false", + "should atom numbers be shown" }, + { "load", "url", "URL of the chemical data" }, + { "compact", "true or false", + "compact means elements shown as dots, no figures etc. (default false)" }, + { + "tooltips", + "string like 'atomumber|test|atomnumber|text'", + "the texts will be used as tooltips for the respective atoms (leave out if none required" }, + { "impliciths", "true or false", + "the implicit hs will be added from start (default true)" }, + { + "spectrumRenderer", + "string", + "TODO name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom" }, + { + "hightlightTable", + "true or false", + "TODO if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableid$atomnumber (default false)" }, + { "smiles", "string", "a structure to load as smiles" }, + { + "scrollbars", + "true or false", + "if the molecule is too big to be displayed in normal size, shall scrollbars be used (default) or the molecule be resized - only for viewer applet" }, + { + "dotranslate", + "true or false", + "should user interface be translated (default) or not (e. g. if you want an English-only webpage)" }, + { "detachable", "true or false", + "should the applet be detacheable by a double click (default false)" }, + { "debug", "true or false", + "switches on debug output (default false)" } }; - @Override - public String getAppletInfo() { - return appletInfo; - } + @Override + public String getAppletInfo() { + return appletInfo; + } - @Override - public String[][] getParameterInfo() { - return paramInfo; - } + @Override + public String[][] getParameterInfo() { + return paramInfo; + } - /** - * loads a molecule from url or smiles - */ - protected void loadModelFromParam() { - URL fileURL = null; - String smiles=null; - try { - URL documentBase = getDocumentBase(); - String load = getParameter("load"); - if (load != null) - fileURL = new URL(documentBase, load); - smiles = getParameter("smiles"); - } catch (Exception exception) { - System.out.println("Cannot load model: " + exception.toString()); - exception.printStackTrace(); - } - if(fileURL!=null) - loadModelFromUrl(fileURL); - if(smiles!=null) - loadModelFromSmiles(smiles); - } - - /** - * Loads a molecule from a smiles into jcp - * - * @param fileURL - */ - public void loadModelFromSmiles(String smiles) { - if (smiles != null) { - try { - SmilesParser sp=new SmilesParser(DefaultChemObjectBuilder.getInstance()); - IMolecule mol = sp.parseSmiles(smiles); - StructureDiagramGenerator sdg = new StructureDiagramGenerator(); - sdg.setMolecule(mol); - sdg.generateCoordinates(new Vector2d(0, 1)); - mol=sdg.getMolecule(); - IChemModel chemModel = DefaultChemObjectBuilder.getInstance().newChemModel(); - chemModel.setMoleculeSet(DefaultChemObjectBuilder.getInstance().newMoleculeSet()); - chemModel.getMoleculeSet().addAtomContainer(mol); - theJcpp.setChemModel(chemModel); - } catch (Exception exception) { - System.out.println("Cannot parse model: " + exception.toString()); - exception.printStackTrace(); - } - }else{ - theJcpp.setChemModel(new ChemModel()); - } - } + /** + * loads a molecule from url or smiles + */ + protected void loadModelFromParam() { + URL fileURL = null; + String smiles = null; + try { + URL documentBase = getDocumentBase(); + String load = getParameter("load"); + if (load != null) + fileURL = new URL(documentBase, load); + smiles = getParameter("smiles"); + } catch (Exception exception) { + System.out.println("Cannot load model: " + exception.toString()); + exception.printStackTrace(); + } + if (fileURL != null) + loadModelFromUrl(fileURL); + if (smiles != null) + loadModelFromSmiles(smiles); + } + /** + * Loads a molecule from a smiles into jcp + * + * @param fileURL + */ + public void loadModelFromSmiles(String smiles) { + if (smiles != null) { + try { + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder + .getInstance()); + IMolecule mol = sp.parseSmiles(smiles); + StructureDiagramGenerator sdg = new StructureDiagramGenerator(); + sdg.setMolecule(mol); + sdg.generateCoordinates(new Vector2d(0, 1)); + mol = sdg.getMolecule(); + IChemModel chemModel = DefaultChemObjectBuilder.getInstance() + .newChemModel(); + chemModel.setMoleculeSet(DefaultChemObjectBuilder.getInstance() + .newMoleculeSet()); + chemModel.getMoleculeSet().addAtomContainer(mol); + theJcpp.setChemModel(chemModel); + } catch (Exception exception) { + System.out.println("Cannot parse model: " + + exception.toString()); + exception.printStackTrace(); + } + } else { + theJcpp.setChemModel(new ChemModel()); + } + } - public void setSmiles(String smiles){ - loadModelFromSmiles(smiles); - theJcpp.get2DHub().updateView(); - repaint(); - } - - /** - * Loads a molecule from a url into jcp - * - * @param fileURL - */ - public void loadModelFromUrl(URL fileURL) { - try { - IChemModel chemModel = JChemPaint.readFromFileReader(fileURL, fileURL.toString(), null); - theJcpp.setChemModel(chemModel); - } catch (Exception exception) { - System.out.println("Cannot parse model: " + exception.toString()); - exception.printStackTrace(); - } - } - - @Override - public void start() { - RendererModel rendererModel = - theJcpp.get2DHub().getRenderer().getRenderer2DModel(); - IChemModel chemModel = theJcpp.getChemModel(); - IControllerModel controllerModel = - theJcpp.get2DHub().getController2DModel(); - - //Parameter parsing goes here - loadModelFromParam(); - String atomNumbers=getParameter("atomNumbersVisible"); - if (atomNumbers != null) { + public void setSmiles(String smiles) { + loadModelFromSmiles(smiles); + theJcpp.get2DHub().updateView(); + repaint(); + } + + /** + * Loads a molecule from a url into jcp + * + * @param fileURL + */ + public void loadModelFromUrl(URL fileURL) { + try { + IChemModel chemModel = JChemPaint.readFromFileReader(fileURL, + fileURL.toString(), null); + theJcpp.setChemModel(chemModel); + } catch (Exception exception) { + System.out.println("Cannot parse model: " + exception.toString()); + exception.printStackTrace(); + } + } + + @Override + public void start() { + RendererModel rendererModel = theJcpp.get2DHub().getRenderer() + .getRenderer2DModel(); + IChemModel chemModel = theJcpp.getChemModel(); + IControllerModel controllerModel = theJcpp.get2DHub() + .getController2DModel(); + + // Parameter parsing goes here + loadModelFromParam(); + String atomNumbers = getParameter("atomNumbersVisible"); + if (atomNumbers != null) { if (atomNumbers.equals("true")) rendererModel.setDrawNumbers(true); } - - String background = getParameter("background"); - if (background != null) { + + String background = getParameter("background"); + if (background != null) { if (background.indexOf("#") == 0) rendererModel.setBackColor(Color.decode(background)); else rendererModel.setBackColor(new Color(Integer .parseInt(background))); - theJcpp.getRenderPanel().setBackground(rendererModel.getBackColor()); + theJcpp.getRenderPanel() + .setBackground(rendererModel.getBackColor()); } - - if (getParameter("compact") != null + + if (getParameter("compact") != null && getParameter("compact").equals("true")) { - rendererModel.setIsCompact(true); - } - - if (getParameter("tooltips") != null) { - StringTokenizer st = - new StringTokenizer(getParameter("tooltips"), "|"); - IAtomContainer container = - theJcpp.getChemModel().getBuilder().newAtomContainer(); - Iterator<IAtomContainer> containers = - ChemModelManipulator.getAllAtomContainers(chemModel).iterator(); - - while (containers.hasNext()) { - container.add(containers.next()); - } - - while (st.hasMoreTokens()) { - IAtom atom = - container.getAtom(Integer.parseInt(st.nextToken()) - 1); - rendererModel.getToolTipTextMap().put(atom, st.nextToken()); - } - rendererModel.setShowTooltip(true); - } - - if(getParameter("dotranslate") != null && getParameter("dotranslate").equals("false")){ - GT.setDoTranslate(false); - } - - if (getParameter("debug") != null + rendererModel.setIsCompact(true); + } + + if (getParameter("tooltips") != null) { + StringTokenizer st = new StringTokenizer(getParameter("tooltips"), + "|"); + IAtomContainer container = theJcpp.getChemModel().getBuilder() + .newAtomContainer(); + Iterator<IAtomContainer> containers = ChemModelManipulator + .getAllAtomContainers(chemModel).iterator(); + + while (containers.hasNext()) { + container.add(containers.next()); + } + + while (st.hasMoreTokens()) { + IAtom atom = container + .getAtom(Integer.parseInt(st.nextToken()) - 1); + rendererModel.getToolTipTextMap().put(atom, st.nextToken()); + } + rendererModel.setShowTooltip(true); + } + + if (getParameter("dotranslate") != null + && getParameter("dotranslate").equals("false")) { + GT.setDoTranslate(false); + } + + if (getParameter("debug") != null && getParameter("debug").equals("true")) { - this.debug=true; - } + this.debug = true; + } - - if (getParameter("impliciths") != null - && getParameter("impliciths").equals("false")) { - controllerModel.setAutoUpdateImplicitHydrogens(false); - rendererModel.setShowImplicitHydrogens(false); - rendererModel.setShowEndCarbons(false); - } else { - controllerModel.setAutoUpdateImplicitHydrogens(true); - rendererModel.setShowImplicitHydrogens(true); - rendererModel.setShowEndCarbons(true); - - if (chemModel != null) { - List<IAtomContainer> atomContainers = - ChemModelManipulator.getAllAtomContainers(chemModel); - for(int i=0;i<atomContainers.size();i++) - { - try { - CDKHydrogenAdder.getInstance( - atomContainers.get(i).getBuilder()) - .addImplicitHydrogens(atomContainers.get(i)); - } catch (CDKException e) { - //do nothing - } - } - } - } - } - - @Override - public void init(){ - prepareExternalFrame(); - } + if (getParameter("impliciths") != null + && getParameter("impliciths").equals("false")) { + controllerModel.setAutoUpdateImplicitHydrogens(false); + rendererModel.setShowImplicitHydrogens(false); + rendererModel.setShowEndCarbons(false); + } else { + controllerModel.setAutoUpdateImplicitHydrogens(true); + rendererModel.setShowImplicitHydrogens(true); + rendererModel.setShowEndCarbons(true); - @Override - public void stop() { - } - /** - * @return Returns the theJcpp. - */ - public AbstractJChemPaintPanel getTheJcpp() { - return theJcpp; - } - /** - * @param theJcpp The theJcpp to set. - */ - public void setTheJcpp(AbstractJChemPaintPanel theJcpp) { - this.theJcpp = theJcpp; - } - - /** - * Gives a mol file of the current molecules in the editor (not reactions) - * - * @return The mol file - * @throws CDKException - */ - public String getMolFile() throws CDKException{ - StringWriter sw = new StringWriter(); - MDLWriter mdlwriter = new MDLWriter(sw); - //mdlwriter.dontWriteAromatic(); - org.openscience.cdk.interfaces.IMoleculeSet som = theJcpp.getChemModel().getMoleculeSet(); - mdlwriter.write(som); - return(sw.toString()); - } - - - /** - * Gives a smiles of the current editor content - * - * @return The smiles - * @throws CloneNotSupportedException - * @throws IOException - * @throws ClassNotFoundException - * @throws CDKException - */ - public String getSmiles() throws CDKException, ClassNotFoundException, IOException, CloneNotSupportedException { - return CreateSmilesAction.getSmiles(theJcpp.getChemModel()); - } + if (chemModel != null) { + List<IAtomContainer> atomContainers = ChemModelManipulator + .getAllAtomContainers(chemModel); + for (int i = 0; i < atomContainers.size(); i++) { + try { + CDKHydrogenAdder.getInstance( + atomContainers.get(i).getBuilder()) + .addImplicitHydrogens(atomContainers.get(i)); + } catch (CDKException e) { + // do nothing + } + } + } + } + } - - /** - * Gives a chiral smiles of the current editor content - * - * @return The smiles - * @throws CloneNotSupportedException - * @throws IOException - * @throws ClassNotFoundException - * @throws CDKException - */ - public String getSmilesChiral() throws CDKException, ClassNotFoundException, IOException, CloneNotSupportedException{ - return CreateSmilesAction.getChiralSmiles(theJcpp.getChemModel()); - } + @Override + public void init() { + prepareExternalFrame(); + } - /** - * This method sets a structure in the editor and leaves the old one. - * This method replaces all \n characters with the system line separator. This can be used when setting a mol file in an applet - * without knowing which platform the applet is running on. - * - * @param mol The mol file to set (V2000) - * @throws Exception - */ - public void addMolFileWithReplace(String mol) throws Exception{ - StringBuffer newmol=new StringBuffer(); - int s = 0; - int e = 0; - while ((e = mol.indexOf("\\n", s)) >= 0) { - newmol.append(mol.substring(s, e)); - newmol.append(System.getProperty("file.separator")); - s = e + 1; + @Override + public void stop() { } - newmol.append(mol.substring(s)); - MDLV2000Reader reader=new MDLV2000Reader(new StringReader(newmol.toString())); - IMolecule cdkmol=(IMolecule)reader.read(DefaultChemObjectBuilder.getInstance().newMolecule()); - InsertTextPanel.generateModel(theJcpp,cdkmol,false); - theJcpp.get2DHub().updateView(); - repaint(); - } + /** + * @return Returns the theJcpp. + */ + public AbstractJChemPaintPanel getTheJcpp() { + return theJcpp; + } - /** - * This method sets a new structure in the editor and removes the old one. - * This method replaces all \n characters with the system line separator. This can be used when setting a mol file in an applet - * without knowing which platform the applet is running on. - * - * @param mol The mol file to set - * @throws CDKException - */ - public void setMolFileWithReplace(String mol) throws CDKException{ - StringBuffer newmol=new StringBuffer(); - int s = 0; - int e = 0; - while ((e = mol.indexOf("\\n", s)) >= 0) { - newmol.append(mol.substring(s, e)); - newmol.append(System.getProperty("file.separator")); - s = e + 1; + /** + * @param theJcpp + * The theJcpp to set. + */ + public void setTheJcpp(AbstractJChemPaintPanel theJcpp) { + this.theJcpp = theJcpp; } - newmol.append(mol.substring(s)); - MDLV2000Reader reader=new MDLV2000Reader(new StringReader(mol)); - IMolecule cdkmol=(IMolecule)reader.read(DefaultChemObjectBuilder.getInstance().newMolecule()); - theJcpp.setChemModel(ChemModelManipulator.newChemModel(cdkmol)); - theJcpp.get2DHub().updateView(); - repaint(); - } - - /** - * Sets a mol file in the applet - * - * @param mol - * @throws Exception - */ - public void setMolFile(String mol) throws CDKException{ - MDLV2000Reader reader=new MDLV2000Reader(new StringReader(mol)); - IMolecule cdkmol=(IMolecule)reader.read(DefaultChemObjectBuilder.getInstance().newMolecule()); - theJcpp.setChemModel(ChemModelManipulator.newChemModel(cdkmol)); - theJcpp.get2DHub().updateView(); - repaint(); - } - - /** - * Clears the applet - */ - public void clear(){ - theJcpp.setChemModel(new ChemModel()); - theJcpp.get2DHub().updateView(); - repaint(); - } + /** + * Gives a mol file of the current molecules in the editor (not reactions) + * + * @return The mol file + * @throws CDKException + */ + public String getMolFile() throws CDKException { + StringWriter sw = new StringWriter(); + MDLWriter mdlwriter = new MDLWriter(sw); + // mdlwriter.dontWriteAromatic(); + org.openscience.cdk.interfaces.IMoleculeSet som = theJcpp + .getChemModel().getMoleculeSet(); + mdlwriter.write(som); + return (sw.toString()); + } - /** - * A method for highlighting atoms from JavaScript - * - * @param atom The atom number (starting with 0) - */ - public void selectAtom(int atom){ - RendererModel rendererModel = - theJcpp.get2DHub().getRenderer().getRenderer2DModel(); - IChemModel chemModel = theJcpp.getChemModel(); - rendererModel.setExternalHighlightColor(Color.RED); - IAtomContainer ac = - chemModel.getMoleculeSet().getBuilder().newAtomContainer(); - ac.addAtom(chemModel.getMoleculeSet().getMolecule(0).getAtom(atom)); - rendererModel.setExternalSelectedPart(ac); - getTheJcpp().repaint(); - } - - /** - * Makes all implicit hydrogens explicit (same as using Edit->Hydrogens->Make all Implicit Hydrogens Explicit) - */ - public void makeHydrogensExplicit(){ - getTheJcpp().get2DHub().makeAllImplicitExplicit(); - getTheJcpp().repaint(); - } + /** + * Gives a smiles of the current editor content + * + * @return The smiles + * @throws CloneNotSupportedException + * @throws IOException + * @throws ClassNotFoundException + * @throws CDKException + */ + public String getSmiles() throws CDKException, ClassNotFoundException, + IOException, CloneNotSupportedException { + return CreateSmilesAction.getSmiles(theJcpp.getChemModel()); + } - /** - * Makes all explicit hydrogens implicit (same as using Edit->Hydrogens->Make all Explicit Hydrogens Implicit) - */ - public void makeHydrogensImplicit(){ - getTheJcpp().get2DHub().makeAllExplicitImplicit(); - getTheJcpp().repaint(); - } + /** + * Gives a chiral smiles of the current editor content + * + * @return The smiles + * @throws CloneNotSupportedException + * @throws IOException + * @throws ClassNotFoundException + * @throws CDKException + */ + public String getSmilesChiral() throws CDKException, + ClassNotFoundException, IOException, CloneNotSupportedException { + return CreateSmilesAction.getChiralSmiles(theJcpp.getChemModel()); + } - /** - * @return Returns the jexf. - */ - private JExternalFrame getJexf() { - if (jexf == null) - jexf = new JExternalFrame(); - return jexf; - } + /** + * This method sets a structure in the editor and leaves the old one. This + * method replaces all \n characters with the system line separator. This + * can be used when setting a mol file in an applet without knowing which + * platform the applet is running on. + * + * @param mol + * The mol file to set (V2000) + * @throws Exception + */ + public void addMolFileWithReplace(String mol) throws Exception { + StringBuffer newmol = new StringBuffer(); + int s = 0; + int e = 0; + while ((e = mol.indexOf("\\n", s)) >= 0) { + newmol.append(mol.substring(s, e)); + newmol.append(System.getProperty("file.separator")); + s = e + 1; + } + newmol.append(mol.substring(s)); + MDLV2000Reader reader = new MDLV2000Reader(new StringReader(newmol + .toString())); + IMolecule cdkmol = (IMolecule) reader.read(DefaultChemObjectBuilder + .getInstance().newMolecule()); + InsertTextPanel.generateModel(theJcpp, cdkmol, false); + theJcpp.get2DHub().updateView(); + repaint(); + } - /** - * sets title for external frame - * adds listener for double clicks in order to open external frame - */ - private void prepareExternalFrame() { - if (this.getParameter("name") != null) - getJexf().setTitle(this.getParameter("name")); - if(getParameter("detachable")!=null && getParameter("detachable").equals("true")){ - getTheJcpp().getRenderPanel().addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if (e.getButton() == 1 && e.getClickCount() == 2) - if (!getJexf().isShowing()) { - getJexf().show(getTheJcpp()); - } - } - }); - } - } + /** + * This method sets a new structure in the editor and removes the old one. + * This method replaces all \n characters with the system line separator. + * This can be used when setting a mol file in an applet without knowing + * which platform the applet is running on. + * + * @param mol + * The mol file to set + * @throws CDKException + */ + public void setMolFileWithReplace(String mol) throws CDKException { + StringBuffer newmol = new StringBuffer(); + int s = 0; + int e = 0; + while ((e = mol.indexOf("\\n", s)) >= 0) { + newmol.append(mol.substring(s, e)); + newmol.append(System.getProperty("file.separator")); + s = e + 1; + } + newmol.append(mol.substring(s)); + MDLV2000Reader reader = new MDLV2000Reader(new StringReader(mol)); + IMolecule cdkmol = (IMolecule) reader.read(DefaultChemObjectBuilder + .getInstance().newMolecule()); + theJcpp.setChemModel(ChemModelManipulator.newChemModel(cdkmol)); + theJcpp.get2DHub().updateView(); + repaint(); + } + + /** + * Sets a mol file in the applet + * + * @param mol + * @throws Exception + */ + public void setMolFile(String mol) throws CDKException { + MDLV2000Reader reader = new MDLV2000Reader(new StringReader(mol)); + IMolecule cdkmol = (IMolecule) reader.read(DefaultChemObjectBuilder + .getInstance().newMolecule()); + theJcpp.setChemModel(ChemModelManipulator.newChemModel(cdkmol)); + theJcpp.get2DHub().updateView(); + repaint(); + } + + /** + * Clears the applet + */ + public void clear() { + theJcpp.setChemModel(new ChemModel()); + theJcpp.get2DHub().updateView(); + repaint(); + } + + /** + * A method for highlighting atoms from JavaScript + * + * @param atom + * The atom number (starting with 0) + */ + public void selectAtom(int atom) { + RendererModel rendererModel = theJcpp.get2DHub().getRenderer() + .getRenderer2DModel(); + IChemModel chemModel = theJcpp.getChemModel(); + rendererModel.setExternalHighlightColor(Color.RED); + IAtomContainer ac = chemModel.getMoleculeSet().getBuilder() + .newAtomContainer(); + ac.addAtom(chemModel.getMoleculeSet().getMolecule(0).getAtom(atom)); + rendererModel.setExternalSelectedPart(ac); + getTheJcpp().repaint(); + } + + /** + * Makes all implicit hydrogens explicit (same as using + * Edit->Hydrogens->Make all Implicit Hydrogens Explicit) + */ + public void makeHydrogensExplicit() { + getTheJcpp().get2DHub().makeAllImplicitExplicit(); + getTheJcpp().repaint(); + } + + /** + * Makes all explicit hydrogens implicit (same as using + * Edit->Hydrogens->Make all Explicit Hydrogens Implicit) + */ + public void makeHydrogensImplicit() { + getTheJcpp().get2DHub().makeAllExplicitImplicit(); + getTheJcpp().repaint(); + } + + /** + * @return Returns the jexf. + */ + private JExternalFrame getJexf() { + if (jexf == null) + jexf = new JExternalFrame(); + return jexf; + } + + /** + * sets title for external frame adds listener for double clicks in order to + * open external frame + */ + private void prepareExternalFrame() { + if (this.getParameter("name") != null) + getJexf().setTitle(this.getParameter("name")); + if (getParameter("detachable") != null + && getParameter("detachable").equals("true")) { + getTheJcpp().getRenderPanel().addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if (e.getButton() == 1 && e.getClickCount() == 2) + if (!getJexf().isShowing()) { + getJexf().show(getTheJcpp()); + } + } + }); + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-10-08 13:10:36
|
Revision: 14952 http://cdk.svn.sourceforge.net/cdk/?rev=14952&view=rev Author: shk3 Date: 2009-10-08 13:10:27 +0000 (Thu, 08 Oct 2009) Log Message: ----------- the double click for detach is ignored in editor, it could confuse editing actions. Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-10-08 12:36:41 UTC (rev 14951) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-10-08 13:10:27 UTC (rev 14952) @@ -30,6 +30,7 @@ package org.openscience.jchempaint.applet; import java.awt.Color; +import java.awt.Container; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; @@ -503,7 +504,11 @@ && getParameter("detachable").equals("true")) { getTheJcpp().getRenderPanel().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - if (e.getButton() == 1 && e.getClickCount() == 2) + Container applet = (Container)e.getSource(); + while(!(applet instanceof JChemPaintEditorApplet || applet instanceof JChemPaintViewerApplet)){ + applet=applet.getParent(); + } + if (e.getButton() == 1 && e.getClickCount() == 2 && applet instanceof JChemPaintViewerApplet) if (!getJexf().isShowing()) { getJexf().show(getTheJcpp()); } @@ -514,7 +519,11 @@ && getParameter("detachableeditor").equals("true")) { getTheJcpp().getRenderPanel().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { - if (e.getButton() == 1 && e.getClickCount() == 2) + Container applet = (Container)e.getSource(); + while(!(applet instanceof JChemPaintEditorApplet || applet instanceof JChemPaintViewerApplet)){ + applet=applet.getParent(); + } + if (e.getButton() == 1 && e.getClickCount() == 2 && applet instanceof JChemPaintViewerApplet) if (!getJexf().isShowing()) { final JChemPaintPanel p = new JChemPaintPanel(theJcpp.getChemModel(),JChemPaintEditorApplet.GUI_APPLET,debug); p.setName("appletframe"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-10-26 10:48:52
|
Revision: 15017 http://cdk.svn.sourceforge.net/cdk/?rev=15017&view=rev Author: shk3 Date: 2009-10-26 10:48:46 +0000 (Mon, 26 Oct 2009) Log Message: ----------- the clear via js now works properly Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-10-23 16:14:09 UTC (rev 15016) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-10-26 10:48:46 UTC (rev 15017) @@ -68,6 +68,8 @@ import org.openscience.cdk.layout.StructureDiagramGenerator; import org.openscience.cdk.layout.TemplateHandler; import org.openscience.cdk.renderer.RendererModel; +import org.openscience.cdk.renderer.selection.IChemObjectSelection; +import org.openscience.cdk.renderer.selection.LogicalSelection; import org.openscience.cdk.smiles.SmilesParser; import org.openscience.cdk.tools.CDKHydrogenAdder; import org.openscience.cdk.tools.manipulator.ChemModelManipulator; @@ -451,9 +453,15 @@ * Clears the applet */ public void clear() { - theJcpp.setChemModel(new ChemModel()); + theJcpp.get2DHub().zap(); theJcpp.get2DHub().updateView(); - repaint(); + theJcpp.getRenderPanel().getRenderer().getRenderer2DModel() + .setZoomFactor(1); + + IChemObjectSelection selection = new LogicalSelection( + LogicalSelection.Type.NONE); + theJcpp.getRenderPanel().getRenderer().getRenderer2DModel() + .setSelection(selection); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sh...@us...> - 2009-12-29 14:30:58
|
Revision: 15240 http://cdk.svn.sourceforge.net/cdk/?rev=15240&view=rev Author: shk3 Date: 2009-12-29 14:30:51 +0000 (Tue, 29 Dec 2009) Log Message: ----------- added more javadoc info Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-12-29 14:16:24 UTC (rev 15239) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2009-12-29 14:30:51 UTC (rev 15240) @@ -134,11 +134,19 @@ { "debug", "true or false", "switches on debug output (default false)" } }; + /** + * Gives basic information about the applet. + * @see java.applet.Applet#getAppletInfo() + */ @Override public String getAppletInfo() { return appletInfo; } + /** + * Gives informations about applet params. + * @see java.applet.Applet#getParameterInfo() + */ @Override public String[][] getParameterInfo() { return paramInfo; @@ -219,6 +227,9 @@ } } + /** + * NOT FOR USE FROM JavaScript. + */ @Override public void start() { RendererModel rendererModel = theJcpp.get2DHub().getRenderer() @@ -312,11 +323,17 @@ } } + /** + * NOT FOR USE FROM JavaScript. + */ @Override public void init() { prepareExternalFrame(); } + /** + * NOT FOR USE FROM JavaScript. + */ @Override public void stop() { } @@ -324,7 +341,7 @@ /** * @return Returns the theJcpp. */ - public AbstractJChemPaintPanel getTheJcpp() { + private AbstractJChemPaintPanel getTheJcpp() { return theJcpp; } @@ -332,7 +349,7 @@ * @param theJcpp * The theJcpp to set. */ - public void setTheJcpp(AbstractJChemPaintPanel theJcpp) { + protected void setTheJcpp(AbstractJChemPaintPanel theJcpp) { this.theJcpp = theJcpp; } @@ -437,7 +454,7 @@ } /** - * Sets a mol file in the applet + * This method sets a new structure in the editor and removes the old one. * * @param mol * @throws Exception This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2010-08-25 07:34:48
|
Revision: 15563 http://cdk.svn.sourceforge.net/cdk/?rev=15563&view=rev Author: conni75 Date: 2010-08-25 07:34:42 +0000 (Wed, 25 Aug 2010) Log Message: ----------- Documentation for the features is generated correctly Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-24 17:14:00 UTC (rev 15562) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-25 07:34:42 UTC (rev 15563) @@ -40,6 +40,7 @@ import java.io.StringWriter; import java.net.URL; import java.util.ArrayList; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -82,6 +83,8 @@ import org.openscience.jchempaint.renderer.selection.IChemObjectSelection; import org.openscience.jchempaint.renderer.selection.LogicalSelection; +import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array; + /** * An abstract class for JCP applets, doing parameter parsing. * @@ -97,51 +100,53 @@ private static String appletInfo = "JChemPaint Applet. See http://cdk.sourceforge.net " + "for more information"; - public static String[][] paramInfo = { - { "background", "color", - "Background color as integer or hex starting with #" }, - { "atomNumbersVisible", "true or false", - "should atom numbers be shown" }, - { "load", "url", "URL of the chemical data" }, - { "compact", "true or false", - "compact means elements shown as dots, no figures etc. (default false)" }, - { "tooltips", - "string like 'atomumber|test|atomnumber|text'", - "the texts will be used as tooltips for the respective atoms (leave out if none required" }, - { "impliciths", "true or false", - "the implicit hs will be added from start (default true)" }, - { "spectrumRenderer", - "string", - "name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom" }, - { "hightlightTable", - "true or false", - "if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableidX, where X=atomnumber starting with 0 (default false)" }, - { "smiles", "string", "a structure to load as smiles" }, - { "mol", "string", "a structure to load as MOL V2000" }, - { "scrollbars", - "true or false", - "if the molecule is too big to be displayed in normal size, shall scrollbars be used (default) or the molecule be resized - only for viewer applet" }, - { "dotranslate", - "true or false", - "should user interface be translated (default) or not (e. g. if you want an English-only webpage)" }, - { "language", - "language code", - "a valid language code to use for ui language" }, - { "detachable", "true or false", - "should the applet be detacheable by a double click (default false)" }, - { "detachableeditor", "true or false", - "should the applet be detacheable as an editor by a double click (default false), only for viewer" }, - { "debug", "true or false", - "switches on debug output (default false)" } }; - + public static String[][] paramInfo; + static{ - //TODO descriptions need to be added to paraminfos like "$feature", "on or off", "$description" + List<List<String>> infos = new ArrayList<List<String>>(); + infos.add(Arrays.asList("background", "color", + "Background color as integer or hex starting with #")); + infos.add(Arrays.asList("atomNumbersVisible", "true or false", + "should atom numbers be shown")); + infos.add(Arrays.asList("load", "url", "URL of the chemical data")); + infos.add(Arrays.asList("compact", "true or false", + "compact means elements shown as dots, no figures etc. (default false)" )); + infos.add(Arrays.asList("tooltips", + "string like 'atomumber|test|atomnumber|text'", + "the texts will be used as tooltips for the respective atoms (leave out if none required")); + infos.add(Arrays.asList("impliciths", "true or false", + "the implicit hs will be added from start (default true)")); + infos.add(Arrays.asList("spectrumRenderer", + "string", + "name of a spectrum applet (see subproject in NMRShiftDB) where peaks should be highlighted when hovering over atom")); + infos.add(Arrays.asList("hightlightTable", + "true or false", + "if true peaks in a table will be highlighted when hovering over atom, ids are assumed to be tableidX, where X=atomnumber starting with 0 (default false)" )); + infos.add(Arrays.asList("smiles", "string", "a structure to load as smiles")); + infos.add(Arrays.asList("mol", "string", "a structure to load as MOL V2000")); + infos.add(Arrays.asList("scrollbars", + "true or false", + "if the molecule is too big to be displayed in normal size, shall scrollbars be used (default) or the molecule be resized - only for viewer applet")); + infos.add(Arrays.asList("dotranslate", + "true or false", + "should user interface be translated (default) or not (e. g. if you want an English-only webpage)")); + infos.add(Arrays.asList("language", + "language code", + "a valid language code to use for ui language")); + infos.add(Arrays.asList("detachable", "true or false", + "should the applet be detacheable by a double click (default false)")); + infos.add(Arrays.asList("detachableeditor", "true or false", + "should the applet be detacheable as an editor by a double click (default false), only for viewer")); + infos.add(Arrays.asList("debug", "true or false", + "switches on debug output (default false)")); String resource = "org.openscience.jchempaint.resources.features"; ResourceBundle featuresDefinition = ResourceBundle.getBundle(resource, Locale.getDefault()); Iterator<String> featuresit = featuresDefinition.keySet().iterator(); while(featuresit.hasNext()){ String feature = featuresit.next(); + infos.add(Arrays.asList(feature,"on or off","switches on or off the ui elements of this feature (default on)")); } + paramInfo = infos.toArray(paramInfo); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2010-08-25 07:48:07
|
Revision: 15564 http://cdk.svn.sourceforge.net/cdk/?rev=15564&view=rev Author: conni75 Date: 2010-08-25 07:47:59 +0000 (Wed, 25 Aug 2010) Log Message: ----------- Removed unneeded import Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-25 07:34:42 UTC (rev 15563) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-25 07:47:59 UTC (rev 15564) @@ -83,8 +83,6 @@ import org.openscience.jchempaint.renderer.selection.IChemObjectSelection; import org.openscience.jchempaint.renderer.selection.LogicalSelection; -import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array; - /** * An abstract class for JCP applets, doing parameter parsing. * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <co...@us...> - 2010-08-25 08:25:37
|
Revision: 15565 http://cdk.svn.sourceforge.net/cdk/?rev=15565&view=rev Author: conni75 Date: 2010-08-25 08:25:31 +0000 (Wed, 25 Aug 2010) Log Message: ----------- Documentation for the features is generated correctly Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-25 07:47:59 UTC (rev 15564) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/applet/JChemPaintAbstractApplet.java 2010-08-25 08:25:31 UTC (rev 15565) @@ -144,7 +144,10 @@ String feature = featuresit.next(); infos.add(Arrays.asList(feature,"on or off","switches on or off the ui elements of this feature (default on)")); } - paramInfo = infos.toArray(paramInfo); + paramInfo = new String[infos.size()][3]; + for(int i=0;i<infos.size();i++){ + paramInfo[i]=infos.get(i).toArray(new String[3]); + } } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |