Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IChemModel


    public void start() {
        // Parameter parsing goes here
        loadModelFromParam();
        JChemPaintRendererModel rendererModel = theJcpp.get2DHub().getRenderer()
                .getRenderer2DModel();
        IChemModel chemModel = theJcpp.getChemModel();
        IControllerModel controllerModel = theJcpp.get2DHub()
                .getController2DModel();

        String atomNumbers = getParameter("atomNumbersVisible");
        if (atomNumbers != null) {
View Full Code Here


     * @throws Exception
     */
    public void setMolFile(String mol) throws CDKException {
      
      ISimpleChemObjectReader cor=null;
      IChemModel chemModel = null;

      if (mol.contains("$RGP")) {
        cor= new RGroupQueryReader(new StringReader(mol));
        chemModel=JChemPaint.getChemModelFromReader(cor, theJcpp);
      }
View Full Code Here

     *            The atom number (starting with 0), -1 sets empty selection.
     */
    public void selectAtom(int atom) {
        JChemPaintRendererModel rendererModel = theJcpp.get2DHub().getRenderer()
                .getRenderer2DModel();
        IChemModel chemModel = theJcpp.getChemModel();
        rendererModel.setExternalHighlightColor(Color.RED);
        IAtomContainer ac = chemModel.getMoleculeSet().getBuilder()
                .newInstance(IAtomContainer.class);
        if(atom!=-1){
            ac.addAtom(chemModel.getMoleculeSet().getAtomContainer(0).getAtom(atom));
            rendererModel.setExternalSelectedPart(ac);
        }else{
            rendererModel.setExternalSelectedPart(null);
        }
        getTheJcpp().get2DHub().updateView();
View Full Code Here

                    JChemPaintEditorApplet.GUI_APPLET) ||
                    JChemPaintPanel.getAllAtomContainersInOne(jcpPanel.getChemModel()).getAtomCount()==0) {
                int clear = jcpPanel.showWarning();
                if (clear == JOptionPane.YES_OPTION) {
                    try {
                        IChemModel chemModel = null;
                      jcpPanel.get2DHub().unsetRGroupHandler();
                            chemModel = JChemPaint
                                    .readFromFileReader(chooser
                                            .getSelectedFile().toURI().toURL(),
                                            chooser.getSelectedFile().toURI()
                                                    .toString(), type, jcpPanel);
                        if (jcpPanel.get2DHub().getUndoRedoFactory() != null
                                && jcpPanel.get2DHub().getUndoRedoHandler() != null) {
                            IUndoRedoable undoredo = jcpPanel.get2DHub()
                                    .getUndoRedoFactory().getLoadNewModelEdit(
                                            jcpPanel.getChemModel(),
                      null,
                                            jcpPanel.getChemModel()
                                                    .getMoleculeSet(),
                                            jcpPanel.getChemModel()
                                                    .getReactionSet(),
                                            chemModel.getMoleculeSet(),
                                            chemModel.getReactionSet(),
                                            "Load "
                                                    + chooser.getSelectedFile()
                                                            .getName());
                            jcpPanel.get2DHub().getUndoRedoHandler().postEdit(
                                    undoredo);
                        }
                        jcpPanel.getChemModel().setMoleculeSet(
                                chemModel.getMoleculeSet());
                        jcpPanel.getChemModel().setReactionSet(chemModel.getReactionSet());
                        jcpPanel.getRenderPanel().getRenderer()
                                .getRenderer2DModel().setSelection(
                                        new LogicalSelection(
                                                LogicalSelection.Type.NONE));
View Full Code Here

  public void actionPerformed(ActionEvent event)
  {
    IChemObject object = getSource(event);

    logger.debug("CreateReaction action");
    IChemModel model = jcpPanel.getChemModel();
    IReactionSet reactionSet = model.getReactionSet();
    if (reactionSet == null)
    {
      reactionSet = model.getBuilder().newInstance(IReactionSet.class);
    }
    IAtomContainer container = null;
    if (object instanceof IAtom)
    {
      container = ChemModelManipulator.getRelevantAtomContainer(model, (IAtom) object);
View Full Code Here

     * @return chemModel with molecule set with molecule(s) created using InChI
     * @throws org.openscience.cdk.exception.CDKException
     */
    public static IChemModel readInChI(URL url) throws CDKException {

        IChemModel chemModel = new ChemModel();
        try {
            IAtomContainerSet moleculeSet = new AtomContainerSet();
            chemModel.setMoleculeSet(moleculeSet);
            StdInChIParser parser = new StdInChIParser();

            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = in.readLine()) != null)
View Full Code Here

    /* (non-Javadoc)
     * @see org.openscience.cdk.controller.IChemModelRelay#makeReactantInExistingReaction(java.lang.String, org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.interfaces.IAtomContainer)
     */
    public static void makeReactantInExistingReaction(ControllerHub controllerhub, String reactionId,
            IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = ReactionSetManipulator.getReactionByReactionID(chemModel.getReactionSet(), reactionId);
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addReactant(mol);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInExistingReactionEdit(chemModel, newContainer, oldcontainer, reactionId, true, "Make Reactant in "+reactionId);
            controllerhub.getUndoRedoHandler().postEdit(undoredo);
        }
        controllerhub.structureChanged();
View Full Code Here

        controllerhub.structureChanged();
    }

    public static void makeProductInNewReaction(ControllerHub controllerhub, IAtomContainer newContainer,
            IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = newContainer.getBuilder().newInstance(IReaction.class);
        reaction.setID(newReactionId(controllerhub));
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addProduct(mol);
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet == null)
        {
            reactionSet = chemModel.getBuilder().newInstance(IReactionSet.class);
        }
        reactionSet.addReaction(reaction);
        chemModel.setReactionSet(reactionSet);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInNewReactionEdit(chemModel, newContainer, oldcontainer, false, "Make Reactant in new Reaction");
            controllerhub.getUndoRedoHandler().postEdit(undoredo);
        }
        controllerhub.structureChanged();
View Full Code Here

    /* (non-Javadoc)
     * @see org.openscience.cdk.controller.IChemModelRelay#makeProductInExistingReaction(java.lang.String, org.openscience.cdk.interfaces.IAtomContainer, org.openscience.cdk.interfaces.IAtomContainer)
     */
    public static void makeProductInExistingReaction(ControllerHub controllerhub, String reactionId,
            IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = ReactionSetManipulator.getReactionByReactionID(chemModel.getReactionSet(), reactionId);
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addProduct(mol);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInExistingReactionEdit(chemModel, newContainer, oldcontainer, reactionId, false, "Make Reactant in "+reactionId);
            controllerhub.getUndoRedoHandler().postEdit(undoredo);
        }
        controllerhub.structureChanged();
View Full Code Here

public class ReactionHub {


    public static void makeReactantInNewReaction(ControllerHub controllerhub, IAtomContainer newContainer, IAtomContainer oldcontainer) {
        IChemModel chemModel = controllerhub.getChemModel();
        IReaction reaction = newContainer.getBuilder().newInstance(IReaction.class);
        reaction.setID(newReactionId(controllerhub));
        IAtomContainer mol=newContainer.getBuilder().newInstance(IAtomContainer.class,newContainer);
        mol.setID(newContainer.getID());
        reaction.addReactant(mol);
        IReactionSet reactionSet = chemModel.getReactionSet();
        if (reactionSet == null)
        {
            reactionSet = chemModel.getBuilder().newInstance(IReactionSet.class);
        }
        reactionSet.addReaction(reaction);
        chemModel.setReactionSet(reactionSet);
        chemModel.getMoleculeSet().removeAtomContainer(oldcontainer);
        if(chemModel.getMoleculeSet().getAtomContainerCount()==0)
            chemModel.getMoleculeSet().addAtomContainer(chemModel.getBuilder().newInstance(IAtomContainer.class));
        if(controllerhub.getUndoRedoFactory()!=null && controllerhub.getUndoRedoHandler()!=null){
            IUndoRedoable undoredo = controllerhub.getUndoRedoFactory().getMakeReactantOrProductInNewReactionEdit(chemModel, newContainer, oldcontainer, true, "Make Reactant in new Reaction");
            controllerhub.getUndoRedoHandler().postEdit(undoredo);
        }
        controllerhub.structureChanged();
View Full Code Here

TOP

Related Classes of org.openscience.cdk.interfaces.IChemModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.