@Test
  public void testConceptNewJump() {
    // given
    Set<Node> newButtons = conceptMapView.lookupAll(".newBtnTop");
    Node firstNewButton = newButtons.iterator().next();

    moveTo(firstNewButton).press(MouseButton.PRIMARY).release(MouseButton.PRIMARY);
    Node concept = conceptMapView.lookup(".concept");

    double expectedX = concept.getLayoutX() + concept.getTranslateX();
    double expectedY = concept.getLayoutY() + concept.getTranslateY();

    // when

    super.interact(
        () -> {
          stage.setFullScreen(false);
          stage.setWidth(stage.getWidth() - 40);
          stage.setHeight(stage.getHeight() - 40);
        });

    // then

    double actualX = concept.getLayoutX() + concept.getTranslateX();
    double actualY = concept.getLayoutY() + concept.getTranslateY();

    assertEquals(expectedX, actualX, 50);
    assertEquals(expectedY, actualY, 50);
  }
Ejemplo n.º 2
0
  public void centerResidues() {
    double globalCenterX = 0d;
    double globalCenterY = 0d;
    double globalCenterZ = 0d;
    int count = 0;

    for (Residue res : residueList) {
      for (Atom atom : res.getAtomList()) {
        globalCenterX += atom.getCoordinates()[0];
        globalCenterY += atom.getCoordinates()[1];
        globalCenterZ += atom.getCoordinates()[2];
      }
      count += res.getAtomList().size();
    }

    globalCenterX /= count;
    globalCenterY /= count;
    globalCenterZ /= count;

    for (Node node : root.pdbObjects.getChildren()) {

      node.setTranslateX(node.getTranslateX() - globalCenterX);
      node.setTranslateY(node.getTranslateY() - globalCenterY);
      node.setTranslateZ(node.getTranslateZ() - globalCenterZ);
    }
  }
  @Test
  public void testLayoutWithConceptAdded() {
    int conceptCount = map.getConceptCount();

    Concept c =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(0), FIRST_CONCEPT));
    double x = 0.4;
    double y = 0.4;
    c.setPosition(x, y, 0);

    map.addConcept(c);

    // when
    super.interact(
        () -> {
          controller.setConceptMap(map);
          controller.layout();
        });

    // then

    Set<Node> concepts = conceptMapView.lookupAll(".concept");

    assertEquals(conceptCount + 1, concepts.size());
    assertEquals(conceptCount + 1, map.getConceptCount());
    Node addedConcept = concepts.iterator().next();

    double xScaled = addedConcept.getLayoutX() + addedConcept.getTranslateX();
    double yScaled = addedConcept.getLayoutY() + addedConcept.getTranslateY();

    assertEquals(x * scene.getWidth(), xScaled, 0.5);
    assertEquals(y * scene.getHeight(), yScaled, 0.5);

    Label caption = (Label) addedConcept.lookup("#caption");
    assertEquals(FIRST_CONCEPT, caption.getText());
  }