Example #1
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);
  }
Example #2
0
  /*
   * Get the text query represented by the underlying graph
   */
  public String getQuery() {
    if (queryGraph.getNumNodes() == 0) return "";

    return queryGraph.toTregexQuery(headNode.getQueryNode());
  }
Example #3
0
 private void updatePopupMenu() {
   addEdgeItem.setEnabled(queryGraph.getNumNodes() > 1);
   if (targetNode != null) deleteNodeItem.setEnabled(!targetNode.isHeadNode());
 }