Examples of IBond


Examples of org.openscience.cdk.interfaces.IBond

    }

    @Override
    public IRenderingElement generate(IAtomContainer ac, RendererModel model) {
        JChemPaintRendererModel jcpModel = (JChemPaintRendererModel) model;
        IBond bond = model.getHighlightedBond();
        if (bond != null && shouldHighlight(bond, jcpModel)) {
            super.ringSet = super.getRingSet(ac);
           
            double r = jcpModel.getHighlightDistance() / jcpModel.getScale();
            r /= 2.0;
            Color hColor = jcpModel.getHoverOverColor();
            Point2d p = bond.get2DCenter();
            boolean filled = jcpModel.getHighlightShapeFilled();
            return new OvalElement(p.x, p.y, r, filled, hColor);
        }
        return new ElementGroup();
    }
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

      }

      /* 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();) {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

    int apoIdx = 1;
    Map<Integer, IBond> apoBonds = new HashMap<Integer, IBond>();
    Iterator<IBond> bonds = root.bonds().iterator();
    // Pick up to two apo bonds randomly
    while (bonds.hasNext() && apoIdx <= 2) {
      IBond bond = bonds.next();
      if (bond.contains(rAtom)) {
        apoBonds.put((apoIdx), bond);
        apoIdx++;
      }
    }
    rootAttachmentPoints.put(rAtom, apoBonds);
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

    return closestAtom;
  }

  // OK
  public IBond getClosestBond(Point2d worldCoord) {
    IBond closestBond = null;
    double closestDistanceSQ = Double.MAX_VALUE;

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

Examples of org.openscience.cdk.interfaces.IBond

    ac.addAtom(atom);
    Iterator<IBond> connbonds = ChemModelManipulator
        .getRelevantAtomContainer(chemModel, atom)
        .getConnectedBondsList(atom).iterator();
    while (connbonds.hasNext()) {
      IBond connBond = connbonds.next();
      ac.addBond(connBond);
    }
    ChemModelManipulator.removeAtomAndConnectedElectronContainers(
        chemModel, atom);
    for (IBond bond : ac.bonds()) {
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

    undoRedoContainer.addAtom(addAtomWithoutUndo(atomType, atom,
        makePseudoAtom));
    IAtomContainer atomContainer = ChemModelManipulator
        .getRelevantAtomContainer(getIChemModel(), undoRedoContainer
            .getAtom(0));
    IBond newBond = atomContainer.getBond(atom, undoRedoContainer
        .getAtom(0));
    undoRedoContainer.addBond(newBond);
    if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) {
      IUndoRedoable undoredo = getUndoRedoFactory()
          .getAddAtomsAndBondsEdit(chemModel, undoRedoContainer,
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

    if (makePseudoAtom) {
      newAtom = chemModel.getBuilder().newInstance(IPseudoAtom.class,atomType);
    } else {
      newAtom = chemModel.getBuilder().newInstance(IAtom.class,atomType);
    }
    IBond newBond;
    if (order == IBond.Order.DOUBLE) {
      newBond = chemModel.getBuilder().newInstance(IBond.class,atom, newAtom,
          CDKConstants.BONDORDER_DOUBLE, stereo);
    } else if (order == IBond.Order.TRIPLE) {
      newBond = chemModel.getBuilder().newInstance(IBond.class,atom, newAtom,
          CDKConstants.BONDORDER_TRIPLE, stereo);
    } else {
      newBond = chemModel.getBuilder().newInstance(IBond.class,atom, newAtom,
          CDKConstants.BONDORDER_SINGLE, stereo);
    }

    IAtomContainer atomCon = ChemModelManipulator.getRelevantAtomContainer(
        chemModel, atom);
    if (atomCon == null) {
      atomCon = chemModel.getBuilder().newInstance(IAtomContainer.class);
      IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
      if (moleculeSet == null) {
        moleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
        chemModel.setMoleculeSet(moleculeSet);
      }
      moleculeSet.addAtomContainer(atomCon);
    }

    // The AtomPlacer generates coordinates for the new atom
    AtomPlacer atomPlacer = new AtomPlacer();
    atomPlacer.setMolecule(chemModel.getBuilder().newInstance(IAtomContainer.class,atomCon));
    double bondLength;
    if (atomCon.getBondCount() >= 1) {
      bondLength = GeometryTools.getBondLengthAverage(atomCon);
    } else {
      bondLength = calculateAverageBondLength(chemModel.getMoleculeSet());
    }

    // determine the atoms which define where the
    // new atom should not be placed
    List<IAtom> connectedAtoms = atomCon.getConnectedAtomsList(atom);

    if (connectedAtoms.size() == 0) {
      Point2d newAtomPoint = new Point2d(atom.getPoint2d());
      double angle = Math.toRadians(-30);
      Vector2d vec1 = new Vector2d(Math.cos(angle), Math.sin(angle));
      vec1.scale(bondLength);
      newAtomPoint.add(vec1);
      newAtom.setPoint2d(newAtomPoint);
    } else if (connectedAtoms.size() == 1) {
      IAtomContainer ac = atomCon.getBuilder().newInstance(IAtomContainer.class);
      ac.addAtom(atom);
      ac.addAtom(newAtom);
      Point2d distanceMeasure = new Point2d(0, 0); // XXX not sure about
      // this?
      IAtom connectedAtom = connectedAtoms.get(0);
      Vector2d v = atomPlacer.getNextBondVector(atom, connectedAtom,
          distanceMeasure, true);
      atomPlacer.placeLinearChain(ac, v, bondLength);
    } else {
      IAtomContainer placedAtoms = atomCon.getBuilder().newInstance(IAtomContainer.class);
      for (IAtom conAtom : connectedAtoms)
        placedAtoms.addAtom(conAtom);
      Point2d center2D = GeometryTools.get2DCenter(placedAtoms);

      IAtomContainer unplacedAtoms = atomCon.getBuilder()
          .newInstance(IAtomContainer.class);
      unplacedAtoms.addAtom(newAtom);

      atomPlacer.distributePartners(atom, placedAtoms, center2D,
          unplacedAtoms, bondLength);
    }

    atomCon.addAtom(newAtom);
    atomCon.addBond(newBond);
    updateAtom(newBond.getAtom(0));
    updateAtom(newBond.getAtom(1));

    // shift the new atom a bit if it is in range of another atom
    JChemPaintRendererModel model = this.getRenderer().getRenderer2DModel();
    double nudgeDistance = model.getHighlightDistance() / model.getScale();
    if (getClosestAtom(newAtom) != null)
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

    undoRedoContainer.addAtom(newAtom);

    IAtomContainer atomContainer = ChemModelManipulator
        .getRelevantAtomContainer(getIChemModel(), newAtom);

    IBond newBond = atomContainer.getBond(atom, newAtom);
    undoRedoContainer.addBond(newBond);
    updateAtom(newBond.getAtom(0));
    updateAtom(newBond.getAtom(1));

    structureChanged();
    if (undoredofactory != null && undoredohandler != null) {
      IUndoRedoable undoredo = undoredofactory.getAddAtomsAndBondsEdit(
          getIChemModel(), undoRedoContainer, null, "Add Bond", this);
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

        .newInstance(IAtomContainer.class);

    // XXX these calls would not be necessary if addAtom returned a bond
    IAtomContainer atomContainer = ChemModelManipulator
        .getRelevantAtomContainer(getIChemModel(), newAtom);
    IBond newBond = atomContainer.getBond(atom, newAtom);

    if (desiredDirection == Direction.UP) {
      newBond.setStereo(IBond.Stereo.UP);
    } else if (desiredDirection == Direction.DOWN) {
      newBond.setStereo(IBond.Stereo.DOWN);
    } else if (desiredDirection == Direction.UNDEFINED) {
      newBond.setStereo(IBond.Stereo.UP_OR_DOWN);
    } else {
      newBond.setStereo(IBond.Stereo.E_OR_Z);
    }
    undoRedoContainer.addAtom(newAtom);
    undoRedoContainer.addBond(newBond);
    if (getUndoRedoFactory() != null && getUndoRedoHandler() != null) {
      IUndoRedoable undoredo = getUndoRedoFactory()
View Full Code Here

Examples of org.openscience.cdk.interfaces.IBond

   * org.openscience.cdk.controller.IChemModelRelay#addBond(org.openscience
   * .cdk.interfaces.IAtom, org.openscience.cdk.interfaces.IAtom, int)
   */
  public IBond addBond(IAtom fromAtom, IAtom toAtom, IBond.Stereo stereo,
      IBond.Order order) {
    IBond newBond = chemModel.getBuilder().newInstance(IBond.class,fromAtom, toAtom, order,
        stereo);
    IAtomContainer fromContainer = ChemModelManipulator
        .getRelevantAtomContainer(chemModel, fromAtom);
    IAtomContainer toContainer = ChemModelManipulator
        .getRelevantAtomContainer(chemModel, toAtom);

    // we need to check if this merges two atom containers or not
    if (fromContainer != toContainer) {
      fromContainer.add(toContainer);
      chemModel.getMoleculeSet().removeAtomContainer(toContainer);
    }
    fromContainer.addBond(newBond);
    updateAtom(newBond.getAtom(0));
    updateAtom(newBond.getAtom(1));
    structureChanged();
    return newBond;
  }
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.