Examples of IsotopeFactory


Examples of org.openscience.cdk.config.IsotopeFactory

   *
   * @param mol The molecule to modify.
   * @throws Exception
   */
  public static void configureMoleculeIsotopes(IMolecule mol) throws Exception {
    IsotopeFactory isotopeFactory = IsotopeFactory.getInstance(DefaultChemObjectBuilder.getInstance());
    isotopeFactory.configureAtoms(mol);   
  }
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

      return mm;
    }
  }*/
 
  static void addHydrogensForSilicon(IMolecule mol) {
    IsotopeFactory isotopeFactory;
    try {
      isotopeFactory = IsotopeFactory.getInstance(DefaultChemObjectBuilder.getInstance());     
    } catch (Exception e) {
      throw new Error(e);
    }
    for(int i=0;i<mol.getAtomCount();i++) {
      IAtom a = mol.getAtom(i);
      if(!a.getSymbol().equals("Si")) continue;
      int c = (int)mol.getBondOrderSum(a);
      if(a.getFormalCharge() == 1 || a.getFormalCharge() == -1) c += 1;
      int hr = 4 - c;
      for(int j=0;j<hr;j++) {
        IAtom ha = new Atom("H");
        isotopeFactory.configure(ha);
        IBond b = new Bond(a, ha);
        mol.addAtom(ha);
        mol.addBond(b);
      }
    }
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

   * Returns the exact mass of an element. Mass is obtained from the CDK
   * library.
   */
  public static double getElementMass(String element) {
    IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
    IsotopeFactory isotopeFac;
    try {
      isotopeFac = IsotopeFactory.getInstance(builder);
    } catch (Exception e) {
      e.printStackTrace();
      return 0;
    }
    IIsotope majorIsotope = isotopeFac.getMajorIsotope(element);
    // If the isotope which such symbol does not exist, return 0
    if (majorIsotope == null) {
      return 0;
    }
    double mass = majorIsotope.getExactMass();
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

    this.maxCount = max;

    try {
      // Use CDK to obtain element's mass
      IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
      IsotopeFactory ifac = IsotopeFactory.getInstance(builder);
      elementObject = ifac.getMajorIsotope(elementSymbol);
      elementMass = elementObject.getExactMass();
    } catch (IOException e) {
      // This can never happen
      e.printStackTrace();
    }
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

                IAtom closestAtom = model.getHighlightedAtom();
                char x = arg0.getKeyChar();               
                if (Character.isLowerCase(x))
                    x = Character.toUpperCase(x);
                System.out.println(x);
                IsotopeFactory ifa;
                ifa = XMLIsotopeFactory.getInstance(closestAtom.getBuilder());
                IIsotope iso = ifa.getMajorIsotope(Character.toString(x));
                if (iso != null) {
                    relay.setSymbol(closestAtom, Character.toString(x));
                }
                this.get2DHub().updateView();
            } catch (IOException e) {
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

        }
       
        Integer massNumber = atom.getMassNumber();
        if (massNumber != null) {
            try {
                IsotopeFactory factory =
                    XMLIsotopeFactory.getInstance(ac.getBuilder());
                if(factory.getMajorIsotope(atom.getSymbol())!=null){
                  int majorMass =
                      factory.getMajorIsotope(atom.getSymbol()).getMassNumber();
                  if (massNumber != majorMass) {
                      Position position = getNextPosition(unused);
                      textGroup.addChild(String.valueOf(massNumber), position);
                  }
                }
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

                String[] funcGroupsKeys=new String[0];
                symbol=EnterElementOrGroupDialog.showDialog(null,null, GT.get("Enter an element symbol:"), GT.get("Enter element"), funcGroupsKeys, "","");
                if(symbol!=null && symbol.length()>0){
                    if(Character.isLowerCase(symbol.toCharArray()[0]))
                        symbol=Character.toUpperCase(symbol.charAt(0))+symbol.substring(1);
                    IsotopeFactory ifa;
                    try {
                        ifa = XMLIsotopeFactory.getInstance(jcpPanel.getChemModel().getBuilder());
                        IIsotope iso=ifa.getMajorIsotope(symbol);
                        if(iso==null){
                            JOptionPane.showMessageDialog(jcpPanel, GT.get("No valid element symbol entered"), GT.get("Invalid symbol"), JOptionPane.WARNING_MESSAGE);
                            return;
                        }
                    } catch (IOException e) {
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

                }
                chemModelRelay.getController2DModel().setDrawElement(x);
            }else if(x!=null && x.length()>0){
                if(Character.isLowerCase(x.toCharArray()[0]))
                    x=Character.toUpperCase(x.charAt(0))+x.substring(1);
                IsotopeFactory ifa=XMLIsotopeFactory.getInstance(chemModelRelay.getIChemModel().getBuilder());
                IIsotope iso=ifa.getMajorIsotope(x);
                if(iso!=null){
                    if(closestAtom==null){
                        IAtomContainer addatom=chemModelRelay.getIChemModel().getBuilder().newInstance(IAtomContainer.class);
                        addatom.addAtom(chemModelRelay.addAtomWithoutUndo(x, worldCoord, false));
                        if(chemModelRelay.getUndoRedoFactory()!=null && chemModelRelay.getUndoRedoHandler()!=null){
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

   * @see javax.swing.undo.UndoableEdit#redo()
   */
  public void redo() throws CannotRedoException {
    this.atom.setSymbol(symbol);
    try {
      IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder());
      this.atom.setMassNumber(ifac.getMajorIsotope(symbol).getMassNumber());
      chemModelRelay.updateAtom(atom);
      ifac.configure(atom);
    } catch (OptionalDataException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here

Examples of org.openscience.cdk.config.IsotopeFactory

   * @see javax.swing.undo.UndoableEdit#undo()
   */
  public void undo() throws CannotUndoException {
    this.atom.setSymbol(formerSymbol);
    try {
      IsotopeFactory ifac = XMLIsotopeFactory.getInstance(atom.getBuilder());
      this.atom.setMassNumber(ifac.getMajorIsotope(formerSymbol).getMassNumber());
      chemModelRelay.updateAtom(atom);
      ifac.configure(atom);
    } catch (OptionalDataException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.