[927] | 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 | |
---|
[922] | 15 | package de.ugoe.cs.autoquest.usability; |
---|
[442] | 16 | |
---|
| 17 | import java.util.ArrayList; |
---|
| 18 | import java.util.List; |
---|
[725] | 19 | import java.util.logging.Level; |
---|
[442] | 20 | |
---|
[1493] | 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; |
---|
[1148] | 24 | import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskModel; |
---|
[725] | 25 | import de.ugoe.cs.util.console.Console; |
---|
[442] | 26 | |
---|
| 27 | /** |
---|
| 28 | * TODO comment |
---|
| 29 | * |
---|
| 30 | * @version $Revision: $ $Date: 16.07.2012$ |
---|
| 31 | * @author 2012, last modified by $Author: pharms$ |
---|
| 32 | */ |
---|
[561] | 33 | public class UsabilityEvaluationManager { |
---|
| 34 | |
---|
| 35 | /** */ |
---|
| 36 | private List<UsabilityEvaluationRule> rules = new ArrayList<UsabilityEvaluationRule>(); |
---|
[442] | 37 | |
---|
[561] | 38 | /** |
---|
| 39 | * |
---|
| 40 | */ |
---|
| 41 | public UsabilityEvaluationManager() { |
---|
| 42 | super(); |
---|
| 43 | init(); |
---|
| 44 | } |
---|
[442] | 45 | |
---|
[561] | 46 | /** |
---|
| 47 | * |
---|
| 48 | */ |
---|
| 49 | private void init() { |
---|
[1493] | 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()); |
---|
[442] | 58 | } |
---|
| 59 | |
---|
[561] | 60 | /** |
---|
[1301] | 61 | * |
---|
[561] | 62 | */ |
---|
[1149] | 63 | public UsabilityEvaluationResult evaluateUsability(ITaskModel taskModel) { |
---|
| 64 | Console.traceln(Level.INFO, "evaluating usability of task model " + taskModel); |
---|
[561] | 65 | |
---|
[1335] | 66 | List<UsabilityEvaluationResult> interimResults = new ArrayList<UsabilityEvaluationResult>(); |
---|
[561] | 67 | |
---|
| 68 | for (UsabilityEvaluationRule rule : rules) { |
---|
[725] | 69 | Console.traceln(Level.INFO, "applying rule " + rule.getClass().getSimpleName()); |
---|
[1149] | 70 | UsabilityEvaluationResult result = rule.evaluate(taskModel); |
---|
[1335] | 71 | interimResults.add(result); |
---|
[725] | 72 | Console.traceln(Level.INFO, "the rule found " + result.getAllDefects().size() + |
---|
| 73 | " usability defects, of which " + result.getSevereDefects().size() + |
---|
| 74 | " are severe."); |
---|
[1493] | 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 | } |
---|
[561] | 103 | } |
---|
| 104 | |
---|
[1493] | 105 | UsabilityEvaluationResult result = new UsabilityEvaluationResult(taskModel, interimResults); |
---|
[725] | 106 | Console.println("the evaluation result contains " + result.getAllDefects().size() + |
---|
| 107 | " defects, of which " + result.getSevereDefects().size() + " are severe."); |
---|
[561] | 108 | |
---|
| 109 | return result; |
---|
| 110 | } |
---|
| 111 | |
---|
[1493] | 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 | |
---|
[442] | 140 | } |
---|