Changeset 1580 for branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/NodeUtils.java
- Timestamp:
- 06/25/14 22:22:39 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/NodeUtils.java
r1579 r1580 9 9 package de.ugoe.cs.autoquest.tasktrees.alignment.pal.tree; 10 10 11 import java.io.*; 12 13 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.io.FormattedOutput; 11 14 12 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 15 13 … … 377 375 } 378 376 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 449 380 /** 450 381 * Returns the first nodes in this tree that has the
Note: See TracChangeset
for help on using the changeset viewer.