Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtom


        IAtom atom = panel.getChemModel().getMoleculeSet().getAtomContainer(0).getAtom(atomnumber);
        return panel.getRenderPanel().getRenderer().toScreenCoordinates(atom.getPoint2d().x,atom.getPoint2d().y);
    }   
   
    protected Point2d getAtomPoint(JChemPaintPanel panel, int atomnumber, int acnumber){
        IAtom atom = panel.getChemModel().getMoleculeSet().getAtomContainer(acnumber).getAtom(atomnumber);
        return panel.getRenderPanel().getRenderer().toScreenCoordinates(atom.getPoint2d().x,atom.getPoint2d().y);
    }   
View Full Code Here


        double scale = jcpModel.getScale();
        double modelAtomRadius = ATOM_RADIUS / scale;
        double modelPointRadius = SCREEN_RADIUS / scale;
        double modelSeparation = SCREEN_SEPARATION / scale;
        for (ILonePair lp : ac.lonePairs()) {
            IAtom atom = lp.getAtom();
            Point2d p = atom.getPoint2d();
            int align = GeometryTools.getBestAlignmentForLabelXY(ac, atom);
            double rx = p.x;
            double ry = p.y;
            double dx = 0;
            double dy = 0;
View Full Code Here

        final double ATOM_RADIUS = jcpModel.getAtomRadius() / jcpModel.getScale();
       
        double modelRadius = SCREEN_RADIUS / jcpModel.getScale();
        Map<IAtom,Integer> singleElectronsPerAtom = new HashMap<IAtom, Integer>();
        for (ISingleElectron e : ac.singleElectrons()) {
            IAtom atom = e.getAtom();
            if(singleElectronsPerAtom.get(atom)==null)
                singleElectronsPerAtom.put(atom,0);
            Point2d p = atom.getPoint2d();
            int align = GeometryTools.getBestAlignmentForLabelXY(ac, atom);
            double rx = p.x;
            double ry = p.y;
            if (align == 1) {
                rx += ATOM_RADIUS+singleElectronsPerAtom.get(atom)*ATOM_RADIUS;
 
View Full Code Here

      }

      /* User has indicated that a certain atom in a substituent needs to become attachment point 1 or 2 */
      else if (type.startsWith("setAtomApoAction")) {
        rGroupHandler=hub.getRGroupHandler();
        IAtom apoAtom = (IAtom) eventSource;
        apoLoop:
          for (Iterator<Integer> rnumItr=rGroupHandler.getrGroupQuery().getRGroupDefinitions().keySet().iterator(); rnumItr.hasNext();) {
            for (RGroup rgrp: rGroupHandler.getrGroupQuery().getRGroupDefinitions().get(rnumItr.next()).getRGroups()) {
              if(rgrp.getGroup().contains(apoAtom)) {
                existingRGroupApo= new HashMap <RGroup,Map<Integer,IAtom>>();
                HashMap<Integer,IAtom> map = new HashMap<Integer,IAtom>();
                map.put(1, rgrp.getFirstAttachmentPoint());
                map.put(2, rgrp.getSecondAttachmentPoint());
                existingRGroupApo.put(rgrp,map);

                boolean firstApo = type.endsWith("1");
                if (firstApo) {
                  rgrp.setFirstAttachmentPoint(apoAtom);
                }
                else {
                  rgrp.setSecondAttachmentPoint(apoAtom);
                }
                break apoLoop;
              }
            }
          }
      }

      /* User action : certain bond in the root needs to become attachment bond 1 or 2 */
      else if (type.startsWith("setBondApoAction")) {
        rGroupHandler=hub.getRGroupHandler();
        IBond apoBond = (IBond) eventSource;
        Map<Integer, IBond> apoBonds=null;

        //Undo/redo business______
        IAtom pseudo=null;
        if (apoBond.getAtom(0) instanceof IPseudoAtom)
          pseudo=apoBond.getAtom(0);
        else
          pseudo=apoBond.getAtom(1);
        Map<Integer, IBond> keepApoBonds = new HashMap<Integer, IBond>();
        if (rGroupHandler.getrGroupQuery().getRootAttachmentPoints()!=null &&
            rGroupHandler.getrGroupQuery().getRootAttachmentPoints().get(pseudo)!=null) {
          apoBonds= rGroupHandler.getrGroupQuery().getRootAttachmentPoints().get(pseudo);
          for (Iterator<Integer> apoItr =apoBonds.keySet().iterator(); apoItr.hasNext();) {
            int apoNum=apoItr.next();
            keepApoBonds.put(apoNum,apoBonds.get(apoNum));
          }
        }
        existingRootAttachmentPoints = new HashMap<IAtom, Map<Integer, IBond>>();
        existingRootAttachmentPoints.put(pseudo, keepApoBonds);
        //________________________


        //Set the new Root APO
        if (rGroupHandler.getrGroupQuery().getRootAttachmentPoints()==null) {
          rGroupHandler.getrGroupQuery().setRootAttachmentPoints(new HashMap<IAtom, Map<Integer, IBond>>());
        }
        Map<IAtom, Map<Integer, IBond>> rootApo=rGroupHandler.getrGroupQuery().getRootAttachmentPoints();
        if (rootApo.get(pseudo)==null) {
          apoBonds=new HashMap<Integer,IBond>();
          rootApo.put(pseudo, apoBonds);
        }
        else
          apoBonds=rGroupHandler.getrGroupQuery().getRootAttachmentPoints().get(pseudo);

        if (type.endsWith("1")) {
          apoBonds.put(1, apoBond);
          if (apoBonds.get(2)!=null && apoBonds.get(2).equals(apoBond))
            apoBonds.remove(2);
        }
        if (type.endsWith("2")) {
          apoBonds.put(2, apoBond);
          if (apoBonds.get(1)!=null && apoBonds.get(1).equals(apoBond))
            apoBonds.remove(1);
        }

      }


      /* User action: certain atom+bond selection is to be the root structure. */
      else if (type.equals("setRoot")) {

        IAtomContainer atc =selection.getConnectedAtomContainer();
        if (!isProperSelection(atc)) {
          JOptionPane.showMessageDialog(jcpPanel, GT.get("Please do not make a fragmented selection."));
          return;
        }

        molecule = createMolecule (atc,existingAtomDistr,existingBondDistr);
        hub.getChemModel().getMoleculeSet().addAtomContainer(molecule);

        if (hub.getRGroupHandler() == null) {
          isNewRgroup=true;
          rgrpQuery = newRGroupQuery(molecule.getBuilder());
          rGroupHandler = new RGroupHandler(rgrpQuery, this.jcpPanel);
          hub.setRGroupHandler(rGroupHandler);
        }
        else {
          rGroupHandler=hub.getRGroupHandler();
          rgrpQuery = hub.getRGroupHandler().getrGroupQuery();
          if(rgrpQuery.getRootStructure()!=null) {
            existingRoot=rgrpQuery.getRootStructure();
            rgrpQuery.getRootStructure().removeProperty(CDKConstants.TITLE);
          }
        }
        molecule.setProperty(CDKConstants.TITLE,RGroup.ROOT_LABEL);
        rgrpQuery.setRootStructure(molecule);

        //Remove old root apo's
        existingRootAttachmentPoints = rgrpQuery.getRootAttachmentPoints();
        rgrpQuery.setRootAttachmentPoints(null);

        //Define new root apo's
        Map<IAtom, Map<Integer, IBond>> apoBonds= new HashMap<IAtom, Map<Integer, IBond>>();
        for (IAtom atom : molecule.atoms()) {
          if (atom instanceof IPseudoAtom) {
            IPseudoAtom pseudo = (IPseudoAtom)atom;
            if (pseudo.getLabel()!=null && RGroupQuery.isValidRgroupQueryLabel(pseudo.getLabel())) {
              chooseRootAttachmentBonds(pseudo,molecule,apoBonds);
            }
          }
        }
        rgrpQuery.setRootAttachmentPoints(apoBonds);

      }

      /* User action: certain atom+bond selection is to be a substituent. */
      else if (type.equals("setSubstitute")) {

        if (hub.getRGroupHandler() == null || hub.getRGroupHandler().getrGroupQuery()==null ||
            hub.getRGroupHandler().getrGroupQuery().getRootStructure()==null) {
          JOptionPane.showMessageDialog(jcpPanel, GT.get("Please define a root structure first."));
          return;
        }

        IAtomContainer atc =selection.getConnectedAtomContainer();
        if (!isProperSelection(atc)) {
          JOptionPane.showMessageDialog(jcpPanel, GT.get("Please do not make a fragmented selection."));
          return;
        }

        // Check - are there any R-groups -> collect them so that user input can be validated
        Map<Integer,Integer> validRnumChoices=new HashMap<Integer,Integer>();
        for (IAtom atom : hub.getRGroupHandler().getrGroupQuery().getRootStructure().atoms()) {
          if (atom instanceof IPseudoAtom) {
            IPseudoAtom pseudo = (IPseudoAtom)atom;
            if (pseudo.getLabel()!=null && RGroupQuery.isValidRgroupQueryLabel(pseudo.getLabel())) {
              int bondCnt=0;
              int rNum=new Integer(pseudo.getLabel().substring(1));
              for (IBond b : hub.getRGroupHandler().getrGroupQuery().getRootStructure().bonds())
                if (b.contains(atom))
                  bondCnt++;

              if ((!validRnumChoices.containsKey(rNum))||
View Full Code Here

  public boolean isMergeAllowed(IChemModelRelay hub) {
    //System.out.println("^^^ isMergeAllowed(IChemModelRelay hub)");

    if (rGroupQuery!=null) {
      for (Iterator<IAtom> it = hub.getRenderer().getRenderer2DModel().getMerge().keySet().iterator(); it.hasNext();) {
        IAtom mergedAtom = it.next();
        IAtom mergedPartnerAtom = hub.getRenderer().getRenderer2DModel().getMerge().get(mergedAtom);
        IAtomContainer container1 = ChemModelManipulator.getRelevantAtomContainer(hub.getChemModel(), mergedAtom);
        IAtomContainer container2 = ChemModelManipulator.getRelevantAtomContainer(hub.getChemModel(), mergedPartnerAtom);

        if(container1!=container2) {
          List<IAtomContainer> substitutes = rGroupQuery.getSubstituents();
View Full Code Here

    String symbol = s.substring(s.indexOf("@") + 1);
        Integer valence=null;
        if(!symbol.equals("off"))
            valence = new Integer(symbol);
    while(atomsInRange.hasNext()){
            IAtom atom = atomsInRange.next();
      if(symbol.equals("off")){
        jcpPanel.get2DHub().setValence(atom,null);
      }else{
        jcpPanel.get2DHub().setValence(atom,valence);
      }
View Full Code Here

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

            while (st.hasMoreTokens()) {
                IAtom atom = container
                        .getAtom(Integer.parseInt(st.nextToken()) - 1);
                rendererModel.getToolTipTextMap().put(atom, st.nextToken());
            }
            rendererModel.setShowTooltip(true);
        }
View Full Code Here

    }
    if(atomsInRange==null)
      return;
    ChangeSingleElectronModule newActiveModule = null;
    while(atomsInRange.hasNext()){
            IAtom atom = atomsInRange.next();
            if(type.equals("add")){
                jcpPanel.get2DHub().addSingleElectron(atom);
                logger.info("Added single electron to atom");
                newActiveModule = new ChangeSingleElectronModule(jcpPanel.get2DHub(), true);
            }else{
View Full Code Here

      changeModeListeners.get(i).modeChanged(this.activeDrawModule);
  }

  // OK
  public IAtom getClosestAtom(Point2d worldCoord) {
    IAtom closestAtom = null;
    double closestDistanceSQ = Double.MAX_VALUE;

    for (IAtomContainer atomContainer : ChemModelManipulator
        .getAllAtomContainers(chemModel)) {
View Full Code Here

      atomsInRange = atoms.iterator();
    }
    if(atomsInRange==null)
      return;
    while(atomsInRange.hasNext()){
      IAtom atom = atomsInRange.next();
          int newCharge = charge;
          if( atom.getFormalCharge() != null)
              newCharge += atom.getFormalCharge();
          jcpPanel.get2DHub().setCharge(atom, newCharge);
    }
    jcpPanel.get2DHub().updateView();
  }
View Full Code Here

TOP

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

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.