Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtomContainer


    public void loadModelFromSmiles(String smiles) {
        if (smiles != null) {
            try {
                SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder
                        .getInstance());
                IAtomContainer mol = sp.parseSmiles(smiles);

                //for some reason, smilesparser sets valencies, which we don't want in jcp
                for(int i=0;i<mol.getAtomCount();i++){
                  mol.getAtom(i).setValency(null);
                }
    JChemPaint.generateModel(theJcpp, mol, true, false);
                /*StructureDiagramGenerator sdg = new StructureDiagramGenerator();
                sdg.setMolecule(mol);
                sdg.generateCoordinates(new Vector2d(0, 1));
View Full Code Here


  public MultiSelection(Collection<T> selection) {
    this.selection = selection;
  }

  public IAtomContainer getConnectedAtomContainer() {
    IAtomContainer atomContainer = null;
    if (!selection.isEmpty()) {
      for (T value : selection) {
        if (atomContainer == null)
          atomContainer = value.getBuilder().newInstance(IAtomContainer.class);
        addToAtomContainer(atomContainer, value);
View Full Code Here

        }

        if (getParameter("tooltips") != null) {
            StringTokenizer st = new StringTokenizer(getParameter("tooltips"),
                    "|");
            IAtomContainer container = theJcpp.getChemModel().getBuilder()
                    .newInstance(IAtomContainer.class);
            Iterator<IAtomContainer> containers = ChemModelManipulator
                    .getAllAtomContainers(chemModel).iterator();

            while (containers.hasNext()) {
                IAtomContainer ac=containers.next();
                container.add(ac);
            }

            while (st.hasMoreTokens()) {
                IAtom atom = container
View Full Code Here

            s = e + 2;
        }
        newmol.append(mol.substring(s));
        MDLV2000Reader reader = new MDLV2000Reader(new StringReader(newmol
                .toString()));
        IAtomContainer cdkmol = (IAtomContainer) reader.read(DefaultChemObjectBuilder
                .getInstance().newInstance(IAtomContainer.class));
        JChemPaint.generateModel(theJcpp, cdkmol, false,false);
        theJcpp.get2DHub().updateView();
        // the newly opened file should nicely fit the screen
        theJcpp.getRenderPanel().setFitToScreen(true);
View Full Code Here

    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

  public SingleSelection(T item) {
    selection = item;
  }

  public IAtomContainer getConnectedAtomContainer() {
    IAtomContainer ac = selection.getBuilder().newInstance(IAtomContainer.class);
    addToAtomContainer(ac, selection);
    return ac;
  }
View Full Code Here

  }

  // OK
  public IAtomContainer removeAtomWithoutUndo(IAtom atom) {
   
    IAtomContainer ac = atom.getBuilder().newInstance(IAtomContainer.class);
    if(rGroupHandler!=null && !rGroupHandler.checkRGroupOkayForDelete(atom, this))
      return ac;
   
    ac.addAtom(atom);
    Iterator<IBond> connbonds = ChemModelManipulator
        .getRelevantAtomContainer(chemModel, atom)
        .getConnectedBondsList(atom).iterator();
    while (connbonds.hasNext()) {
      IBond connBond = connbonds.next();
      ac.addBond(connBond);
    }
    ChemModelManipulator.removeAtomAndConnectedElectronContainers(
        chemModel, atom);
    for (IBond bond : ac.bonds()) {
      if (bond.getAtom(0) == atom)
        updateAtom(bond.getAtom(1));
      else
        updateAtom(bond.getAtom(0));
    }
View Full Code Here

    return addAtom(atomType, 0, worldCoord, makePseudoAtom);
  }

  //OK TODO this could do with less partitioning
  public IAtomContainer removeAtom(IAtom atom) {
    IAtomContainer ac = removeAtomWithoutUndo(atom);
        removeEmptyContainers(chemModel);
      if(getUndoRedoFactory()!=null && getUndoRedoHandler()!=null){
        IUndoRedoable undoredo = getUndoRedoFactory().getRemoveAtomsAndBondsEdit(getIChemModel(), ac, "Remove Atom",this);
        getUndoRedoHandler().postEdit(undoredo);
      }
View Full Code Here

   * org.openscience.cdk.controller.IChemModelRelay#addAtom(java.lang.String,
   * int, javax.vecmath.Point2d)
   */
  public IAtom addAtom(String atomType, int isotopeNumber,
      Point2d worldCoord, boolean makePseudoAtom) {
    IAtomContainer undoRedoContainer = chemModel.getBuilder()
        .newInstance(IAtomContainer.class);
    undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, isotopeNumber,
        worldCoord, makePseudoAtom));
    if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) {
      IUndoRedoable undoredo = getUndoRedoFactory()
          .getAddAtomsAndBondsEdit(chemModel, undoRedoContainer,
              null, "Add Atom", this);
      getUndoRedoHandler().postEdit(undoredo);
    }
    return undoRedoContainer.getAtom(0);
  }
View Full Code Here

      newAtom.setMassNumber(isotopeNumber);
    // FIXME : there should be an initial hierarchy?
    IAtomContainerSet molSet = chemModel.getMoleculeSet();
    if (molSet == null) {
      molSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
      IAtomContainer ac = chemModel.getBuilder().newInstance(IAtomContainer.class);
      ac.addAtom(newAtom);
      molSet.addAtomContainer(ac);
      chemModel.setMoleculeSet(molSet);
    }
    IAtomContainer newAtomContainer = chemModel.getBuilder().newInstance(IAtomContainer.class);
    if (chemModel.getMoleculeSet().getAtomContainer(0).getAtomCount() == 0)
      newAtomContainer = (IAtomContainer) chemModel.getMoleculeSet()
          .getAtomContainer(0);
    else
      molSet.addAtomContainer(newAtomContainer);
    newAtomContainer.addAtom(newAtom);
    updateAtom(newAtom);
    JChemPaintRendererModel model = this.getRenderer().getRenderer2DModel();
    double nudgeDistance = model.getHighlightDistance() / model.getScale();
    if (getClosestAtom(newAtom) != null)
      newAtom.getPoint2d().x += nudgeDistance;
View Full Code Here

TOP

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

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.