Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IAtom


        }
  }
 
    public void mouseDrag( Point2d worldCoordFrom, Point2d worldCoordTo ) {
        if(isBond) return;
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoordTo);

        merge =  (IAtom) getHighlighted(worldCoordTo, closestAtom);


        chemModelRelay.clearPhantoms();
        if(start.distance( worldCoordTo )<getHighlightDistance()) {
            // clear phantom
            merge = null;
            dest = null;
        }else if (merge != null) {
            // set bond
            chemModelRelay.addPhantomBond( chemModelRelay.getIChemModel()
                .getBuilder().newInstance(IBond.class,source,merge) );
            dest = null;

        }else {
            dest = AddBondDragModule.roundAngle(start, worldCoordTo, bondLength );
            IAtom atom = chemModelRelay.getIChemModel().getBuilder().
              newInstance(IAtom.class, chemModelRelay.getController2DModel().getDrawElement(), dest );
            IBond bond = chemModelRelay.getIChemModel().getBuilder().
              newInstance(IBond.class, source, atom, IBond.Order.SINGLE, stereoForNewBond );
            chemModelRelay.addPhantomBond( bond );
            // update phantom
View Full Code Here


        // Make a bond of DrawBondType from the atom to a new atom of DrawElement
        //-Clicked in empty and not dragged more than highligt distance:
        // Make new atom
        //-Clicked in empty and dragged more than hightligh distance:
        // Make a bond of DrawBondType with two new atoms of DrawElement
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);
        JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
        double dH = model.getHighlightDistance() / model.getScale();
        IAtom newAtom;
        if(newSource){
            newAtom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), start, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
        }else{
            newAtom = source;
        }
        if(start.distance(worldCoord)>dH){
            if(dest==null)
                dest=worldCoord;

            IAtom atom = chemModelRelay.addAtom( chemModelRelay.getController2DModel().getDrawElement(), chemModelRelay.getController2DModel().getDrawIsotopeNumber(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
            if(chemModelRelay.getController2DModel().getDrawIsotopeNumber()!=0)
                atom.setMassNumber(chemModelRelay.getController2DModel().getDrawIsotopeNumber());

            IUndoRedoFactory factory = chemModelRelay.getUndoRedoFactory();
            UndoRedoHandler handler = chemModelRelay.getUndoRedoHandler();
            IAtomContainer containerForUndoRedo = chemModelRelay.getIChemModel().getBuilder().newInstance(IAtomContainer.class);
            IBond bond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond);
View Full Code Here

        // in case we are starting on an empty canvas
        if(bondLength==0|| Double.isNaN(bondLength))
            bondLength=1.5;
       
        start = new Point2d(worldCoord);
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoord);
        IBond closestBond = chemModelRelay.getClosestBond( worldCoord );

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

        if(singleSelection == null || singleSelection instanceof IAtom ) {
            isBond = false;
            source =  (IAtom) getHighlighted(worldCoord, closestAtom);

            if(source == null) {
                source = getBuilder().newInstance(IAtom.class, chemModelRelay.getController2DModel().getDrawElement(), start );
                newSource = true;
            }
            else {
                // Take the true (x,y) of the atom, not the click point
                // otherwise it's very hard to draw a regular ring
                start = closestAtom.getPoint2d();
            }

        }
        else if (singleSelection instanceof IBond) {
            if(stereoForNewBond==IBond.Stereo.NONE){
View Full Code Here

    }

  @Override
    public void mouseDrag( Point2d worldCoordFrom, Point2d worldCoordTo ) {
        if(isBond) return;
        IAtom closestAtom = chemModelRelay.getClosestAtom(worldCoordTo);

        chemModelRelay.getRenderer().getRenderer2DModel().getMerge().remove(merge);
        merge =  (IAtom) getHighlighted(worldCoordTo, closestAtom);


        chemModelRelay.clearPhantoms();
        if(start.distance( worldCoordTo )<getHighlightDistance()) {
            // clear phantom
            merge = null;
            dest = null;
        }else if (merge != null) {
            // set bond
            chemModelRelay.addPhantomBond( getBuilder().newInstance(IBond.class,source,merge, orderForNewBond, stereoForNewBond) );
            dest = null;
            //we also remember the merge atom in the merges in the rendererModel,
            //in case an application uses these.
            chemModelRelay.getRenderer().getRenderer2DModel().getMerge().put(merge,merge);
        }else {
            dest = roundAngle( start, worldCoordTo, bondLength );
            IAtom atom = getBuilder().newInstance(IAtom.class, chemModelRelay.getController2DModel().getDrawElement(), dest );
            IBond bond = getBuilder().newInstance(IBond.class, source,atom, orderForNewBond, stereoForNewBond );
            chemModelRelay.addPhantomBond( bond );
            // update phantom
        }
        chemModelRelay.updateView();
View Full Code Here

        IUndoRedoFactory factory = chemModelRelay.getUndoRedoFactory();
        UndoRedoHandler handler = chemModelRelay.getUndoRedoHandler();
        IAtomContainer containerForUndoRedo = chemModelRelay.getIChemModel().getBuilder().newInstance(IAtomContainer.class);
       
        IAtom newAtom;
        if(newSource) {
            newAtom = chemModelRelay.addAtomWithoutUndo( chemModelRelay.getController2DModel().getDrawElement(), start, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
            containerForUndoRedo.addAtom(newAtom);
        }
        else
            newAtom = source;

        // if merge is set either form a bond or add and form
        IAtomContainer removedContainer=null;
        if(merge!=null) {
                chemModelRelay.getRenderer().getRenderer2DModel().getMerge().remove(merge);
                removedContainer = ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), merge);
                IBond newBond = chemModelRelay.addBond( newAtom , merge, stereoForNewBond, orderForNewBond );
                containerForUndoRedo.addBond(newBond);
        } else {
            if(start.distance( worldCoord )<getHighlightDistance()) {
                if(!newSource) {
                    IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), newAtom, stereoForNewBond, orderForNewBond, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
                    containerForUndoRedo.addAtom(undoRedoAtom);
                    IAtomContainer atomCon =
                        ChemModelManipulator.getRelevantAtomContainer(chemModelRelay.getIChemModel(), undoRedoAtom);
                    containerForUndoRedo.addElectronContainer(atomCon.getConnectedElectronContainersList(undoRedoAtom).get(0));
                } else if(makeInitialBond){
                    IAtom undoRedoAtom=chemModelRelay.addAtomWithoutUndo(
                            chemModelRelay.getController2DModel().getDrawElement(),
                            new Point2d(newAtom.getPoint2d().x+1.5,newAtom.getPoint2d().y),
                            chemModelRelay.getController2DModel().getDrawPseudoAtom());
                    containerForUndoRedo.addAtom(undoRedoAtom);
                    containerForUndoRedo.addBond(chemModelRelay.addBond(newAtom, undoRedoAtom, stereoForNewBond, orderForNewBond));
                }
            }else {
                IAtom atom = chemModelRelay.addAtomWithoutUndo(chemModelRelay.getController2DModel().getDrawElement(), dest, chemModelRelay.getController2DModel().getDrawPseudoAtom() );
                containerForUndoRedo.addAtom(atom);
                IBond newBond = chemModelRelay.addBond( newAtom, atom, stereoForNewBond, orderForNewBond );
                containerForUndoRedo.addBond(newBond);
            }
        }
View Full Code Here

        return theDescriptorValue2dList;
    }

    private boolean __isMatchFunctionalGroup(int theAnnotatedAtomNumber, int theMoleculeIndex, String theFunctionalGroup) {
        IAtom theAnnotatedAtom = this.getNMRShiftDB().getMoleculeSet().getMolecule(theMoleculeIndex).getAtom(theAnnotatedAtomNumber);
        List<IAtom> theConnectedAtomList = this.getNMRShiftDB().getMoleculeSet().getMolecule(theMoleculeIndex).getConnectedAtomsList(theAnnotatedAtom);

        if (theConnectedAtomList.size() != 1) {
            return false;
        } else {
View Full Code Here

        return true;
    }

    private List<Double> __generateDescriptor(int theAnnotatedAtomNumber, int theIndexOfMolecule) {
        List<Double> theDescriptorList = this.__initializeDescriptorList();
        IAtom theAnnotatedAtom = this.getNMRShiftDB().getMoleculeSet().getMolecule(theIndexOfMolecule).getAtom(theAnnotatedAtomNumber);
        List<Double> theDistanceList = this.__getDistanceMatrixList().get(theIndexOfMolecule).getDistanceMatrix().get(theAnnotatedAtomNumber);
        Double theAnnotatedAtomRadius = this.__getAtomRadiusList().get(theAnnotatedAtom.getAtomicNumber());

        for (int ai = 0, aEnd = theDistanceList.size(); ai < aEnd; ai++) {
            IAtom theTestAtom = this.getNMRShiftDB().getMoleculeSet().getMolecule(theIndexOfMolecule).getAtom(ai);
            Double theTestAtomRadius = this.__getAtomRadiusList().get(theTestAtom.getAtomicNumber());
            List<Double> theTestList = new ArrayList<>();
            int theIndex = this.__getAtomSymbolIndex(this.getNMRShiftDB().getMoleculeSet().getMolecule(theIndexOfMolecule).getAtom(ai).getSymbol());

            for (Double li = this.MINIMUM_DISTANCE; li < this.MAXIMUM_DISTANCE; li += this.INTERVAL) {
                if (theDistanceList.get(ai) < theAnnotatedAtomRadius + theTestAtomRadius + li && theDistanceList.get(ai) != 0) {
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.