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 | |
---|
15 | package de.ugoe.cs.autoquest.usability; |
---|
16 | |
---|
17 | import java.util.ArrayList; |
---|
18 | import java.util.List; |
---|
19 | import java.util.logging.Level; |
---|
20 | |
---|
21 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IMarkingTemporalRelationship; |
---|
22 | import de.ugoe.cs.autoquest.tasktrees.treeifc.IStructuringTemporalRelationship; |
---|
23 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITask; |
---|
24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
25 | import 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 | */ |
---|
33 | public 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 TaskTreeTestRule()); |
---|
51 | // rules.add(new TextInputStatisticsRule()); |
---|
52 | // rules.add(new MissingFeedbackRule()); |
---|
53 | // rules.add(new EventCoverageRatioRule()); |
---|
54 | // rules.add(new TargetDistanceRule()); |
---|
55 | // rules.add(new RequiredInefficientActionsRule()); |
---|
56 | // rules.add(new DataEntryMethodChangeRule()); |
---|
57 | rules.add(new DefaultValueRule()); |
---|
58 | // rules.add(new CheckBoxMultipleSelectionRule()); |
---|
59 | // rules.add(new CommonTaskRateRule()); |
---|
60 | // rules.add(new MisleadingClickCueRule()); |
---|
61 | // rules.add(new DefaultCursorPositioningRule()); |
---|
62 | // rules.add(new UnusedGUIElementsRule()); |
---|
63 | // rules.add(new TaskCooccurrenceRule()); |
---|
64 | } |
---|
65 | |
---|
66 | /** |
---|
67 | * |
---|
68 | */ |
---|
69 | public UsabilityEvaluationResult evaluateUsability(ITaskModel taskModel) { |
---|
70 | Console.traceln(Level.INFO, "evaluating usability of task model " + taskModel); |
---|
71 | |
---|
72 | List<UsabilityEvaluationResult> interimResults = new ArrayList<UsabilityEvaluationResult>(); |
---|
73 | |
---|
74 | for (UsabilityEvaluationRule rule : rules) { |
---|
75 | Console.traceln(Level.INFO, "applying rule " + rule.getClass().getSimpleName()); |
---|
76 | UsabilityEvaluationResult result = rule.evaluate(taskModel); |
---|
77 | interimResults.add(result); |
---|
78 | Console.traceln(Level.INFO, "the rule found " + result.getAllSmells().size() + |
---|
79 | " usability smells."); |
---|
80 | |
---|
81 | List<ITask> referredTasks = new ArrayList<ITask>(); |
---|
82 | |
---|
83 | for (UsabilitySmell smell : result.getAllSmells()) { |
---|
84 | if (smell.getSmellingTask() != null) { |
---|
85 | referredTasks.add(smell.getSmellingTask()); |
---|
86 | } |
---|
87 | } |
---|
88 | |
---|
89 | int counter = 0; |
---|
90 | for (int i = 0; i < referredTasks.size(); i++) { |
---|
91 | for (int j = 0; j < referredTasks.size(); j++) { |
---|
92 | if (isChildOf(referredTasks.get(i), referredTasks.get(j))) { |
---|
93 | counter++; |
---|
94 | break; |
---|
95 | } |
---|
96 | } |
---|
97 | } |
---|
98 | |
---|
99 | if (counter > 0) { |
---|
100 | Console.traceln(Level.INFO, counter + " of the findings are duplicates in " + |
---|
101 | "that they refer to tasks whose parent tasks are also " + |
---|
102 | "referred by the findings"); |
---|
103 | } |
---|
104 | } |
---|
105 | |
---|
106 | UsabilityEvaluationResult result = new UsabilityEvaluationResult(taskModel, interimResults); |
---|
107 | Console.println("the evaluation result contains " + result.getAllSmells().size() + |
---|
108 | " smells."); |
---|
109 | |
---|
110 | return result; |
---|
111 | } |
---|
112 | |
---|
113 | /** |
---|
114 | * <p> |
---|
115 | * TODO: comment |
---|
116 | * </p> |
---|
117 | * |
---|
118 | * @param iTask |
---|
119 | * @param iTask2 |
---|
120 | * @return |
---|
121 | */ |
---|
122 | private boolean isChildOf(final ITask potChild, ITask potParent) { |
---|
123 | |
---|
124 | if (potParent instanceof IStructuringTemporalRelationship) { |
---|
125 | for (ITask child : ((IStructuringTemporalRelationship) potParent).getChildren()) { |
---|
126 | if ((child == potChild) || isChildOf(potChild, child)) { |
---|
127 | return true; |
---|
128 | } |
---|
129 | } |
---|
130 | } |
---|
131 | else if (potParent instanceof IMarkingTemporalRelationship) { |
---|
132 | ITask child = ((IMarkingTemporalRelationship) potParent).getMarkedTask(); |
---|
133 | if ((child == potChild) || isChildOf(potChild, child)) { |
---|
134 | return true; |
---|
135 | } |
---|
136 | } |
---|
137 | |
---|
138 | return false; |
---|
139 | } |
---|
140 | |
---|
141 | } |
---|