source: trunk/autoquest-core-usability/src/main/java/de/ugoe/cs/autoquest/usability/UsabilityEvaluationManager.java @ 1493

Last change on this file since 1493 was 1493, checked in by pharms, 10 years ago
  • state of the HCSE 2014 Paper. An appropriate tag will follow.
File size: 5.0 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.usability;
16
17import java.util.ArrayList;
18import java.util.List;
19import java.util.logging.Level;
20
21import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship;
22import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship;
23import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask;
24import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel;
25import de.ugoe.cs.util.console.Console;
26
27/**
28 * TODO comment
29 *
30 * @version $Revision: $ $Date: 16.07.2012$
31 * @author 2012, last modified by $Author: pharms$
32 */
33public class UsabilityEvaluationManager {
34   
35    /** */
36    private List<UsabilityEvaluationRule> rules = new ArrayList<UsabilityEvaluationRule>();
37
38    /**
39     *
40     */
41    public UsabilityEvaluationManager() {
42        super();
43        init();
44    }
45
46    /**
47     *
48     */
49    private void init() {
50        //rules.add(new TextInputStatisticsRule());
51        rules.add(new MissingFeedbackRule());
52        rules.add(new EventCoverageRatioRule());
53        rules.add(new RequiredInefficientActionsRule());
54        //rules.add(new TaskCooccurrenceRule());
55        rules.add(new TargetDistanceRule());
56        //rules.add(new UnusedGUIElementsRule());
57        //rules.add(new TaskTreeTestRule());
58    }
59
60    /**
61     *
62     */
63    public UsabilityEvaluationResult evaluateUsability(ITaskModel taskModel) {
64        Console.traceln(Level.INFO, "evaluating usability of task model " + taskModel);
65
66        List<UsabilityEvaluationResult> interimResults = new ArrayList<UsabilityEvaluationResult>();
67
68        for (UsabilityEvaluationRule rule : rules) {
69            Console.traceln(Level.INFO, "applying rule " + rule.getClass().getSimpleName());
70            UsabilityEvaluationResult result = rule.evaluate(taskModel);
71            interimResults.add(result);
72            Console.traceln(Level.INFO, "the rule found " + result.getAllDefects().size() +
73                            " usability defects, of which " + result.getSevereDefects().size() +
74                            " are severe.");
75           
76            if ((rule instanceof EventCoverageRatioRule) ||
77                (rule instanceof RequiredInefficientActionsRule) ||
78                (rule instanceof TargetDistanceRule))
79            {
80                ITask[] referredTasks = new ITask[result.getAllDefects().size()];
81
82                for (int i = 0; i < result.getAllDefects().size(); i++) {
83                    referredTasks[i] =
84                        (ITask) result.getAllDefects().get(i).getDescriptionFragments().get(1);
85                }
86               
87                int counter = 0;
88                for (int i = 0; i < referredTasks.length; i++) {
89                    for (int j = 0; j < referredTasks.length; j++) {
90                        if (isChildOf(referredTasks[i], referredTasks[j])) {
91                            counter++;
92                            break;
93                        }
94                    }
95                }
96               
97                if (counter > 0) {
98                    Console.traceln(Level.INFO, counter + " of the findings are duplicates in " +
99                                    "that they refer to tasks whose parent tasks are also " +
100                                    "referred by the findings");
101                }
102            }
103        }
104
105        UsabilityEvaluationResult result = new UsabilityEvaluationResult(taskModel, interimResults);
106        Console.println("the evaluation result contains " + result.getAllDefects().size() +
107                        " defects, of which " + result.getSevereDefects().size() + " are severe.");
108
109        return result;
110    }
111
112    /**
113     * <p>
114     * TODO: comment
115     * </p>
116     *
117     * @param iTask
118     * @param iTask2
119     * @return
120     */
121    private boolean isChildOf(final ITask potChild, ITask potParent) {
122       
123        if (potParent instanceof IStructuringTemporalRelationship) {
124            for (ITask child : ((IStructuringTemporalRelationship) potParent).getChildren()) {
125                if ((child == potChild) || isChildOf(potChild, child)) {
126                    return true;
127                }
128            }
129        }
130        else if (potParent instanceof IMarkingTemporalRelationship) {
131            ITask child = ((IMarkingTemporalRelationship) potParent).getMarkedTask();
132            if ((child == potChild) || isChildOf(potChild, child)) {
133                return true;
134            }
135        }
136       
137        return false;
138    }
139
140}
Note: See TracBrowser for help on using the repository browser.