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