Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtom


        }
    }

    public void mouseClickedDown(Point2d worldCoord) {

        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);
        double dA = super.distanceToAtom(closestAtom, worldCoord);
        if(dA>getHighlightDistance())
            closestAtom=null;
        String[] funcGroupsKeys=new String[funcgroupsmap.keySet().size()+1];
        Iterator<String> it=funcgroupsmap.keySet().iterator();
        int h=1;
        funcGroupsKeys[0]="";
        while(it.hasNext()){
            funcGroupsKeys[h]=(String)it.next();
            h++;
        }
        String x=EnterElementOrGroupDialog.showDialog(null,null, "Enter an element symbol or choose/enter a functional group abbreviation:", "Enter element", funcGroupsKeys, "","");
        try{
            IAtomContainer ac=(IAtomContainer)funcgroupsmap.get(x.toLowerCase());
            //this means a functional group was entered
            if(ac!=null && !x.equals("")){
                IAtomContainer container = ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), closestAtom);
                IAtom lastplaced=null;
                int counter=0;
                //this is the starting point for placing
                lastplaced=closestAtom;
                counter=1;
                if(container==null){
View Full Code Here


    public AbstractSelectModule(IChemModelRelay chemModelRelay) {
        super(chemModelRelay);
    }

  private IAtom getClosestSelAtom(Point2d worldCoord) {
    IAtom closestAtom = null;
    IChemObjectSelection sel = chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
    double closestDistanceSQ = Double.MAX_VALUE;

    for (IAtom atom : sel.elements(IAtom.class)) {
      if (atom.getPoint2d() != null) {
View Full Code Here

        boolean inSelectionCircle = false;
        JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
        IChemObjectSelection sel = model.getSelection();
        if (sel == null) return;
        double d = model.getSelectionRadius() / model.getScale();
        IAtom closestAtom = null;
        IBond closestBond = null;
        IAtom highlitAtom = model.getHighlightedAtom();
        IBond highlitBond = model.getHighlightedBond();
        if(from.equals(startPoint)) {
          LogicalSelection lsel = null;
          boolean isAllSelected = false;
            if (sel.getClass().isAssignableFrom(LogicalSelection.class)) {
View Full Code Here

        boolean shiftPressed = (modifiers & MouseEvent.SHIFT_DOWN_MASK) != 0;

        if(p.equals(startPoint)){
           
            IAtom closestAtom = chemModelRelay.getClosestAtom(p);
            IBond closestBond = chemModelRelay.getClosestBond(p);
            IChemObject singleSelection = getHighlighted( p,
                    closestAtom,
                    closestBond );

            IChemObjectSelection curSel = chemModelRelay.getRenderer().getRenderer2DModel().getSelection();
            IChemObjectSelection sel = null;
            if (shiftPressed && curSel != null && curSel.isFilled()) {
                IAtomContainer container = new AtomContainer(curSel.getConnectedAtomContainer());               
                if (singleSelection instanceof IAtom) {
                    IAtom atom = (IAtom) singleSelection;
                    if (!container.contains(atom))  container.addAtom(atom);
                    else container.removeAtom(atom);
                } else if (singleSelection instanceof IBond) {
                    IBond bond = (IBond) singleSelection;
                    if (!container.contains(bond))  container.addBond(bond);
View Full Code Here

  }

  public void mouseClickedDown(Point2d worldCoord) {
    JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
    double dH = model.getHighlightDistance() / model.getScale();
    IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);

    if(closestAtom == null || closestAtom.getPoint2d().distance(worldCoord) > dH)
      startAtom = null;
    else
      startAtom = chemModelRelay.getClosestAtom(worldCoord);
  }
View Full Code Here

  }
 
  public void mouseClickedUp(Point2d worldCoord){
    JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
    double dH = model.getHighlightDistance() / model.getScale();
    IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);

    IAtom endAtom = null;
    if(closestAtom != null && closestAtom.getPoint2d().distance(worldCoord) < dH)
      endAtom = chemModelRelay.getClosestAtom(worldCoord);
    if(endAtom!=null && startAtom!=null){
      IMapping mapping = startAtom.getBuilder().newInstance(IMapping.class,startAtom, endAtom);
      // ok, now figure out if they are in one reaction
View Full Code Here

        newring.removeBond(bond);
        return newring;
    }

    public void mouseClickedDown(Point2d worldCoord) {
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);
        IBond closestBond = chemModelRelay.getClosestBond(worldCoord);

        IChemObject singleSelection = getHighlighted( worldCoord,
                                                      closestAtom,closestBond );

        if (singleSelection == null) {
            //we add the ring
        IRing newRing = this.addRingToEmptyCanvas(worldCoord);
            chemModelRelay.getRenderer().getRenderer2DModel().getMerge().clear();
            //we look if it would merge
            for(IAtom atom : newRing.atoms()){
                IAtom closestAtomInRing = this.chemModelRelay.getClosestAtom(atom);
                if( closestAtomInRing != null) {
                        chemModelRelay.getRenderer().getRenderer2DModel().getMerge().put(atom, closestAtomInRing);
                }
            }
            //if we need to merge, we first move the ring so that the merge atoms
            //are exactly on top of each other - if not doing this, rings get distorted.
            if(chemModelRelay.getRenderer().getRenderer2DModel().getMerge().size()>0){
                try {
                    IAtom toleave = chemModelRelay.getRenderer().getRenderer2DModel().getMerge().keySet().iterator().next();
                    IAtom toshift = (IAtom)chemModelRelay.getRenderer().getRenderer2DModel().getMerge().get(chemModelRelay.getRenderer().getRenderer2DModel().getMerge().keySet().iterator().next()).clone();
                    toleave.getPoint2d().sub(toshift.getPoint2d());
                    Point2d pointSub = new Point2d(toleave.getPoint2d().x, toleave.getPoint2d().y);
                    for(IAtom atom: newRing.atoms()){
                        atom.getPoint2d().sub(pointSub);
                    }
                } catch (CloneNotSupportedException e) {
View Full Code Here

    public void mouseMove(Point2d worldCoord) {
        if ((System.nanoTime() - drawTime) < 4000000) {
            return;
        }
        this.chemModelRelay.clearPhantoms();
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);
        IBond closestBond = chemModelRelay.getClosestBond(worldCoord);
        IChemObject singleSelection = getHighlighted( worldCoord,
                closestAtom,closestBond );

        if (singleSelection == null) {
            //we build a phantom ring
            IRing ring = this.chemModelRelay.getIChemModel().getBuilder().newInstance(IRing.class,ringSize, "C");
            if (addingBenzene) {
                ring.getBond(0).setOrder(IBond.Order.DOUBLE);
                ring.getBond(2).setOrder(IBond.Order.DOUBLE);
                ring.getBond(4).setOrder(IBond.Order.DOUBLE);
            }
            double bondLength = ((ControllerHub)this.chemModelRelay).calculateAverageBondLength(this.chemModelRelay.getIChemModel().getMoleculeSet());
           
            ringPlacer.placeRing(ring, worldCoord, bondLength, RingPlacer.jcpAngles);
           
            for(IAtom atom : ring.atoms())
                this.chemModelRelay.addPhantomAtom(atom);
            for(IBond atom : ring.bonds())
                this.chemModelRelay.addPhantomBond(atom);
            //and look if it would merge somewhere
            chemModelRelay.getRenderer().getRenderer2DModel().getMerge().clear();
            for(IAtom atom : ring.atoms()){
                IAtom closestAtomInRing = this.chemModelRelay.getClosestAtom(atom);
                if( closestAtomInRing != null) {
                        chemModelRelay.getRenderer().getRenderer2DModel().getMerge().put(closestAtomInRing, atom);
                }
            }
        } else if (singleSelection instanceof IAtom) {
View Full Code Here

    for (int i = 0; i < undoRedoContainer.getBondCount(); i++) {
      IBond bond = undoRedoContainer.getBond(i);
      containerToAddTo.addBond(bond);
    }
    for (int i = 0; i < undoRedoContainer.getAtomCount(); i++) {
      IAtom atom = undoRedoContainer.getAtom(i);
      containerToAddTo.addAtom(atom);
      chemModelRelay.updateAtom(atom);
    }
  }
View Full Code Here

    public void redo() {
        Set<IAtom> keys = atomCoordsMap.keySet();
        Iterator<IAtom> it = keys.iterator();
        while (it.hasNext()) {
            IAtom atom = it.next();
            Point2d[] coords = atomCoordsMap.get(atom);
            atom.setNotification(false);
            atom.setPoint2d(coords[0]);
            atom.setNotification(true);
        }
    }
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.