Ignore:
Timestamp:
01/16/13 17:51:51 (11 years ago)
Author:
adeicke
Message:
  • Removed lombok related annotations and util class
  • Added comments and formating due to match project defaults
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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
     
    1125import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    1226 
     27/** 
     28 * <p> 
     29 * TODO comment 
     30 * </p> 
     31 *  
     32 * @author Alexander Deicke 
     33 */ 
    1334public enum EventTargetFilter implements TaskTreeNodeFilter<IEventTarget> { 
    1435 
    1536    TEXT_FIELD(ITextField.class), 
    16      
     37 
    1738    TEXT_AREA(ITextArea.class); 
    18      
     39 
    1940    private Class<? extends IEventTarget> eventTargetClazz; 
    20      
     41 
    2142    private EventTargetFilter(Class<? extends IEventTarget> eventTargetClazz) { 
    2243        this.eventTargetClazz = eventTargetClazz; 
     
    3758        return Predicates.and(instanceOfIEventTaskPredicate, nodeHoldsInstanceOfFilterArgument); 
    3859    } 
    39      
     60 
    4061    private Function<ITaskTreeNode, IEventTarget> nodeExtractionFunction() { 
    4162        return new Function<ITaskTreeNode, IEventTarget>() { 
    42              
     63 
    4364            @Override 
    4465            public IEventTarget apply(ITaskTreeNode treeNode) { 
     
    4768        }; 
    4869    } 
    49      
     70 
    5071} 
  • 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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
     
    620 
    721import de.ugoe.cs.autoquest.eventcore.IEventType; 
     22import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 
    823import de.ugoe.cs.autoquest.eventcore.gui.MouseButtonInteraction; 
    924import de.ugoe.cs.autoquest.eventcore.gui.MouseInteraction; 
     
    1227import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    1328 
     29/** 
     30 * <p> 
     31 * TODO comment 
     32 * </p> 
     33 *  
     34 * @author Alexander Deicke 
     35 */ 
    1436public enum EventTypeFilter implements TaskTreeNodeFilter<IEventType> { 
     37 
     38    MOUSE_BUTTON_INTERACTION(MouseButtonInteraction.class), 
     39     
     40    MOUSE_INTERACTION(MouseInteraction.class), 
    1541     
    1642    TEXT_INPUT(TextInput.class), 
    1743     
    18     MOUSE_INTERACTION(MouseInteraction.class), 
    19      
    20     MOUSE_BUTTON_INTERACTION(MouseButtonInteraction.class); 
    21      
     44    USER_INTERACTION(IInteraction.class); 
     45 
    2246    private Class<? extends IEventType> eventTypeClazz; 
    23      
     47 
    2448    private EventTypeFilter(Class<? extends IEventType> eventTypeClazz) { 
    2549        this.eventTypeClazz = eventTypeClazz; 
     
    3155        return (Class<IEventType>) eventTypeClazz; 
    3256    } 
    33      
     57 
    3458    @SuppressWarnings("rawtypes") 
    3559    @Override 
     
    4064        return Predicates.and(instanceOfIEventTaskPredicate, nodeHoldsInstanceOfFilterArgument); 
    4165    } 
    42      
     66 
    4367    private Function<ITaskTreeNode, IEventType> nodeExtractionFunction() { 
    4468        return new Function<ITaskTreeNode, IEventType>() { 
    45              
     69 
    4670            @Override 
    4771            public IEventType apply(ITaskTreeNode treeNode) { 
     
    5074        }; 
    5175    } 
    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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
     
    418 
    519import com.google.common.base.Predicate; 
     20import com.google.common.collect.LinkedListMultimap; 
    621import com.google.common.collect.Lists; 
     22import com.google.common.collect.Multimap; 
    723 
     24import de.ugoe.cs.autoquest.eventcore.guimodel.IGUIElement; 
     25import de.ugoe.cs.autoquest.tasktrees.treeifc.IEventTask; 
    826import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    927 
     28/** 
     29 * <p> 
     30 * TODO comment 
     31 * </p> 
     32 *  
     33 * @author Alexander Deicke 
     34 */ 
    1035public class FilterStatistic { 
    11      
     36 
    1237    @SuppressWarnings("rawtypes") 
    1338    private final Predicate filterPredicate; 
    1439 
    1540    private List<ITaskTreeNode> filteredNodes = Lists.newArrayList(); 
    16      
     41 
    1742    private List<ITaskTreeNode> nodesNotMatchedFilter = Lists.newArrayList(); 
    18      
     43 
    1944    @SuppressWarnings("rawtypes") 
    2045    public FilterStatistic(Predicate filterPredicate) { 
    2146        this.filterPredicate = filterPredicate; 
    2247    } 
    23      
     48 
    2449    @SuppressWarnings("unchecked") 
    2550    public void addNode(ITaskTreeNode node) { 
    2651        if (filterPredicate.apply(node)) { 
    2752            filteredNodes.add(node); 
    28         } else { 
     53        } 
     54        else { 
    2955            nodesNotMatchedFilter.add(node); 
    3056        } 
    3157    } 
    32      
     58 
    3359    public List<ITaskTreeNode> nodesMatchedFilter() { 
    3460        return this.filteredNodes; 
    3561    } 
    36      
     62 
    3763    public int nrOfNodesMatchedFilter() { 
    3864        return this.filteredNodes.size(); 
    3965    } 
    40      
     66 
    4167    public List<ITaskTreeNode> nodesNotMatchedFilter() { 
    4268        return this.nodesNotMatchedFilter; 
    4369    } 
    44      
     70 
    4571    public int nrOfNodesNotMatchedFilter() { 
    4672        return this.nodesNotMatchedFilter.size(); 
    4773    } 
    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 
    4992} 
  • 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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
     
    721import com.google.common.cache.CacheBuilder; 
    822 
     23/** 
     24 * <p> 
     25 * TODO comment 
     26 * </p> 
     27 *  
     28 * @author Alexander Deicke 
     29 */ 
    930public class FilterStatisticCache { 
    1031 
    1132    private static final FilterStatisticCache instance = new FilterStatisticCache(); 
    12      
     33 
    1334    @SuppressWarnings("rawtypes") 
    1435    private Cache<TaskTreeNodeFilter, FilterStatistic> cache; 
    15      
     36 
    1637    private FilterStatisticCache() { 
    1738        this.cache = CacheBuilder.newBuilder().expireAfterWrite(10, TimeUnit.MINUTES).build(); 
    1839    } 
    19      
     40 
    2041    public static FilterStatisticCache instance() { 
    2142        return instance; 
    2243    } 
    23      
     44 
    2445    @SuppressWarnings("rawtypes") 
    2546    public void addFilterStatistic(TaskTreeNodeFilter nodeFilter, FilterStatistic filterStatistic) { 
    2647        this.cache.put(nodeFilter, filterStatistic); 
    2748    } 
    28      
     49 
    2950    @SuppressWarnings("rawtypes") 
    3051    public Optional<FilterStatistic> getFilterStatistic(TaskTreeNodeFilter nodeFilter) { 
    3152        return Optional.fromNullable(this.cache.getIfPresent(nodeFilter)); 
    3253    } 
    33      
     54 
    3455    public void clear() { 
    3556        this.cache.invalidateAll(); 
    3657    } 
    37      
     58 
    3859} 
  • 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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
     
    1024import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTreeNode; 
    1125 
     26/** 
     27 * <p> 
     28 * TODO comment 
     29 * </p> 
     30 *  
     31 * @author Alexander Deicke 
     32 */ 
    1233public class IterativeDFSFilterStrategy implements TaskTreeFilterStrategy { 
    13      
     34 
    1435    private FilterStatistic filterStatistic; 
    15      
     36 
    1637    @SuppressWarnings("unchecked") 
    1738    @Override 
     
    3152        return this.filterStatistic; 
    3253    } 
    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 
    3464    private void traverse(ITaskTree taskTree) { 
    3565        Stack<ITaskTreeNode> unvisitedNodes = new Stack<ITaskTreeNode>(); 
    3666        unvisitedNodes.push(taskTree.getRoot()); 
    37         while(stillUnvisitedNodes(unvisitedNodes)) { 
     67        while (stillUnvisitedNodes(unvisitedNodes)) { 
    3868            ITaskTreeNode node = unvisitedNodes.pop(); 
    3969            processCurrentNode(node); 
     
    4979        this.filterStatistic.addNode(node); 
    5080    } 
    51      
     81 
    5282    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()) { 
    5586            unvisitedNodes.push(child); 
    5687        } 
  • 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. 
    114 
    215package de.ugoe.cs.autoquest.usability.tasktree.filter; 
     
    619import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    720 
     21/** 
     22 * <p> 
     23 * TODO comment 
     24 * </p> 
     25 *  
     26 * @author Alexander Deicke 
     27 */ 
    828public class TaskTreeFilter { 
    9      
     29 
    1030    private final TaskTreeFilterStrategy taskTreeFilterStrategy; 
    11      
     31 
    1232    public TaskTreeFilter(TaskTreeFilterStrategy treeTraversalStrategy) { 
    1333        Preconditions.checkNotNull(treeTraversalStrategy); 
     
    2141    public FilterEventTypeStep filterByEventType(EventTypeFilter eventType) { 
    2242        return new FilterEventTypeStep(eventType); 
     43    } 
     44 
     45    public FilterNodeTypeStep filterByNodeType(TaskTreeNodeTypeFilter nodeType) { 
     46        return new FilterNodeTypeStep(nodeType); 
    2347    } 
    2448 
     
    5074 
    5175    } 
     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    } 
    5290} 
  • 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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
    317import de.ugoe.cs.autoquest.tasktrees.treeifc.ITaskTree; 
    418 
     19/** 
     20 * <p> 
     21 * TODO comment 
     22 * </p> 
     23 *  
     24 * @author Alexander Deicke 
     25 */ 
    526public interface TaskTreeFilterStrategy { 
    627 
     
    829 
    930    public FilterStatistic filter(ITaskTree taskTree, EventTypeFilter eventType); 
    10    
     31 
     32    public FilterStatistic filter(ITaskTree taskTree, TaskTreeNodeTypeFilter nodeType); 
     33 
    1134} 
  • 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 
    115package de.ugoe.cs.autoquest.usability.tasktree.filter; 
    216 
    317import com.google.common.base.Predicate; 
    418 
     19/** 
     20 * <p> 
     21 * TODO comment 
     22 * </p> 
     23 *  
     24 * @author Alexander Deicke 
     25 */ 
    526public interface TaskTreeNodeFilter<T> { 
    627 
    728    public Class<T> clazz(); 
    8      
     29 
    930    @SuppressWarnings("rawtypes") 
    1031    public Predicate filterPredicate(); 
    11      
     32 
    1233} 
Note: See TracChangeset for help on using the changeset viewer.