Changeset 1040 for trunk/autoquest-core-usability-evaluation
- Timestamp:
- 01/16/13 17:51:51 (12 years ago)
- Location:
- trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability
- Files:
-
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/UsabilityEvaluationFacade.java
r1033 r1040 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 1 15 package de.ugoe.cs.autoquest.usability; 2 16 3 17 import java.util.EnumSet; 4 18 import java.util.List; 5 6 import lombok.AccessLevel;7 import lombok.AllArgsConstructor;8 import lombok.NoArgsConstructor;9 19 10 20 import com.google.common.base.Optional; … … 17 27 import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRuleset; 18 28 19 @NoArgsConstructor(access = AccessLevel.PRIVATE) 29 /** 30 * <p> 31 * TODO comment 32 * </p> 33 * 34 * @author Alexander Deicke 35 */ 20 36 public class UsabilityEvaluationFacade { 21 37 22 public static ExecuteUsabilityEvaluationStep applyUsabilityRuleset(UsabilityRuleset usabilityRuleset) { 23 Preconditions.checkNotNull(usabilityRuleset); 38 private UsabilityEvaluationFacade() { 39 // no instantiation allowed 40 } 41 42 public static ExecuteUsabilityEvaluationStep applyUsabilityRuleset(UsabilityRuleset usabilityRuleset) 43 { 44 Preconditions.checkNotNull(usabilityRuleset); 24 45 return new ExecuteUsabilityEvaluationStep(usabilityRuleset); 25 46 } 26 47 27 @AllArgsConstructor28 48 protected static class ExecuteUsabilityEvaluationStep { 29 30 private final UsabilityRuleset usabilityRuleset;31 49 32 public UsabilityEvaluationReport evaluateUsabilityOf(ITaskTree taskTree) { 33 Preconditions.checkNotNull(taskTree); 34 EnumSet<? extends UsabilityRule> evaluationRules = usabilityRuleset.evaluationRules(); 35 List<UsabilityDefect> evaluationResults = 36 Lists.newArrayListWithCapacity(evaluationRules.size()); 37 for(UsabilityRule usabilityRule : evaluationRules) { 38 Optional<UsabilityDefect> ruleEvaluationResult = usabilityRule.evaluate(taskTree); 39 if(ruleEvaluationResult.isPresent()) { 40 evaluationResults.add(ruleEvaluationResult.get()); 41 } 42 } 43 return UsabilityEvaluationReport.from(evaluationResults); 44 } 45 50 protected ExecuteUsabilityEvaluationStep(UsabilityRuleset usabilityRuleset) { 51 super(); 52 this.usabilityRuleset = usabilityRuleset; 53 } 54 55 private final UsabilityRuleset usabilityRuleset; 56 57 public UsabilityEvaluationReport evaluateUsabilityOf(ITaskTree taskTree) { 58 Preconditions.checkNotNull(taskTree); 59 EnumSet<? extends UsabilityRule> evaluationRules = usabilityRuleset.evaluationRules(); 60 List<UsabilityDefect> evaluationResults = 61 Lists.newArrayListWithCapacity(evaluationRules.size()); 62 for (UsabilityRule usabilityRule : evaluationRules) { 63 Optional<UsabilityDefect> ruleEvaluationResult = usabilityRule.evaluate(taskTree); 64 if (ruleEvaluationResult.isPresent()) { 65 evaluationResults.add(ruleEvaluationResult.get()); 66 } 67 } 68 return UsabilityEvaluationReport.from(evaluationResults); 69 } 70 46 71 } 47 72 -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/UsabilityEvaluationReport.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability; 2 16 3 17 import java.util.List; 4 5 import lombok.AccessLevel;6 import lombok.AllArgsConstructor;7 18 8 19 import com.google.common.base.Preconditions; … … 10 21 import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect; 11 22 12 @AllArgsConstructor(access = AccessLevel.PRIVATE) 23 /** 24 * <p> 25 * TODO comment 26 * </p> 27 * 28 * @author Alexander Deicke 29 */ 13 30 public class UsabilityEvaluationReport { 14 31 15 32 private List<UsabilityDefect> evaluationResults; 16 33 34 private UsabilityEvaluationReport(List<UsabilityDefect> evaluationResults) { 35 this.evaluationResults = evaluationResults; 36 } 37 17 38 public static UsabilityEvaluationReport from(List<UsabilityDefect> evaluationResults) { 18 19 39 Preconditions.checkNotNull(evaluationResults); 40 return new UsabilityEvaluationReport(evaluationResults); 20 41 } 21 42 22 43 public List<UsabilityDefect> evaluationResults() { 23 44 return this.evaluationResults; 24 45 } 25 46 26 47 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefect.java
r1032 r1040 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. 1 14 2 15 package de.ugoe.cs.autoquest.usability.evaluation.result; … … 7 20 import java.util.Map; 8 21 9 import lombok.AllArgsConstructor;10 import lombok.ExtensionMethod;11 import lombok.Getter;12 13 22 import org.apache.commons.lang.StringUtils; 14 23 15 24 import com.google.common.base.CharMatcher; 16 25 import com.google.common.base.Joiner; 26 import com.google.common.base.Predicate; 27 import com.google.common.collect.Iterables; 17 28 import com.google.common.collect.Lists; 18 29 19 30 import de.ugoe.cs.autoquest.usability.DefectDescription; 20 31 import de.ugoe.cs.autoquest.usability.ParameterFragment; 21 import de.ugoe.cs.autoquest.usability.util.DefectDescriptionExtensionMethods;22 32 23 @AllArgsConstructor 24 @ExtensionMethod({DefectDescriptionExtensionMethods.class}) 33 /** 34 * <p> 35 * TODO comment 36 * </p> 37 * 38 * @author Alexander Deicke 39 */ 25 40 public class UsabilityDefect { 26 41 27 @Getter28 42 private UsabilityDefectSeverityLevel severityLevel; 29 43 … … 32 46 private Map<String, String> descriptionParametersValues; 33 47 48 public UsabilityDefect(UsabilityDefectSeverityLevel severityLevel, 49 DefectDescription defectDescription, 50 Map<String, String> descriptionParametersValues) 51 { 52 super(); 53 this.severityLevel = severityLevel; 54 this.defectDescription = defectDescription; 55 this.descriptionParametersValues = descriptionParametersValues; 56 } 57 34 58 public String defectDescription() { 35 if (defectDescription.containsParameterFragments()) {59 if (containsParameterFragments(defectDescription)) { 36 60 return assembleDefectDescription(); 37 } else { 38 return Joiner.on(" ").skipNulls().join(defectDescription.getTextFragmentOrParameterFragment()); 61 } 62 else { 63 return Joiner.on(" ").skipNulls() 64 .join(defectDescription.getTextFragmentOrParameterFragment()); 39 65 } 40 66 } 41 67 68 private boolean containsParameterFragments(DefectDescription defectDescription) { 69 return Iterables.any(defectDescription.getTextFragmentOrParameterFragment(), 70 new Predicate<Object>() { 71 72 @Override 73 public boolean apply(Object fragment) { 74 return fragment instanceof ParameterFragment; 75 } 76 77 }); 78 } 79 42 80 private String assembleDefectDescription() { 43 List<String> descriptionParts = 44 Lists.newArrayListWithCapacity(defectDescription.getTextFragmentOrParameterFragment().size()); 81 List<String> descriptionParts = 82 Lists.newArrayListWithCapacity(defectDescription.getTextFragmentOrParameterFragment() 83 .size()); 45 84 46 85 for (Object fragment : defectDescription.getTextFragmentOrParameterFragment()) { 47 if ( fragment.isParameterFragment()) {86 if (isParameterFragment(fragment)) { 48 87 descriptionParts.add(parameterFragmentAsString((ParameterFragment) fragment)); 49 } else { 50 descriptionParts.add(CharMatcher.WHITESPACE.collapseFrom((String) fragment, ' ').trim()); 88 } 89 else { 90 descriptionParts.add(CharMatcher.WHITESPACE.collapseFrom((String) fragment, ' ') 91 .trim()); 51 92 } 52 93 } … … 55 96 } 56 97 98 private boolean isParameterFragment(Object object) { 99 return object instanceof ParameterFragment; 100 } 101 57 102 private String parameterFragmentAsString(ParameterFragment fragment) { 58 String value = descriptionParametersValues.getValueOrEmptyString(fragment.getParameterName()); 103 String value = 104 getValueOrEmptyString(descriptionParametersValues, fragment.getParameterName()); 59 105 if (StringUtils.isNotEmpty(value)) { 60 106 return value; 61 } else { 62 throw new IllegalArgumentException(format("required parameter \"%s\" for usability defect description not provided", fragment.getParameterName())); 107 } 108 else { 109 throw new IllegalArgumentException( 110 format("required parameter \"%s\" for usability defect description not provided", 111 fragment.getParameterName())); 63 112 } 64 113 } 65 114 115 private String getValueOrEmptyString(Map<String, String> stringKeyValueMap, String key) { 116 return stringKeyValueMap != null && stringKeyValueMap.containsKey(key) ? stringKeyValueMap 117 .get(key) : StringUtils.EMPTY; 118 } 119 120 public UsabilityDefectSeverityLevel getSeverityLevel() { 121 return severityLevel; 122 } 123 66 124 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefectDescriptionResolver.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.result; 2 16 … … 4 18 import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule; 5 19 20 /** 21 * <p> 22 * TODO comment 23 * </p> 24 * 25 * @author Alexander Deicke 26 */ 6 27 public interface UsabilityDefectDescriptionResolver { 7 28 -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefectFactory.java
r1030 r1040 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. 1 14 2 15 package de.ugoe.cs.autoquest.usability.evaluation.result; … … 6 19 import de.ugoe.cs.autoquest.usability.DefectDescription; 7 20 import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule; 8 import lombok.AllArgsConstructor;9 21 10 @AllArgsConstructor 22 /** 23 * <p> 24 * TODO comment 25 * </p> 26 * 27 * @author Alexander Deicke 28 */ 11 29 public class UsabilityDefectFactory { 30 31 public UsabilityDefectFactory(UsabilityDefectDescriptionResolver usabilityDefectDescriptionResolver) 32 { 33 super(); 34 this.usabilityDefectDescriptionResolver = usabilityDefectDescriptionResolver; 35 } 12 36 13 37 private final UsabilityDefectDescriptionResolver usabilityDefectDescriptionResolver; … … 15 39 public UsabilityDefect createUsabilityGuidlineRecommendation(UsabilityDefectSeverityLevel recommendationSeverityLevel, 16 40 UsabilityRule usabilityRule, 17 Map<String, String> recommendationMessageParameteValues) { 41 Map<String, String> recommendationMessageParameteValues) 42 { 18 43 DefectDescription guidlineDescription = 19 44 usabilityDefectDescriptionResolver.descriptionFor(usabilityRule); -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefectSeverityLevel.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.result; 2 16 17 /** 18 * <p> 19 * TODO comment 20 * </p> 21 * 22 * @author Alexander Deicke 23 */ 3 24 public enum UsabilityDefectSeverityLevel { 4 25 5 26 INFO, LOW, MEDIUM, HIGH; 6 27 7 28 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/result/UsabilityDefectXmlDescriptionResolver.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.result; 2 16 … … 16 30 import de.ugoe.cs.autoquest.usability.evaluation.rule.set.UsabilityRule; 17 31 32 /** 33 * <p> 34 * TODO comment 35 * </p> 36 * 37 * @author Alexander Deicke 38 */ 18 39 public class UsabilityDefectXmlDescriptionResolver implements UsabilityDefectDescriptionResolver { 19 40 20 41 private static final String DEFAULT_MESSAGES_FILE = "defectDescriptions_en.xml"; 21 22 private static final UsabilityDefectXmlDescriptionResolver instance = new UsabilityDefectXmlDescriptionResolver(); 23 42 43 private static final UsabilityDefectXmlDescriptionResolver instance = 44 new UsabilityDefectXmlDescriptionResolver(); 45 24 46 private DefectDescriptions defectDescriptions; 25 47 26 48 private UsabilityDefectXmlDescriptionResolver() { 27 49 loadDescriptions(); 28 50 } 29 51 30 52 @SuppressWarnings("unchecked") 31 53 private void loadDescriptions() { 32 InputStream inputStream = 33 ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 54 InputStream inputStream = ClassLoader.getSystemResourceAsStream(DEFAULT_MESSAGES_FILE); 34 55 try { 35 56 String packageName = DefectDescriptions.class.getPackage().getName(); … … 38 59 39 60 defectDescriptions = 40 ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)) 41 .getValue(); 61 ((JAXBElement<DefectDescriptions>) unmarshaller.unmarshal(inputStream)).getValue(); 42 62 } 43 63 catch (Exception e) { 44 throw new RuntimeException 45 ("error while initializing usability defect descriptions", e); 64 throw new RuntimeException("error while initializing usability defect descriptions", e); 46 65 } 47 66 finally { … … 56 75 } 57 76 } 58 77 59 78 public static UsabilityDefectXmlDescriptionResolver instance() { 60 79 return instance; … … 63 82 @Override 64 83 public DefectDescription descriptionFor(final UsabilityRule usabilityRule) { 65 Optional<DefectDescription> guidlineDescription = Iterables.tryFind(defectDescriptions.getDefectDescription(), new Predicate<DefectDescription>() { 66 67 public boolean apply(DefectDescription defectDescription) { 68 return usabilityRule.ruleIdentifier().equals(defectDescription.getDefectId()); 69 } 70 71 }); 72 if(!guidlineDescription.isPresent()) 73 throw new RuntimeException 74 ("error while initializing usability defect descriptions. No " + 75 "description text available for description " + usabilityRule.ruleIdentifier()); 84 Optional<DefectDescription> guidlineDescription = 85 Iterables.tryFind(defectDescriptions.getDefectDescription(), 86 new Predicate<DefectDescription>() { 87 88 public boolean apply(DefectDescription defectDescription) { 89 return usabilityRule.ruleIdentifier() 90 .equals(defectDescription.getDefectId()); 91 } 92 93 }); 94 if (!guidlineDescription.isPresent()) 95 throw new RuntimeException( 96 "error while initializing usability defect descriptions. No " + 97 "description text available for description " + 98 usabilityRule.ruleIdentifier()); 76 99 return guidlineDescription.get(); 77 100 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/NoLetterOrDigitTextInputsEvaluator.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator; 2 16 … … 16 30 import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeFilter; 17 31 32 /** 33 * <p> 34 * TODO comment 35 * </p> 36 * 37 * @author Alexander Deicke 38 */ 18 39 public class NoLetterOrDigitTextInputsEvaluator extends RuleEvaluator { 19 40 20 public NoLetterOrDigitTextInputsEvaluator(UsabilityRule evaluatedUsabilityRule, ITaskTree taskTree) { 41 public NoLetterOrDigitTextInputsEvaluator(UsabilityRule evaluatedUsabilityRule, 42 ITaskTree taskTree) 43 { 21 44 super(evaluatedUsabilityRule, taskTree); 22 45 } … … 25 48 protected FilterStatistic nodesUnderEvaluation(ITaskTree taskTree) { 26 49 Optional<FilterStatistic> cachedNodes = loadFromCache(TEXT_INPUT); 27 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, TEXT_INPUT); 50 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, 51 TEXT_INPUT); 28 52 } 29 53 30 54 @Override 31 55 protected FilterStatistic extractNodesFromTaskTree(ITaskTree taskTree) { 32 return new TaskTreeFilter(new IterativeDFSFilterStrategy()) 33 .f ilterByEventType(TEXT_INPUT).from(taskTree);56 return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT) 57 .from(taskTree); 34 58 } 35 59 36 60 @Override 37 61 protected float calculateEvaluationMetric() { 38 Multiset<String> enteredTextFragments = aggregateEnteredTextFromTextInputs(this.filteredNodes.nodesMatchedFilter()); 62 Multiset<String> enteredTextFragments = 63 aggregateEnteredTextFromTextInputs(this.filteredNodes.nodesMatchedFilter()); 39 64 int allCharactersCount = 0; 40 65 int noLetterOrDigitCount = 0; 41 for (String textFragment : enteredTextFragments.elementSet()) {66 for (String textFragment : enteredTextFragments.elementSet()) { 42 67 int occurencesOfTextFragment = enteredTextFragments.count(textFragment); 43 68 allCharactersCount += CharMatcher.ANY.countIn(textFragment) * occurencesOfTextFragment; 44 noLetterOrDigitCount += CharMatcher.forPredicate(characterIsLetterOrDigitPredicate()).countIn(textFragment) * occurencesOfTextFragment; 69 noLetterOrDigitCount += 70 CharMatcher.forPredicate(characterIsLetterOrDigitPredicate()).countIn(textFragment) * 71 occurencesOfTextFragment; 45 72 } 46 return allCharactersCount != 0 ? (float) noLetterOrDigitCount / (float) allCharactersCount : 0; 73 return allCharactersCount != 0 ? (float) noLetterOrDigitCount / (float) allCharactersCount 74 : 0; 47 75 } 48 76 49 77 @Override 50 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) { 78 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) 79 { 51 80 Optional<UsabilityDefectSeverityLevel> recommendationSeverityLevel = Optional.absent(); 52 81 if (evaluationMetric > 0.1) // every 10th sign … … 68 97 return recommendationSeverityLevel; 69 98 } 70 99 71 100 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/RuleEvaluator.java
r1035 r1040 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. 1 14 2 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator; … … 17 30 import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeNodeFilter; 18 31 32 /** 33 * <p> 34 * TODO comment 35 * </p> 36 * 37 * @author Alexander Deicke 38 */ 19 39 public abstract class RuleEvaluator { 20 40 … … 38 58 39 59 @SuppressWarnings("rawtypes") 40 protected FilterStatistic cacheAndReturnNodes(ITaskTree taskTree, TaskTreeNodeFilter nodeFilter) { 60 protected FilterStatistic cacheAndReturnNodes(ITaskTree taskTree, TaskTreeNodeFilter nodeFilter) 61 { 41 62 FilterStatistic textInputEvents = extractNodesFromTaskTree(taskTree); 42 63 FilterStatisticCache.instance().addFilterStatistic(nodeFilter, textInputEvents); … … 52 73 determineSeverityLevel(evaluationMetric); 53 74 if (severityLevel.isPresent()) { 54 ruleEvaluationResult = 55 Optional.of(createRuleEvaluationResult(severityLevel.get())); 75 ruleEvaluationResult = Optional.of(createRuleEvaluationResult(severityLevel.get())); 56 76 } 57 77 return ruleEvaluationResult; … … 59 79 60 80 protected abstract float calculateEvaluationMetric(); 61 81 62 82 protected void storeEvaluationMetricForDefectDescription(String key, String value) { 63 83 defectDescriptionMessageParameterValues.put(key, value); … … 66 86 protected abstract Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric); 67 87 68 public UsabilityDefect createRuleEvaluationResult(UsabilityDefectSeverityLevel severityLevelOfDefect) { 88 public UsabilityDefect createRuleEvaluationResult(UsabilityDefectSeverityLevel severityLevelOfDefect) 89 { 69 90 return new UsabilityDefectFactory(UsabilityDefectXmlDescriptionResolver.instance()) 70 .createUsabilityGuidlineRecommendation(severityLevelOfDefect, 71 evaluatedUsabilityRule, 91 .createUsabilityGuidlineRecommendation(severityLevelOfDefect, evaluatedUsabilityRule, 72 92 defectDescriptionMessageParameterValues); 73 93 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/TextInputEntryRepetitionsEvaluator.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator; 2 16 3 17 import static de.ugoe.cs.autoquest.usability.tasktree.filter.EventTypeFilter.TEXT_INPUT; 4 18 import static de.ugoe.cs.autoquest.usability.util.TextInputUtil.aggregateEnteredTextFromTextInputs; 19 import static java.lang.String.format; 5 20 6 21 import com.google.common.base.Optional; … … 16 31 import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeFilter; 17 32 33 /** 34 * <p> 35 * TODO comment 36 * </p> 37 * 38 * @author Alexander Deicke 39 */ 18 40 public class TextInputEntryRepetitionsEvaluator extends RuleEvaluator { 19 41 20 public TextInputEntryRepetitionsEvaluator(UsabilityRule evaluatedUsabilityRule, ITaskTree taskTree) { 42 public TextInputEntryRepetitionsEvaluator(UsabilityRule evaluatedUsabilityRule, 43 ITaskTree taskTree) 44 { 21 45 super(evaluatedUsabilityRule, taskTree); 22 46 } … … 25 49 protected FilterStatistic nodesUnderEvaluation(ITaskTree taskTree) { 26 50 Optional<FilterStatistic> cachedNodes = loadFromCache(TEXT_INPUT); 27 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, TEXT_INPUT); 51 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, 52 TEXT_INPUT); 28 53 } 29 54 30 55 @Override 31 56 protected FilterStatistic extractNodesFromTaskTree(ITaskTree taskTree) { 32 return new TaskTreeFilter(new IterativeDFSFilterStrategy()) 33 .f ilterByEventType(TEXT_INPUT).from(taskTree);57 return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT) 58 .from(taskTree); 34 59 } 35 60 36 61 @Override 37 62 protected float calculateEvaluationMetric() { 38 Multiset<String> enteredTextFragments = aggregateEnteredTextFromTextInputs(this.filteredNodes.nodesMatchedFilter()); 39 Multiset<String> orderedTextFragmentsWithMultipleOccurences = onlyTextFragmentsWithMultipleOccurences(enteredTextFragments); 40 if(orderedTextFragmentsWithMultipleOccurences.isEmpty()) return 0; 41 String wordWithHighestRepetitionInTextFragments = orderedTextFragmentsWithMultipleOccurences.iterator().next(); 63 Multiset<String> enteredTextFragments = 64 aggregateEnteredTextFromTextInputs(this.filteredNodes.nodesMatchedFilter()); 65 Multiset<String> orderedTextFragmentsWithMultipleOccurences = 66 onlyTextFragmentsWithMultipleOccurences(enteredTextFragments); 67 if (orderedTextFragmentsWithMultipleOccurences.isEmpty()) 68 return 0; 69 String wordWithHighestRepetitionInTextFragments = 70 orderedTextFragmentsWithMultipleOccurences.iterator().next(); 42 71 int numberOfRepeatedWords = orderedTextFragmentsWithMultipleOccurences.entrySet().size(); 43 int maxRepetitions = orderedTextFragmentsWithMultipleOccurences.count(wordWithHighestRepetitionInTextFragments); 72 int maxRepetitions = 73 orderedTextFragmentsWithMultipleOccurences 74 .count(wordWithHighestRepetitionInTextFragments); 75 storeEvaluationMetricForDefectDescription("textRepetitionRatio", 76 format("textRepetitionRatio %s repeated tokens, up to %s repetitions per token", 77 numberOfRepeatedWords, maxRepetitions)); 44 78 return Math.max(numberOfRepeatedWords, maxRepetitions); 45 79 } 46 47 private Multiset<String> onlyTextFragmentsWithMultipleOccurences(final Multiset<String> allTextInputs) { 48 return Multisets.copyHighestCountFirst(Multisets.filter(allTextInputs, new Predicate<String>() { 49 50 @Override 51 public boolean apply(String word) { 52 return allTextInputs.count(word) > 1; 53 } 54 55 })); 80 81 private Multiset<String> onlyTextFragmentsWithMultipleOccurences(final Multiset<String> allTextInputs) 82 { 83 return Multisets.copyHighestCountFirst(Multisets.filter(allTextInputs, 84 new Predicate<String>() { 85 86 @Override 87 public boolean apply(String word) 88 { 89 return allTextInputs 90 .count(word) > 1; 91 } 92 93 })); 56 94 } 57 95 58 96 @Override 59 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) { 97 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) 98 { 60 99 Optional<UsabilityDefectSeverityLevel> recommendationSeverityLevel = Optional.absent(); 61 100 if (evaluationMetric > 10) { … … 73 112 return recommendationSeverityLevel; 74 113 } 75 114 76 115 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/evaluator/TextInputRatioEvaluator.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator; 2 16 … … 15 29 import de.ugoe.cs.autoquest.usability.tasktree.filter.TaskTreeFilter; 16 30 31 /** 32 * <p> 33 * TODO comment 34 * </p> 35 * 36 * @author Alexander Deicke 37 */ 17 38 public class TextInputRatioEvaluator extends RuleEvaluator { 18 39 … … 24 45 protected FilterStatistic nodesUnderEvaluation(ITaskTree taskTree) { 25 46 Optional<FilterStatistic> cachedNodes = loadFromCache(TEXT_INPUT); 26 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, TEXT_INPUT); 47 return cachedNodes.isPresent() ? cachedNodes.get() : cacheAndReturnNodes(taskTree, 48 TEXT_INPUT); 27 49 } 28 50 29 51 @Override 30 52 protected FilterStatistic extractNodesFromTaskTree(ITaskTree taskTree) { 31 return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT).from(taskTree); 53 return new TaskTreeFilter(new IterativeDFSFilterStrategy()).filterByEventType(TEXT_INPUT) 54 .from(taskTree); 32 55 } 33 56 … … 38 61 return textInputEvents / (textInputEvents + nonTextInputEvents); 39 62 } 40 63 41 64 private int nrOfEventNodesNotMatchedFilter() { 42 return Iterables.size( 43 Iterables.filter(this.filteredNodes.nodesNotMatchedFilter(),new Predicate<ITaskTreeNode>() {44 45 @Override46 public boolean apply(ITaskTreeNode node) {47 return (node.getChildren() == null) || (node.getChildren().size() == 0);48 }49 })50 );65 return Iterables.size(Iterables.filter(this.filteredNodes.nodesNotMatchedFilter(), 66 new Predicate<ITaskTreeNode>() { 67 68 @Override 69 public boolean apply(ITaskTreeNode node) { 70 return (node.getChildren() == null) || 71 (node.getChildren().size() == 0); 72 } 73 })); 51 74 } 52 75 53 76 @Override 54 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) { 77 protected Optional<UsabilityDefectSeverityLevel> determineSeverityLevel(float evaluationMetric) 78 { 55 79 Optional<UsabilityDefectSeverityLevel> recommendationSeverityLevel = Optional.absent(); 56 80 if (evaluationMetric > 0.9) { -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/EmptyUsabilityRuleset.java
r1034 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; 2 16 … … 10 24 import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect; 11 25 26 /** 27 * <p> 28 * TODO comment 29 * </p> 30 * 31 * @author Alexander Deicke 32 */ 12 33 public class EmptyUsabilityRuleset implements UsabilityRuleset { 13 34 14 35 private enum EmptyUsabilityRule implements UsabilityRule { 15 36 ; 16 37 17 38 @Override … … 26 47 27 48 } 28 29 private final EnumSet<EmptyUsabilityRule> EMPTY_USABILITY_RULESET = 30 EnumSet.noneOf(EmptyUsabilityRule.class);49 50 private final EnumSet<EmptyUsabilityRule> EMPTY_USABILITY_RULESET = EnumSet 51 .noneOf(EmptyUsabilityRule.class); 31 52 32 53 @Override 33 54 public EnumSet<? extends UsabilityRule> evaluationRules() { 34 55 return EMPTY_USABILITY_RULESET; 35 56 } 36 57 -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/MouseInteractionUsabilityRuleset.java
r1034 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; 2 16 … … 8 22 import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect; 9 23 24 /** 25 * <p> 26 * TODO comment 27 * </p> 28 * 29 * @author Alexander Deicke 30 */ 10 31 public class MouseInteractionUsabilityRuleset implements UsabilityRuleset { 11 32 12 33 private enum MouseInteractionUsabilityRule implements UsabilityRule { 13 34 14 35 MOUSE_INTERACTION { 15 36 … … 25 46 return this.name(); 26 47 } 27 48 28 49 }; 29 50 30 51 public abstract Optional<UsabilityDefect> evaluate(ITaskTree taskTree); 31 52 } 32 33 private final EnumSet<MouseInteractionUsabilityRule> MOUSE_INTERACTION_USABILITY_RULESET = EnumSet34 35 53 54 private final EnumSet<MouseInteractionUsabilityRule> MOUSE_INTERACTION_USABILITY_RULESET = 55 EnumSet.allOf(MouseInteractionUsabilityRule.class); 56 36 57 @Override 37 58 public EnumSet<? extends UsabilityRule> evaluationRules() { -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/RulesetFactory.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; 2 16 3 import lombok.AccessLevel; 4 import lombok.NoArgsConstructor; 17 /** 18 * <p> 19 * TODO comment 20 * </p> 21 * 22 * @author Alexander Deicke 23 */ 24 public class RulesetFactory { 5 25 6 @NoArgsConstructor(access = AccessLevel.PRIVATE) 7 public class RulesetFactory { 8 26 private RulesetFactory() { 27 // no instantiation allowed 28 } 29 9 30 public static EmptyUsabilityRuleset emptyUsabilityRuleset() { 10 31 return new EmptyUsabilityRuleset(); 11 32 } 12 33 13 34 public static TextInputUsabiliyRuleset textInputUsabiliyRuleset() { 14 35 return new TextInputUsabiliyRuleset(); 15 36 } 16 37 17 38 public static MouseInteractionUsabilityRuleset mouseInteractionUsabiliyRuleset() { 18 39 return new MouseInteractionUsabilityRuleset(); -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/TextInputUsabiliyRuleset.java
r1034 r1040 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. 1 14 2 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; … … 12 25 import de.ugoe.cs.autoquest.usability.evaluation.rule.evaluator.TextInputRatioEvaluator; 13 26 27 /** 28 * <p> 29 * TODO comment 30 * </p> 31 * 32 * @author Alexander Deicke 33 */ 14 34 public class TextInputUsabiliyRuleset implements UsabilityRuleset { 15 35 … … 17 37 18 38 TEXT_FIELD_INPUT_RATIO { 19 39 20 40 @Override 21 41 public Optional<UsabilityDefect> evaluate(ITaskTree taskTree) { … … 56 76 } 57 77 78 }; 58 79 59 };60 61 80 public abstract Optional<UsabilityDefect> evaluate(ITaskTree taskTree); 62 81 -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/UsabilityRule.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; 2 16 … … 6 20 import de.ugoe.cs.autoquest.usability.evaluation.result.UsabilityDefect; 7 21 22 /** 23 * <p> 24 * TODO comment 25 * </p> 26 * 27 * @author Alexander Deicke 28 */ 8 29 public interface UsabilityRule { 9 30 10 31 public String ruleIdentifier(); 11 32 12 33 public Optional<UsabilityDefect> evaluate(ITaskTree taskTree); 13 34 -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/evaluation/rule/set/UsabilityRuleset.java
r1034 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.evaluation.rule.set; 2 16 3 17 import java.util.EnumSet; 4 18 5 19 /** 20 * <p> 21 * TODO comment 22 * </p> 23 * 24 * @author Alexander Deicke 25 */ 6 26 public interface UsabilityRuleset { 7 27 8 28 public EnumSet<? extends UsabilityRule> evaluationRules(); 9 29 10 30 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/EventTargetFilter.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 11 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 12 26 27 /** 28 * <p> 29 * TODO comment 30 * </p> 31 * 32 * @author Alexander Deicke 33 */ 13 34 public enum EventTargetFilter implements TaskTreeNodeFilter<IEventTarget> { 14 35 15 36 TEXT_FIELD(ITextField.class), 16 37 17 38 TEXT_AREA(ITextArea.class); 18 39 19 40 private Class<? extends IEventTarget> eventTargetClazz; 20 41 21 42 private EventTargetFilter(Class<? extends IEventTarget> eventTargetClazz) { 22 43 this.eventTargetClazz = eventTargetClazz; … … 37 58 return Predicates.and(instanceOfIEventTaskPredicate, nodeHoldsInstanceOfFilterArgument); 38 59 } 39 60 40 61 private Function<ITaskTreeNode, IEventTarget> nodeExtractionFunction() { 41 62 return new Function<ITaskTreeNode, IEventTarget>() { 42 63 43 64 @Override 44 65 public IEventTarget apply(ITaskTreeNode treeNode) { … … 47 68 }; 48 69 } 49 70 50 71 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/EventTypeFilter.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 6 20 7 21 import de.ugoe.cs.autoquest.eventcore.IEventType; 22 import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 8 23 import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 9 24 import de.ugoe.cs.autoquest.eventcore.gui.MouseInteraction; … … 12 27 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 13 28 29 /** 30 * <p> 31 * TODO comment 32 * </p> 33 * 34 * @author Alexander Deicke 35 */ 14 36 public enum EventTypeFilter implements TaskTreeNodeFilter<IEventType> { 37 38 MOUSE_BUTTON_INTERACTION(MouseButtonInteraction.class), 39 40 MOUSE_INTERACTION(MouseInteraction.class), 15 41 16 42 TEXT_INPUT(TextInput.class), 17 43 18 MOUSE_INTERACTION(MouseInteraction.class), 19 20 MOUSE_BUTTON_INTERACTION(MouseButtonInteraction.class); 21 44 USER_INTERACTION(IInteraction.class); 45 22 46 private Class<? extends IEventType> eventTypeClazz; 23 47 24 48 private EventTypeFilter(Class<? extends IEventType> eventTypeClazz) { 25 49 this.eventTypeClazz = eventTypeClazz; … … 31 55 return (Class<IEventType>) eventTypeClazz; 32 56 } 33 57 34 58 @SuppressWarnings("rawtypes") 35 59 @Override … … 40 64 return Predicates.and(instanceOfIEventTaskPredicate, nodeHoldsInstanceOfFilterArgument); 41 65 } 42 66 43 67 private Function<ITaskTreeNode, IEventType> nodeExtractionFunction() { 44 68 return new Function<ITaskTreeNode, IEventType>() { 45 69 46 70 @Override 47 71 public IEventType apply(ITaskTreeNode treeNode) { … … 50 74 }; 51 75 } 52 76 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatistic.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 4 18 5 19 import com.google.common.base.Predicate; 20 import com.google.common.collect.LinkedListMultimap; 6 21 import com.google.common.collect.Lists; 22 import com.google.common.collect.Multimap; 7 23 24 import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 25 import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 8 26 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 9 27 28 /** 29 * <p> 30 * TODO comment 31 * </p> 32 * 33 * @author Alexander Deicke 34 */ 10 35 public class FilterStatistic { 11 36 12 37 @SuppressWarnings("rawtypes") 13 38 private final Predicate filterPredicate; 14 39 15 40 private List<ITaskTreeNode> filteredNodes = Lists.newArrayList(); 16 41 17 42 private List<ITaskTreeNode> nodesNotMatchedFilter = Lists.newArrayList(); 18 43 19 44 @SuppressWarnings("rawtypes") 20 45 public FilterStatistic(Predicate filterPredicate) { 21 46 this.filterPredicate = filterPredicate; 22 47 } 23 48 24 49 @SuppressWarnings("unchecked") 25 50 public void addNode(ITaskTreeNode node) { 26 51 if (filterPredicate.apply(node)) { 27 52 filteredNodes.add(node); 28 } else { 53 } 54 else { 29 55 nodesNotMatchedFilter.add(node); 30 56 } 31 57 } 32 58 33 59 public List<ITaskTreeNode> nodesMatchedFilter() { 34 60 return this.filteredNodes; 35 61 } 36 62 37 63 public int nrOfNodesMatchedFilter() { 38 64 return this.filteredNodes.size(); 39 65 } 40 66 41 67 public List<ITaskTreeNode> nodesNotMatchedFilter() { 42 68 return this.nodesNotMatchedFilter; 43 69 } 44 70 45 71 public int nrOfNodesNotMatchedFilter() { 46 72 return this.nodesNotMatchedFilter.size(); 47 73 } 48 74 75 /** 76 * <p> 77 * TODO: comment 78 * </p> 79 * 80 * @param eventTargetParent 81 * @return 82 */ 83 public Multimap<IGUIElement, ITaskTreeNode> groupBy() { 84 Multimap<IGUIElement, ITaskTreeNode> groupedNodes = LinkedListMultimap.create(); 85 for(ITaskTreeNode node : filteredNodes) { 86 IGUIElement eventTask = (IGUIElement) ((IEventTask) node).getEventTarget(); 87 groupedNodes.put(eventTask.getParent(), node); 88 } 89 return groupedNodes; 90 } 91 49 92 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/FilterStatisticCache.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 7 21 import com.google.common.cache.CacheBuilder; 8 22 23 /** 24 * <p> 25 * TODO comment 26 * </p> 27 * 28 * @author Alexander Deicke 29 */ 9 30 public class FilterStatisticCache { 10 31 11 32 private static final FilterStatisticCache instance = new FilterStatisticCache(); 12 33 13 34 @SuppressWarnings("rawtypes") 14 35 private Cache<TaskTreeNodeFilter, FilterStatistic> cache; 15 36 16 37 private FilterStatisticCache() { 17 38 this.cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(); 18 39 } 19 40 20 41 public static FilterStatisticCache instance() { 21 42 return instance; 22 43 } 23 44 24 45 @SuppressWarnings("rawtypes") 25 46 public void addFilterStatistic(TaskTreeNodeFilter nodeFilter, FilterStatistic filterStatistic) { 26 47 this.cache.put(nodeFilter, filterStatistic); 27 48 } 28 49 29 50 @SuppressWarnings("rawtypes") 30 51 public Optional<FilterStatistic> getFilterStatistic(TaskTreeNodeFilter nodeFilter) { 31 52 return Optional.fromNullable(this.cache.getIfPresent(nodeFilter)); 32 53 } 33 54 34 55 public void clear() { 35 56 this.cache.invalidateAll(); 36 57 } 37 58 38 59 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/IterativeDFSFilterStrategy.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 … … 10 24 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 11 25 26 /** 27 * <p> 28 * TODO comment 29 * </p> 30 * 31 * @author Alexander Deicke 32 */ 12 33 public class IterativeDFSFilterStrategy implements TaskTreeFilterStrategy { 13 34 14 35 private FilterStatistic filterStatistic; 15 36 16 37 @SuppressWarnings("unchecked") 17 38 @Override … … 31 52 return this.filterStatistic; 32 53 } 33 54 55 @SuppressWarnings("unchecked") 56 @Override 57 public FilterStatistic filter(ITaskTree taskTree, TaskTreeNodeTypeFilter nodeType) { 58 Predicate<ITaskTreeNode> filterPredicate = nodeType.filterPredicate(); 59 this.filterStatistic = new FilterStatistic(filterPredicate); 60 traverse(taskTree); 61 return this.filterStatistic; 62 } 63 34 64 private void traverse(ITaskTree taskTree) { 35 65 Stack<ITaskTreeNode> unvisitedNodes = new Stack<ITaskTreeNode>(); 36 66 unvisitedNodes.push(taskTree.getRoot()); 37 while (stillUnvisitedNodes(unvisitedNodes)) {67 while (stillUnvisitedNodes(unvisitedNodes)) { 38 68 ITaskTreeNode node = unvisitedNodes.pop(); 39 69 processCurrentNode(node); … … 49 79 this.filterStatistic.addNode(node); 50 80 } 51 81 52 82 private void processChildrenOfCurrentNode(Stack<ITaskTreeNode> unvisitedNodes, 53 ITaskTreeNode node) { 54 for(ITaskTreeNode child : node.getChildren()) { 83 ITaskTreeNode node) 84 { 85 for (ITaskTreeNode child : node.getChildren()) { 55 86 unvisitedNodes.push(child); 56 87 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/TaskTreeFilter.java
r1030 r1040 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. 1 14 2 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; … … 6 19 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 7 20 21 /** 22 * <p> 23 * TODO comment 24 * </p> 25 * 26 * @author Alexander Deicke 27 */ 8 28 public class TaskTreeFilter { 9 29 10 30 private final TaskTreeFilterStrategy taskTreeFilterStrategy; 11 31 12 32 public TaskTreeFilter(TaskTreeFilterStrategy treeTraversalStrategy) { 13 33 Preconditions.checkNotNull(treeTraversalStrategy); … … 21 41 public FilterEventTypeStep filterByEventType(EventTypeFilter eventType) { 22 42 return new FilterEventTypeStep(eventType); 43 } 44 45 public FilterNodeTypeStep filterByNodeType(TaskTreeNodeTypeFilter nodeType) { 46 return new FilterNodeTypeStep(nodeType); 23 47 } 24 48 … … 50 74 51 75 } 76 77 public class FilterNodeTypeStep { 78 79 private final TaskTreeNodeTypeFilter nodeType; 80 81 public FilterNodeTypeStep(TaskTreeNodeTypeFilter nodeType) { 82 this.nodeType = nodeType; 83 } 84 85 public FilterStatistic from(ITaskTree taskTree) { 86 return taskTreeFilterStrategy.filter(taskTree, nodeType); 87 } 88 89 } 52 90 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/TaskTreeFilterStrategy.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 3 17 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 4 18 19 /** 20 * <p> 21 * TODO comment 22 * </p> 23 * 24 * @author Alexander Deicke 25 */ 5 26 public interface TaskTreeFilterStrategy { 6 27 … … 8 29 9 30 public FilterStatistic filter(ITaskTree taskTree, EventTypeFilter eventType); 10 31 32 public FilterStatistic filter(ITaskTree taskTree, TaskTreeNodeTypeFilter nodeType); 33 11 34 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter/TaskTreeNodeFilter.java
r1030 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.tasktree.filter; 2 16 3 17 import com.google.common.base.Predicate; 4 18 19 /** 20 * <p> 21 * TODO comment 22 * </p> 23 * 24 * @author Alexander Deicke 25 */ 5 26 public interface TaskTreeNodeFilter<T> { 6 27 7 28 public Class<T> clazz(); 8 29 9 30 @SuppressWarnings("rawtypes") 10 31 public Predicate filterPredicate(); 11 32 12 33 } -
trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/util/TextInputUtil.java
r1031 r1040 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 1 15 package de.ugoe.cs.autoquest.usability.util; 2 16 … … 15 29 import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 16 30 31 /** 32 * <p> 33 * TODO comment 34 * </p> 35 * 36 * @author Alexander Deicke 37 */ 17 38 public class TextInputUtil { 18 19 public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) { 39 40 private TextInputUtil() { 41 // util class 42 } 43 44 public static Multiset<String> aggregateEnteredTextFromTextInputs(List<ITaskTreeNode> nodesWithTextInputEvents) 45 { 20 46 List<Iterable<String>> allTextInputs = Lists.newArrayList(); 21 for (ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) {47 for (ITaskTreeNode nodeWithTextInput : nodesWithTextInputEvents) { 22 48 TextInput textInput = (TextInput) ((IEventTask) nodeWithTextInput).getEventType(); 23 49 allTextInputs.add(splitTextIntoWordsAndSigns(textInput.getEnteredText())); … … 25 51 return HashMultiset.create(Iterables.concat(allTextInputs)); 26 52 } 27 53 28 54 public static Iterable<String> splitTextIntoWordsAndSigns(String enteredText) { 29 CharMatcher onlyWords = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate())); 30 CharMatcher onlySigns = CharMatcher.WHITESPACE.or(CharMatcher.forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 31 Iterable<String> words = Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 32 Iterable<String> signs = Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 55 CharMatcher onlyWords = 56 CharMatcher.WHITESPACE.or(CharMatcher 57 .forPredicate(characterIsJavaIdentifierPartPredicate())); 58 CharMatcher onlySigns = 59 CharMatcher.WHITESPACE.or(CharMatcher 60 .forPredicate(characterIsJavaIdentifierPartPredicate()).negate()); 61 Iterable<String> words = 62 Splitter.on(onlyWords).omitEmptyStrings().trimResults().split(enteredText); 63 Iterable<String> signs = 64 Splitter.on(onlySigns).omitEmptyStrings().trimResults().split(enteredText); 33 65 return Iterables.concat(words, signs); 34 66 } 35 67 36 68 public static Predicate<Character> characterIsJavaIdentifierPartPredicate() { 37 69 return new Predicate<Character>() { 38 70 39 71 @Override 40 72 public boolean apply(Character character) { 41 return!Character.isJavaIdentifierPart(character);73 return !Character.isJavaIdentifierPart(character); 42 74 } 43 75 44 76 }; 45 77 } 46 78 47 79 public static Predicate<Character> characterIsLetterOrDigitPredicate() { 48 80 return new Predicate<Character>() { 49 81 50 82 @Override 51 83 public boolean apply(Character character) { 52 84 return !Character.isLetterOrDigit(character); 53 85 } 54 86 55 87 }; 56 88 }
Note: See TracChangeset
for help on using the changeset viewer.