Ejemplo 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());
        }
      }
    }
  }
Ejemplo n.º 2
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();
     }
   }
 }