/** Helper method use to add some textField to the edge. */
  public void addTextFieldToEdge() {
    graphNode1 = new GraphNode();
    graphNode1.setContainer(graphEdge);
    graphNode1.setPosition(TestHelper.getWaypoint(25, 13));

    textField1 = test.addTextField(graphNode1, text, AnchorType.LeftEnding);

    graphNode2 = new GraphNode();
    graphNode2.setContainer(graphEdge);
    graphNode2.setPosition(TestHelper.getWaypoint(12, 13));

    // the anchorage will be set to (12, 10).
    textField2 = test.addTextField(graphNode2, text, AnchorType.Line);

    graphNode3 = new GraphNode();
    graphNode3.setContainer(graphEdge);
    graphNode3.setPosition(TestHelper.getWaypoint(8, 6));

    // the anchorage will be set to (7, 7).
    textField3 = test.addTextField(graphNode3, text, AnchorType.Line);

    graphNode4 = new GraphNode();
    graphNode4.setContainer(graphEdge);
    graphNode4.setPosition(TestHelper.getWaypoint(5, 7));

    textField4 = test.addTextField(graphNode4, text, AnchorType.RightEnding);
  }
  /**
   * Basic stress test of <code>notifyGraphNodeChange()</code> method.
   *
   * @throws Exception if if any exception occurs when testing.
   */
  public void testUseCaseNode_notifyGraphNodeChange_AbsolutePosition() throws Exception {
    GraphNode dv = new GraphNode();
    dv.setPosition(StressTestHelper.createPoint(0, 0));
    GraphNode ssNode = StressTestHelper.getGraphNode(1);
    ssNode.setSize(StressTestHelper.createDimension(400, 800));
    ssNode.setPosition(StressTestHelper.createPoint(100, 200));
    ssNode.setContainer(dv);
    graphNode.setContainer(ssNode);
    ssNode.addContained(graphNode);

    // create a use case node here.
    node = new UseCaseNode(graphNode, properties);

    // change the node and test it.
    for (int i = 0; i < LOOPTIMES; i++) {
      int width = 40 + i;
      int height = 80 + i;
      graphNode.setSize(StressTestHelper.createDimension(width, height));

      int x = 10 + i;
      int y = 20 + i;
      graphNode.setPosition(StressTestHelper.createPoint(x, y));

      // notify the node change here.
      node.notifyGraphNodeChange("node changed.");

      // check the Node here.

      // get the location to test.
      assertEquals("The notifyGraphNodeChange method is incorrect.", 105 + i, node.getLocation().x);
      assertEquals("The notifyGraphNodeChange method is incorrect.", 215 + i, node.getLocation().y);
    }
  }
  /**
   * Set up environment.
   *
   * @throws Exception exception
   */
  public void setUp() throws Exception {
    Helper.clearNamespace();
    Helper.initNamespace();

    freeTextGraphNode = new GraphNode();
    freeTextGraphNode.setContainer(new GraphElement() {});
  }
  /** Accuracy Test of the <code>addTextField()</code> method. */
  public void testAddTextField_Line() {
    graphNode.setPosition(TestHelper.getWaypoint(12, 13));
    graphNode.setContainer(graphEdge);

    TextField textField = test.addTextField(graphNode, text, AnchorType.Line);
    // get the contained graphNode to check the constructor.
    assertEquals("The contained graphNode should be equals.", graphNode, textField.getGraphNode());

    // get the anchorage point.
    Point anchorage = textField.getAnchorage();
    //  get the position of the anchorage point to check the method.
    assertEquals("The anchorage point should be at (12, 10).", 12, anchorage.x);
    assertEquals("The anchorage point should be at (12, 10).", 10, anchorage.y);
  }