Ignore:
Timestamp:
02/21/13 18:39:13 (11 years ago)
Author:
pharms
Message:
  • changed rules to be testable on their own
  • added first version for a task detection rule
  • refactored rules to have a simpler interface
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/TrackBarSelectionDetectionRule.java

    r1099 r1107  
    1919 * @author 2012, last modified by $Author: patrick$ 
    2020 */ 
    21 public class TrackBarSelectionDetectionRule implements TemporalRelationshipRule { 
     21class TrackBarSelectionDetectionRule implements TemporalRelationshipRule { 
     22    /** 
     23     * <p> 
     24     * the task tree node factory to be used for creating substructures for the temporal 
     25     * relationships identified during rule 
     26     * </p> 
     27     */ 
     28    private ITaskTreeNodeFactory taskTreeNodeFactory; 
     29    /** 
     30     * <p> 
     31     * the task tree builder to be used for creating substructures for the temporal relationships 
     32     * identified during rule application 
     33     * </p> 
     34     */ 
     35    private ITaskTreeBuilder taskTreeBuilder; 
    2236 
    23     /** */ 
     37    /** 
     38     * <p> 
     39     * the node equality manager needed for comparing task tree nodes with each other 
     40     * </p> 
     41     */ 
    2442    private NodeEqualityRuleManager nodeEqualityRuleManager; 
    2543 
    2644    /** 
    27      * 
     45     * <p> 
     46     * instantiates the rule and initializes it with a node equality rule manager and the minimal 
     47     * node equality identified sublist must have to consider them as iterated. 
     48     * </p> 
    2849     */ 
    29     TrackBarSelectionDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager) { 
    30         super(); 
     50    TrackBarSelectionDetectionRule(NodeEqualityRuleManager nodeEqualityRuleManager, 
     51                                   ITaskTreeNodeFactory    taskTreeNodeFactory, 
     52                                   ITaskTreeBuilder        taskTreeBuilder) 
     53    { 
    3154        this.nodeEqualityRuleManager = nodeEqualityRuleManager; 
     55        this.taskTreeNodeFactory = taskTreeNodeFactory; 
     56        this.taskTreeBuilder = taskTreeBuilder; 
    3257    } 
    3358 
     
    3560     * (non-Javadoc) 
    3661     *  
    37      * @see TemporalRelationshipRule#apply(TaskTreeNode, TaskTreeBuilder, TaskTreeNodeFactory) 
     62     * @see de.ugoe.cs.tasktree.temporalrelation.TemporalRelationshipRule#apply(TaskTreeNode, 
     63     * boolean) 
    3864     */ 
    3965    @Override 
    40     public RuleApplicationResult apply(ITaskTreeNode        parent, 
    41                                        ITaskTreeBuilder     builder, 
    42                                        ITaskTreeNodeFactory nodeFactory, 
    43                                        boolean              finalize) 
    44     { 
     66    public RuleApplicationResult apply(ITaskTreeNode parent, boolean finalize) { 
    4567        if (!(parent instanceof ISequence)) { 
    4668            return null; 
     
    7294                // Therefore, 
    7395                // create an iteration with the different selectable values as selection children 
    74                 handleValueSelections(parent, currentTrackBar, valueSelectionStartIndex, index - 1, 
    75                                       builder, nodeFactory, result); 
     96                handleValueSelections 
     97                    (parent, currentTrackBar, valueSelectionStartIndex, index - 1, result); 
    7698 
    7799                return result; 
     
    84106            if (finalize) { 
    85107                handleValueSelections(parent, currentTrackBar, valueSelectionStartIndex, 
    86                                       parent.getChildren().size() - 1, builder, nodeFactory, result); 
     108                                      parent.getChildren().size() - 1, result); 
    87109            } 
    88110            else { 
     
    101123                                       int                   startIndex, 
    102124                                       int                   endIndex, 
    103                                        ITaskTreeBuilder      builder, 
    104                                        ITaskTreeNodeFactory  nodeFactory, 
    105125                                       RuleApplicationResult result) 
    106126    { 
    107         IIteration iteration = nodeFactory.createNewIteration(); 
    108         builder.setDescription(iteration, "value selection on " + trackbar.getStringIdentifier()); 
     127        IIteration iteration = taskTreeNodeFactory.createNewIteration(); 
     128        taskTreeBuilder.setDescription 
     129            (iteration, "value selection on " + trackbar.getStringIdentifier()); 
    109130        result.addNewlyCreatedParentNode(iteration); 
    110131 
    111         ISelection selection = nodeFactory.createNewSelection(); 
     132        ISelection selection = taskTreeNodeFactory.createNewSelection(); 
    112133        result.addNewlyCreatedParentNode(selection); 
    113         builder.setChild(iteration, selection); 
     134        taskTreeBuilder.setChild(iteration, selection); 
    114135 
    115136        for (int i = endIndex - startIndex; i >= 0; i--) { 
    116             addChildIfNecessary(selection, parent.getChildren().get(startIndex), builder, 
    117                                 nodeFactory, result); 
    118             builder.removeChild((ISequence) parent, startIndex); 
     137            addChildIfNecessary(selection, parent.getChildren().get(startIndex), result); 
     138            taskTreeBuilder.removeChild((ISequence) parent, startIndex); 
    119139        } 
    120140 
    121         builder.addChild((ISequence) parent, startIndex, iteration); 
     141        taskTreeBuilder.addChild((ISequence) parent, startIndex, iteration); 
    122142 
    123143        result.setRuleApplicationStatus(RuleApplicationStatus.RULE_APPLICATION_FINISHED); 
     
    129149    private void addChildIfNecessary(ISelection            parentSelection, 
    130150                                     ITaskTreeNode         node, 
    131                                      ITaskTreeBuilder      builder, 
    132                                      ITaskTreeNodeFactory  nodeFactory, 
    133151                                     RuleApplicationResult result) 
    134152    { 
     
    144162 
    145163        // if we did not return in the previous checks, then the node must be added 
    146         builder.addChild(parentSelection, node); 
     164        taskTreeBuilder.addChild(parentSelection, node); 
    147165    } 
    148166 
Note: See TracChangeset for help on using the changeset viewer.