Changeset 422


Ignore:
Timestamp:
07/16/12 15:12:28 (12 years ago)
Author:
pharms
Message:

Added support for external specification of event filters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/jfc/JFCLogParser.java

    r392 r422  
    9494        /** 
    9595         * <p> 
    96          * Constructor. Creates a new JFCLogParser. 
     96         * Constructor. Creates a new JFCLogParser with a default event filter. 
     97         * This ignores focus events, mouse pressed, and mouse released events. 
    9798         * </p> 
    9899         */ 
     
    100101                sequences = new LinkedList<List<JFCEvent>>(); 
    101102                currentSequence = new LinkedList<JFCEvent>(); 
    102                 setupEventFilter(); 
    103         } 
    104  
    105         private void setupEventFilter() { 
     103                setupDefaultEventFilter(); 
     104        } 
     105 
     106        /** 
     107         * <p> 
     108         * Constructor. Creates a new JFCLogParser with a specific event filter. 
     109         * The events in the provided collection are ignored by the parser. 
     110         * As events, the constants of the different event classes must be used. 
     111         * E.g. creating a collection and putting 
     112         * <code>MouseEvent.MOUSE_PRESSED</code> will cause the parser to ignore 
     113         * all mouse pressed events. If the provided collection is null, no event 
     114         * is ignored. 
     115         * </p> 
     116         *  
     117         * @param ignoredEvents the events to be ignored by the parser, can be null 
     118         */ 
     119        public JFCLogParser(Collection<Integer> ignoredEvents) { 
     120                sequences = new LinkedList<List<JFCEvent>>(); 
     121                currentSequence = new LinkedList<JFCEvent>(); 
     122                eventFilter = ignoredEvents; 
     123        } 
     124 
     125        /** 
     126         * <p> 
     127         * creates a default event filter that ignores focus changes, mouse pressed 
     128         * and mouse released events. 
     129         * </p> 
     130         */ 
     131        private void setupDefaultEventFilter() { 
    106132                eventFilter = new HashSet<Integer>(); 
    107133                eventFilter.add(MouseEvent.MOUSE_PRESSED); 
     
    141167                } else if (qName.equals("event")) { 
    142168                        int eventId = Integer.parseInt(atts.getValue("id")); 
    143                         if (!eventFilter.contains(eventId)) { 
     169                        if ((eventFilter == null) || (!eventFilter.contains(eventId))) { 
    144170                                currentEvent = new JFCEvent(atts.getValue("id")); 
    145171                                paramSource = ParamSource.EVENT; 
Note: See TracChangeset for help on using the changeset viewer.