Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IBond


        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)) {
              lsel = (LogicalSelection)sel;
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);
                    else container.addBond(bond);
                }
                LogicalSelection logSel = new LogicalSelection(LogicalSelection.Type.ALL);
                logSel.select(container);
View Full Code Here

        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) {
View Full Code Here

        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
View Full Code Here

        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 );
View Full Code Here

            //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

        // 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);
            }
        }

        if (factory != null && handler != null) {
View Full Code Here

    //    containerToAddTo.add(removedAtomContainer);
    //    chemModel.getMoleculeSet().removeAtomContainer(removedAtomContainer);
    //}

    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);
View Full Code Here

         */
        protected IAtomContainer getSelectedAtomContainer(Point2d worldCoord) {
                JChemPaintRendererModel rModel =
                                                        chemModelRelay.getRenderer().getRenderer2DModel();
                IAtom atom = chemModelRelay.getClosestAtom(worldCoord);
                IBond bond = chemModelRelay.getClosestBond(worldCoord);

                IChemObjectSelection localSelection = rModel.getSelection();
                IChemObject chemObject = getHighlighted(worldCoord, atom, bond);

                if (localSelection==null || !localSelection.contains(chemObject)) {
View Full Code Here

  public void redo() {
    Set<IBond> keys = changedBondOrders.keySet();
    Iterator<IBond> it = keys.iterator();
    while (it.hasNext()) {
      IBond bond = (IBond) it.next();
      IBond.Order[] bondOrders = changedBondOrders.get(bond);
      bond.setOrder(bondOrders[0]);
      chemModelRelay.updateAtom(bond.getAtom(0));
      chemModelRelay.updateAtom(bond.getAtom(1));
    }
    Set<IBond> keysstereo = changedBondsStereo.keySet();
    Iterator<IBond> itint = keysstereo.iterator();
    while (itint.hasNext()) {
      IBond bond = (IBond) itint.next();
      IBond.Stereo[] bondStereos = changedBondsStereo.get(bond);
      bond.setStereo(bondStereos[0]);
    }
  }
View Full Code Here

TOP

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

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.