Ignore:
Timestamp:
06/25/14 22:22:39 (10 years ago)
Author:
rkrimmel
Message:

Further code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/NodeUtils.java

    r1579 r1580  
    99package de.ugoe.cs.autoquest.tasktrees.alignment.pal.tree; 
    1010 
    11 import java.io.*; 
    12  
    13 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.io.FormattedOutput; 
     11 
    1412import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 
    1513 
     
    377375        } 
    378376 
    379         /** 
    380          * prints node in New Hamshire format. 
    381          */ 
    382         static void printNH(PrintWriter out, Node node, 
    383                 boolean printLengths, boolean printInternalLabels) { 
    384  
    385                 printNH(out, node, printLengths, printInternalLabels, 0, true); 
    386         } 
    387  
    388  
    389         static int printNH(PrintWriter out, Node node, 
    390                 boolean printLengths, boolean printInternalLabels, int column, boolean breakLines) { 
    391  
    392                 if (breakLines) column = breakLine(out, column); 
    393  
    394                 if (!node.isLeaf()) 
    395                 { 
    396                         out.print("("); 
    397                         column++; 
    398  
    399                         for (int i = 0; i < node.getChildCount(); i++) 
    400                         { 
    401                                 if (i != 0) 
    402                                 { 
    403                                         out.print(","); 
    404                                         column++; 
    405                                 } 
    406  
    407                                 column = printNH(out, node.getChild(i), printLengths, printInternalLabels, column, breakLines); 
    408                         } 
    409  
    410                         out.print(")"); 
    411                         column++; 
    412                 } 
    413  
    414                 if (!node.isRoot()) 
    415                 { 
    416                         if (node.isLeaf() || printInternalLabels) 
    417                         { 
    418                                 if (breakLines) column = breakLine(out, column); 
    419  
    420                                 String id = node.getIdentifier().toString(); 
    421                                 out.print(id); 
    422                                 column += id.length(); 
    423                         } 
    424  
    425                         if (printLengths) 
    426                         { 
    427                                 out.print(":"); 
    428                                 column++; 
    429  
    430                                 if (breakLines) column = breakLine(out, column); 
    431  
    432                                 column += FormattedOutput.getInstance().displayDecimal(out, node.getBranchLength(), 7); 
    433                         } 
    434                 } 
    435  
    436                 return column; 
    437         } 
    438  
    439         private static int breakLine(PrintWriter out, int column) 
    440         { 
    441                 if (column > 70) 
    442                 { 
    443                         out.println(); 
    444                         column = 0; 
    445                 } 
    446  
    447                 return column; 
    448         } 
     377 
     378 
     379 
    449380        /** 
    450381         * Returns the first nodes in this tree that has the 
Note: See TracChangeset for help on using the changeset viewer.