Example #1
0
 public void setHeadNode(Node node) {
   if (headNode != null) {
     headNode.setHeadNode(false);
   }
   headNode = node;
   headNode.setHeadNode(true);
 }
Example #2
0
  /** Create a node at the most recent popup location */
  private void createNode(int x, int y) {
    QueryNode qn = queryGraph.createNode();
    Node node = new Node(this, qn);

    // make it the head node if it is currently the only node
    if (queryGraph.getNumNodes() == 1) {
      node.setHeadNode(true);
      setHeadNode(node);
    }

    // place on the screen
    node.setLocation(x, y);
    this.add(node);
    this.repaint();

    // add the popup
    NodeListener listener = new NodeListener(node, this);
    node.addMouseListener(listener);
    node.addMouseMotionListener(listener);

    // select this new node
    selectNode(node);
    fireEvent(node, GRAPH_CHANGED);

    System.out.println(qn.label);
  }