Package javax.vecmath

Examples of javax.vecmath.Vector2d


    IRing newRing = createAttachRing(sharedAtoms, ringSize, "C", phantom);
    double bondLength = GeometryTools.getBondLengthAverage(sourceContainer);
    Point2d conAtomsCenter = getConnectedAtomsCenter(sharedAtoms, chemModel);

    Point2d sharedAtomsCenter = atom.getPoint2d();
    Vector2d ringCenterVector = new Vector2d(sharedAtomsCenter);
    ringCenterVector.sub(conAtomsCenter);

    if ((ringCenterVector.x == 0 && ringCenterVector.y == 0)) {
      // Rare bug case:
      // the spiro ring can not be attached, it will lead
      // to NaN values deeper down and serious picture distortion.
View Full Code Here


      bondLength = GeometryTools.getBondLengthAverage(sourceContainer);
      Point2d conAtomsCenter = getConnectedAtomsCenter(sharedAtoms,
          chemModel);

      Point2d sharedAtomsCenter = atom.getPoint2d();
      Vector2d ringCenterVector = new Vector2d(sharedAtomsCenter);
      ringCenterVector.sub(conAtomsCenter);

      if ((ringCenterVector.x == 0 && ringCenterVector.y == 0)) {
        return chemModel.getBuilder().newInstance(IRing.class);
      } else {
        ringPlacer.placeSpiroRing(newRing, sharedAtoms,
View Full Code Here

    // calculate two points that are perpendicular to the highlighted bond
    // and have a certain distance from the bond center
    Point2d firstPoint = firstAtom.getPoint2d();
    Point2d secondPoint = secondAtom.getPoint2d();
    Vector2d diff = new Vector2d(secondPoint);
    diff.sub(firstPoint);
    double bondLength = firstPoint.distance(secondPoint);
    double angle = GeometryTools.getAngle(diff.x, diff.y);
    Point2d newPoint1 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle + (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle + (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);
    Point2d newPoint2 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle - (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle - (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);

    // decide on which side to draw the ring??
    IAtomContainer connectedAtoms = bond.getBuilder().newInstance(IAtomContainer.class);
    for (IAtom atom : sourceContainer.getConnectedAtomsList(firstAtom)) {
      if (atom != secondAtom)
        connectedAtoms.addAtom(atom);
    }
    for (IAtom atom : sourceContainer.getConnectedAtomsList(secondAtom)) {
      if (atom != firstAtom)
        connectedAtoms.addAtom(atom);
    }
    Point2d conAtomsCenter = GeometryTools.get2DCenter(connectedAtoms);
    double distance1 = newPoint1.distance(conAtomsCenter);
    double distance2 = newPoint2.distance(conAtomsCenter);
    Vector2d ringCenterVector = new Vector2d(sharedAtomsCenter);
    if (distance1 < distance2) {
      ringCenterVector.sub(newPoint1);
    } else { // distance2 <= distance1
      ringCenterVector.sub(newPoint2);
    }

    // construct a new Ring that contains the highlighted bond an its two
    // atoms
    IRing newRing = createAttachRing(sharedAtoms, size, "C", phantom);
View Full Code Here

    // calculate two points that are perpendicular to the highlighted bond
    // and have a certain distance from the bond center
    Point2d firstPoint = firstAtom.getPoint2d();
    Point2d secondPoint = secondAtom.getPoint2d();
    Vector2d diff = new Vector2d(secondPoint);
    diff.sub(firstPoint);
    double bondLength = firstPoint.distance(secondPoint);
    double angle = GeometryTools.getAngle(diff.x, diff.y);
    Point2d newPoint1 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle + (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle + (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);
    Point2d newPoint2 = new Point2d( // FIXME: what is this point??
        (Math.cos(angle - (Math.PI / 2)) * bondLength / 4)
            + sharedAtomsCenter.x, (Math.sin(angle - (Math.PI / 2))
            * bondLength / 4)
            + sharedAtomsCenter.y);

    // decide on which side to draw the ring??
    IAtomContainer connectedAtoms = bond.getBuilder().newInstance(IAtomContainer.class);
    for (IAtom atom : sourceContainer.getConnectedAtomsList(firstAtom)) {
      if (atom != secondAtom)
        connectedAtoms.addAtom(atom);
    }
    for (IAtom atom : sourceContainer.getConnectedAtomsList(secondAtom)) {
      if (atom != firstAtom)
        connectedAtoms.addAtom(atom);
    }
    Point2d conAtomsCenter = GeometryTools.get2DCenter(connectedAtoms);
    double distance1 = newPoint1.distance(conAtomsCenter);
    double distance2 = newPoint2.distance(conAtomsCenter);
    Vector2d ringCenterVector = new Vector2d(sharedAtomsCenter);
    if (distance1 < distance2) {
      ringCenterVector.sub(newPoint1);
    } else { // distance2 <= distance1
      ringCenterVector.sub(newPoint2);
    }

    // construct a new Ring that contains the highlighted bond an its two
    // atoms
    IRing newRing = createAttachRing(sharedAtoms, 6, "C", phantom);
View Full Code Here

      IAtomContainer movedAtomContainer = renderer.getRenderer2DModel()
          .getSelection().getConnectedAtomContainer();
      if (movedAtomContainer != null) {
        IAtom atomA = (IAtom) it.next();
        IAtom atomB = mergeMap.get(atomA);
        Vector2d shift = new Vector2d();
        shift.sub(atomB.getPoint2d(), atomA.getPoint2d());

        for (IAtom shiftAtom : movedAtomContainer.atoms()) {
          shiftAtom.getPoint2d().add(shift);
        }
      }
View Full Code Here

        IAtomContainerSet moleculeSet = super.chemModelRelay.getChemModel().getMoleculeSet();
        if (moleculeSet.getAtomContainerCount() == 0 || (moleculeSet.getAtomContainerCount() == 1 && moleculeSet.getAtomContainer(0).getAtomCount() == 0)) {
            return;
        }
       
        final Vector2d unit = newUnitVector(startPoint, endPoint);
        final Vector2d perp = new Vector2d(unit.y, -unit.x);
       
        List<IAtomContainer> reactants = new ArrayList<IAtomContainer>(2);
        List<IAtomContainer> products = new ArrayList<IAtomContainer>(2);
       
        // determine the reactants and products of a reaction we do this by
View Full Code Here

       
       
    }
   
    static Vector2d newUnitVector(Point2d a, Point2d b) {
        Vector2d v = new Vector2d(b.x - a.x,
                                  b.y - a.y);
        v.normalize();
        return v;
    }
View Full Code Here

            renderer.toScreenCoordinates( worldCoord.x, worldCoord.y );
        zoom(z);
        Point2d newScreenCoords =
            renderer.toScreenCoordinates( worldCoord.x, worldCoord.y );
       
        Vector2d v= new Vector2d();
        v.sub( screenCoord, newScreenCoords );
        renderer.shiftDrawCenter( v.x, v.y );
    }
View Full Code Here

                }
            }

            Point2d current = GeometryTools.get2DCenter(selectedAC);
            start2DCenter = current;
            offset = new Vector2d();
            offset.sub(current, worldCoord);

         } else if(switchtowhenoutside!=null){
            this.chemModelRelay.getRenderer().getRenderer2DModel()
                .setSelection(AbstractSelection.EMPTY_SELECTION);
View Full Code Here

    }


    public void mouseClickedUp(Point2d worldCoord) {
      if (start2DCenter != null) {
            Vector2d end = new Vector2d();

            // take 2d center of end point to ensure correct positional undo
            Point2d end2DCenter = GeometryTools.get2DCenter(atomsToMove);
            end.sub(end2DCenter, start2DCenter);

            Map<IAtom, IAtom> mergeMap = calculateMerge(atomsToMove);
            JChemPaintRendererModel model = chemModelRelay.getRenderer().getRenderer2DModel();
            model.getMerge().clear();
            model.getMerge().putAll(mergeMap);

            // Do the merge of atoms
            if (!mergeMap.isEmpty()) {
                try {
          chemModelRelay.mergeMolecules(end);
        } catch (RuntimeException e) {
          //move things back, merge is not allowed
                Vector2d d = new Vector2d();
                d.sub(start2DCenter,end2DCenter);
          chemModelRelay.moveBy(atomsToMove, d, null);
                chemModelRelay.updateView();
        }
            }else {
                chemModelRelay.moveBy(atomsToMove, null, end);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector2d

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.