Changeset 970 for trunk/autoquest-core-tasktrees/src/main/java
- Timestamp:
- 11/08/12 19:54:41 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultIterationDetectionRule.java
r922 r970 120 120 121 121 122 // to find longer iterations first, start with long sequences123 122 SubSequences subSequences = getEqualSubsequences(parent, treeBuilder, nodeFactory); 124 123 … … 173 172 SubSequences subSequences = null; 174 173 174 // to find longer iterations first, start with long sequences 175 175 FIND_ITERATION: 176 176 for (int end = parent.getChildren().size(); end > 0; end--) { … … 496 496 /** 497 497 * <p> 498 * merges equal selections. This is done through trying to merge each node of selections with499 * each other. For this, the method500 * {@link #mergeEqualNodes(List, ITaskTreeBuilder, ITaskTreeNodeFactory)} is called with a501 * join of the child list of both selections.498 * merges equal selections. This is done by adding those children of the second selection to 499 * the first selection that can not be merged with any of the children of the first selection. 500 * If a merge is possible and this merge is not a simple selection of the merged children, 501 * then the merged child replaces the child of the first selection which was merged. 502 502 * </p> 503 503 * … … 507 507 * @param nodeFactory the node factory that can be used for instantiating task tree nodes 508 508 * 509 * @return the result of the merge which is n otnull509 * @return the result of the merge which is never null 510 510 */ 511 511 private ITaskTreeNode mergeEqualSelections(ISelection selection1, … … 514 514 ITaskTreeNodeFactory nodeFactory) 515 515 { 516 ISelection mergeResult = nodeFactory.createNewSelection(); 517 518 for (int i = 0; i < selection1.getChildren().size(); i++) { 519 treeBuilder.addChild(mergeResult, selection1.getChildren().get(i)); 520 } 521 516 ISelection mergeResult = selection1; 517 518 ITaskTreeNode childToMerge = null; 519 ITaskTreeNode mergedChild = null; 520 521 // check for each child of selection 2 if it is a duplicate of one of the children 522 // if selection 1. If not, add it as further child to the merge result, else skip it. 522 523 for (int i = 0; i < selection2.getChildren().size(); i++) { 523 treeBuilder.addChild(mergeResult, selection2.getChildren().get(i)); 524 } 525 526 mergeEqualNodes(mergeResult.getChildren(), treeBuilder, nodeFactory); 524 childToMerge = selection2.getChildren().get(i); 525 for (int j = 0; j < selection1.getChildren().size(); j++) { 526 mergedChild = mergeEqualTasks 527 (selection1.getChildren().get(j), childToMerge, treeBuilder, nodeFactory); 528 529 // a merge must not be a selection, except it is one of the children. Otherwise 530 // no real merge was done. 531 if ((mergedChild != null) && 532 ((!(mergedChild instanceof ISelection)) || 533 (selection1.getChildren().get(j) == mergedChild) || 534 (childToMerge == mergedChild))) 535 { 536 // we found a real merge. So replace the original child in selection 1 with 537 // the merged child 538 treeBuilder.removeChild(selection1, selection1.getChildren().get(j)); 539 treeBuilder.addChild(selection1, mergedChild); 540 mergedChild = null; 541 childToMerge = null; 542 break; 543 } 544 } 545 546 if (childToMerge != null) { 547 treeBuilder.addChild(selection1, childToMerge); 548 } 549 } 527 550 528 551 return mergeResult;
Note: See TracChangeset
for help on using the changeset viewer.