@Test
  public void testDelete() {
    // given
    map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.5, 0.5, 0);

    map.addConcept(c1);

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

    Node concept = conceptMapView.lookup(".concept");

    // when
    moveTo(concept).doubleClickOn(MouseButton.PRIMARY);

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

    // then
    assertSame(0, concepts.size());
  }
  @Test
  public void testNoDuplicateLinkOnLayoutUndirected() {
    this.map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.3, 0.3, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c1.setPosition(0.6, 0.6, 30);

    map.addConcept(c1);
    map.addConcept(c2);

    map.addUndirectedLink(c1, c2);

    // when

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

    Set<Node> linkCaptions = conceptMapView.lookupAll(".link");

    assertEquals(1, linkCaptions.size());
  }
Esempio n. 3
0
  private void writeConceptList() throws XMLStreamException {
    out.writeStartElement("concept-list");
    for (int i = 0; i < cmap.getConceptCount(); i++) {
      Concept c = cmap.getConcept(i);
      String id = "c" + String.valueOf(i);
      String label = c.getName().getContent();

      out.writeStartElement("concept");
      out.writeAttribute("id", id);
      out.writeAttribute("label", label);
      out.writeEndElement();
    }
    out.writeEndElement();
  }
  @Test
  public void testConceptDelete() {
    // given
    map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.5, 0.5, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c1.setPosition(0.7, 0.7, 30);

    map.addConcept(c1);
    map.addConcept(c2);
    map.addUndirectedLink(c1, c2);

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

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

    Iterator<Node> iterator = concepts.iterator();

    Node firstConceptView = iterator.next();

    // when
    moveTo(firstConceptView).doubleClickOn(MouseButton.PRIMARY);

    // then
    concepts = conceptMapView.lookupAll(".concept");

    iterator = concepts.iterator();

    assertEquals(map.getConceptCount(), 1);
    assertEquals(c2, map.getConcept(0));
    assertEquals(concepts.size(), 1);
  }
  @Test
  public void testLink() {
    // given
    map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.8, 0.5, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c2.setPosition(0.5, 0.3, 30);

    map.addConcept(c1);
    map.addConcept(c2);

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

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

    Iterator<Node> iterator = concepts.iterator();

    Node firstConceptView = iterator.next();
    Node secondConceptView = iterator.next();

    // when
    moveTo(firstConceptView)
        .press(MouseButton.PRIMARY)
        .moveTo(secondConceptView)
        .release(MouseButton.PRIMARY);

    // then
    assertTrue(map.isAnyLinkExisting(c1, c2));
    assertFalse(
        firstConceptView.getBoundsInParent().intersects(secondConceptView.getBoundsInParent()));
  }
  @Test
  public void testRotateLinkCaption() {
    this.map.clear();

    User user = map.getExperiment().getParticipants().get(2);
    Concept c1 = new Concept(new CollaborativeString(user, FIRST_CONCEPT));
    c1.setPosition(0.2, 0.5, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c2.setPosition(0.4, 0.4, 0);

    map.addConcept(c1);
    map.addConcept(c2);

    map.addUndirectedLink(c1, c2).getCaption().append(user, "hunts");

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

    Node linkCaption = conceptMapView.lookup(".link");

    double rotate = linkCaption.getRotate();
    int scrollAmount = 100;

    // when
    moveTo(linkCaption)
        .sleep(1000)
        .press(MouseButton.PRIMARY)
        .sleep(5000)
        .scroll(scrollAmount)
        .release(MouseButton.PRIMARY);

    // then
    assertEquals(rotate + 180, linkCaption.getRotate(), 0.0);
  }
  @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());
  }
  @Test
  public void testLinkDelete() {
    // given
    map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.5, 0.5, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c2.setPosition(0.7, 0.7, 30);

    Concept c3 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(3), THIRD_CONCEPT));
    c3.setPosition(0.7, 0.2, 0);

    map.addConcept(c1);
    map.addConcept(c2);
    map.addConcept(c3);

    map.addUndirectedLink(c1, c2);
    map.addDirectedLink(c1, c3);

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

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

    // when
    for (Node link : links) moveTo(link).doubleClickOn(MouseButton.PRIMARY);

    // then
    concepts = conceptMapView.lookupAll(".concept");

    assertEquals(3, map.getConceptCount());
    assertEquals(3, concepts.size());
    assertNull(conceptMapView.lookup(".link"));
    assertNull(map.getLink(c1, c2));
    assertNull(map.getLink(c2, c1));
    assertNull(map.getLink(c1, c3));
  }
  @Test
  public void testLinkAnchorSelection() {
    // given
    map.clear();

    Concept c1 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(2), FIRST_CONCEPT));
    c1.setPosition(0.5, 0.5, 0);

    Concept c2 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(1), SECOND_CONCEPT));
    c2.setPosition(0.3, 0.5, 30);

    Concept c3 =
        new Concept(
            new CollaborativeString(map.getExperiment().getParticipants().get(3), THIRD_CONCEPT));
    c3.setPosition(0.7, 0.2, 0);

    map.addConcept(c1);
    map.addConcept(c2);
    map.addConcept(c3);

    map.addDirectedLink(c1, c2);
    map.addUndirectedLink(c2, c3);

    map.addDirectedLink(c1, c3);

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

    Set<Node> links = conceptMapView.lookupAll(".linkPath");

    Iterator<Node> iterator = links.iterator();
    Node link1 = iterator.next();
    Node link2 = iterator.next();

    // when
    moveTo(link1).clickOn(MouseButton.PRIMARY);

    ObservableList<Node> children = conceptMapView.getChildren();
    Node lookupAnchor = children.get(children.size() - 1);

    moveTo(lookupAnchor).clickOn(MouseButton.PRIMARY);

    moveTo(link1).clickOn(MouseButton.PRIMARY);

    // select second link
    moveTo(link2).clickOn(MouseButton.PRIMARY);

    children = conceptMapView.getChildren();
    lookupAnchor = children.get(children.size() - 1);

    moveTo(lookupAnchor).clickOn(MouseButton.PRIMARY);

    assertSame(0, conceptMapView.lookupAll(".anchorPolygon").size());
  }