Changeset 1040 for trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter
- Timestamp:
- 01/16/13 17:51:51 (11 years ago)
- Location:
- trunk/autoquest-core-usability-evaluation/src/main/java/de/ugoe/cs/autoquest/usability/tasktree/filter
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.