Exemplo n.º 1
0
  public synchronized void swap(RootedTree destTree, PhyloNode destNode) {
    synchronized (destTree) {
      /*
       * If we're swapping within the same tree, then it's easy:
       */
      if (origTree == destTree && origVertex != null) {
        Object p1 = origTree.getParentOf(origVertex);
        Object p2 = origTree.getParentOf(destNode);
        if (p1 != null && p2 != null) {
          origTree.removeEdge(p1, origVertex);
          origTree.removeEdge(p2, destNode);
          origTree.addEdge(p1, destNode);
          origTree.addEdge(p2, origVertex);
        }
      } else {
        /*
         * If we're swapping with an "external" clipboard, then it's also easy.
         */
        PhyloTree clipTree = loadClip();
        setClip(destTree, destNode);
        setClipFromJS(newickString);

        Object p1 = destTree.getParentOf(destNode);
        destTree.deleteSubtree(destNode);
        Graphs.addGraph(destTree, clipTree);
        if (p1 == null) {
          destTree.setRoot(clipTree.getRoot());
        } else {
          destTree.addEdge(p1, clipTree.getRoot());
        }
      }
    }
  }
Exemplo n.º 2
0
 public void setClip(RootedTree tree, PhyloNode node) {
   setStateRecursive(tree, (PhyloNode) tree.getRoot(), PhyloNode.NONE);
   RootedTree clone = tree.cloneSubtree(node);
   newickString = TreeIO.createNHXString(clone);
   origTree = tree;
   origVertex = node;
   fireEvent(CLIPBOARD_UPDATED);
 }
Exemplo n.º 3
0
 void clearCutNodes() {
   if (origTree != null) {
     if (origVertex != null && origVertex.getState() == PhyloNode.CUT) {
       origTree.deleteSubtree(origVertex);
       origTree.removeElbowsBelow(origTree.getRoot());
       setStateRecursive(origTree, (PhyloNode) origTree.getRoot(), PhyloNode.NONE);
       origVertex.found = false;
       origVertex = null;
       origTree.modPlus();
     }
   }
 }
Exemplo n.º 4
0
 void clearTree() {
   if (origTree != null) {
     setStateRecursive(origTree, (PhyloNode) origTree.getRoot(), PhyloNode.NONE);
     origTree = null;
   }
 }