Changeset 1107 for trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultGuiElementSequenceDetectionRule.java
- Timestamp:
- 02/21/13 18:39:13 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/DefaultGuiElementSequenceDetectionRule.java
r993 r1107 20 20 * @author 2012, last modified by $Author: patrick$ 21 21 */ 22 public class DefaultGuiElementSequenceDetectionRule implements TemporalRelationshipRule { 23 22 class DefaultGuiElementSequenceDetectionRule implements TemporalRelationshipRule { 23 24 /** 25 * <p> 26 * the task tree node factory to be used for creating substructures for the temporal 27 * relationships identified during rule 28 * </p> 29 */ 30 private ITaskTreeNodeFactory taskTreeNodeFactory; 31 /** 32 * <p> 33 * the task tree builder to be used for creating substructures for the temporal relationships 34 * identified during rule application 35 * </p> 36 */ 37 private ITaskTreeBuilder taskTreeBuilder; 38 24 39 /** 25 40 * <p> … … 31 46 /** 32 47 * <p> 33 * instantiates the rule without a GUI element filter 34 * </p> 35 */ 36 DefaultGuiElementSequenceDetectionRule() { 37 this.guiElementFilter = null; 38 } 39 48 * instantiates the rule with a task tree node factory and builder to be used during rule 49 * application but without a GUI element filter 50 * </p> 51 * 52 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 53 * for the temporal relationships identified during rule 54 * application 55 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 56 * the temporal relationships identified during rule application 57 */ 58 DefaultGuiElementSequenceDetectionRule(ITaskTreeNodeFactory taskTreeNodeFactory, 59 ITaskTreeBuilder taskTreeBuilder) 60 { 61 this(null, taskTreeNodeFactory, taskTreeBuilder); 62 } 63 40 64 /** 41 65 * <p> … … 45 69 * </p> 46 70 * 47 * @param guiElementFilter the GUI element filter to be applied 48 */ 49 DefaultGuiElementSequenceDetectionRule(List<Class<? extends IGUIElement>> guiElementFilter) { 71 * @param guiElementFilter the GUI element filter to be applied 72 * @param taskTreeNodeFactory the task tree node factory to be used for creating substructures 73 * for the temporal relationships identified during rule 74 * application 75 * @param taskTreeBuilder the task tree builder to be used for creating substructures for 76 * the temporal relationships identified during rule application 77 */ 78 DefaultGuiElementSequenceDetectionRule(List<Class<? extends IGUIElement>> guiElementFilter, 79 ITaskTreeNodeFactory taskTreeNodeFactory, 80 ITaskTreeBuilder taskTreeBuilder) 81 { 50 82 this.guiElementFilter = guiElementFilter; 83 this.taskTreeNodeFactory = taskTreeNodeFactory; 84 this.taskTreeBuilder = taskTreeBuilder; 51 85 } 52 86 … … 55 89 * 56 90 * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 57 * TaskTreeBuilder, TaskTreeNodeFactory)91 * boolean) 58 92 */ 59 93 @Override 60 public RuleApplicationResult apply(ITaskTreeNode parent, 61 ITaskTreeBuilder builder, 62 ITaskTreeNodeFactory nodeFactory, 63 boolean finalize) 64 { 94 public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 65 95 if (!(parent instanceof ISequence)) { 66 96 return null; … … 95 125 // anything. 96 126 97 RuleApplicationStatus status ;127 RuleApplicationStatus status = null; 98 128 if (initialHierarchyLevel < maxHierarchyDepth) { 99 status = generateSubSequences(parent, hierarchies, initialHierarchyLevel, finalize, 100 builder, nodeFactory, result); 101 } 102 else { 129 status = generateSubSequences 130 (parent, hierarchies, initialHierarchyLevel, finalize, result); 131 } 132 133 if (status == null) { 103 134 status = RuleApplicationStatus.RULE_NOT_APPLIED; 104 135 } … … 121 152 * @param maxHierarchyDepth the maximum hierarchy depth that may apply in this application 122 153 * @param finalize true, if the application shall be finalized, false else 123 * @param builder the builder to use for generating the tree structure124 * @param nodeFactory the node factory to use for generating the tree structure125 154 * @param result the result of the rule application to add newly created parent 126 155 * nodes to … … 136 165 int hierarchyLevel, 137 166 boolean finalize, 138 ITaskTreeBuilder builder,139 ITaskTreeNodeFactory nodeFactory,140 167 RuleApplicationResult result) 141 168 { … … 169 196 } 170 197 else if (nextGuiElementDiffers) { 171 status = condenseSequence (parent, hierarchies, hierarchyLevel, startingIndex,172 index - 1, builder, nodeFactory, result);198 status = condenseSequence 199 (parent, hierarchies, hierarchyLevel, startingIndex, index - 1, result); 173 200 174 201 if (status != null) { … … 195 222 status = condenseSequence 196 223 (parent, hierarchies, hierarchyLevel, startingIndex, 197 parent.getChildren().size() - 1, builder, nodeFactory,result);224 parent.getChildren().size() - 1, result); 198 225 } 199 226 else if (status != RuleApplicationStatus.RULE_APPLICATION_FINISHED) { … … 225 252 * @param startIndex the index of the first child belonging to the subgroup 226 253 * @param endIndex the index of the last child belonging to the subgroup 227 * @param builder the builder to use for generating the tree structure228 * @param nodeFactory the node factory to use for generating the tree structure229 254 * @param result the result of the rule application to add newly created parent nodes to 230 255 * … … 238 263 int startIndex, 239 264 int endIndex, 240 ITaskTreeBuilder builder,241 ITaskTreeNodeFactory nodeFactory,242 265 RuleApplicationResult result) 243 266 { … … 247 270 248 271 if (!onlyASingleChildToReduce || !singleChildIsSequence) { 249 ISequence sequence = nodeFactory.createNewSequence();272 ISequence sequence = taskTreeNodeFactory.createNewSequence(); 250 273 251 274 List<List<IGUIElement>> subHierarchies = new ArrayList<List<IGUIElement>>(); 252 275 List<IGUIElement> newHierarchy = 253 276 hierarchies.get(startIndex).subList(0, hierarchyLevel + 1); 254 builder.setDescription(sequence, "interactions on " + 255 newHierarchy.get(newHierarchy.size() - 1).getStringIdentifier()); 277 taskTreeBuilder.setDescription 278 (sequence, "interactions on " + 279 newHierarchy.get(newHierarchy.size() - 1).getStringIdentifier()); 256 280 257 281 for (int i = startIndex; i <= endIndex; i++) { 258 builder.addChild(sequence, parent.getChildren().get(startIndex));259 builder.removeChild((ISequence) parent, startIndex);282 taskTreeBuilder.addChild(sequence, parent.getChildren().get(startIndex)); 283 taskTreeBuilder.removeChild((ISequence) parent, startIndex); 260 284 261 285 subHierarchies.add(hierarchies.remove(startIndex)); 262 286 } 263 287 264 builder.addChild((ISequence) parent, startIndex, sequence);288 taskTreeBuilder.addChild((ISequence) parent, startIndex, sequence); 265 289 266 290 hierarchies.add(startIndex, newHierarchy); 267 291 268 generateSubSequences 269 (sequence, subHierarchies, hierarchyLevel + 1, true, builder, nodeFactory, result); 292 generateSubSequences(sequence, subHierarchies, hierarchyLevel + 1, true, result); 270 293 271 294 result.addNewlyCreatedParentNode(sequence);
Note: See TracChangeset
for help on using the changeset viewer.