示例#1
0
  public void testItShouldUpdateItsCoordinatesWhenMoved() {
    Molecule molecule = new DefaultMolecule();
    Atom atom = molecule.addAtom("C");

    atom.move(100, 100, 0);

    assertEquals(100d, atom.getX());
    assertEquals(100d, atom.getY());
    assertEquals(0d, atom.getZ());
  }
示例#2
0
  public Atom getClosestAtom(Point2D graphCord) {
    Atom closestAtom = null;
    double closestDistance = Double.MAX_VALUE;

    for (int i = 0; i < molecule.countAtoms(); i++) {
      Atom currentAtom = molecule.getAtom(i);
      Point2D currentPointGraph =
          realCordToGraphCord(new Point2D(currentAtom.getX(), currentAtom.getY()));
      double distance = GeometryTools.calcDistance(graphCord, currentPointGraph);

      if (distance <= renderer.getRendererModel().getAtomRadius() && distance < closestDistance) {
        closestAtom = currentAtom;
        closestDistance = distance;
      }
    }
    return closestAtom;
  }