Ignore:
Timestamp:
09/04/12 16:12:06 (12 years ago)
Author:
sherbold
Message:
  • complete rewrite of keyboard interaction sorting. As a result, the command cleanupKeyInteractions is deprecated.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/quest-ui-core/src/main/java/de/ugoe/cs/quest/commands/sequences/CMDsortKeyInteractions.java

    r750 r765  
    66import java.util.LinkedList; 
    77import java.util.List; 
     8import java.util.logging.Level; 
    89 
    910import de.ugoe.cs.quest.CommandHelpers; 
    1011import de.ugoe.cs.quest.SequenceInstanceOf; 
    1112import de.ugoe.cs.quest.eventcore.Event; 
    12 import de.ugoe.cs.quest.eventcore.gui.SortedInteractionEventList; 
     13import de.ugoe.cs.quest.eventcore.gui.KeyInteractionSorter; 
     14import de.ugoe.cs.quest.eventcore.gui.KeyInteractionSorter.CleanupMode; 
    1315import de.ugoe.cs.util.console.Command; 
     16import de.ugoe.cs.util.console.Console; 
    1417import de.ugoe.cs.util.console.GlobalDataContainer; 
    1518 
    1619/** 
    1720 * <p> 
    18  * Command to sort the key interactions in a sequence of events. An example, the sequence 
    19  * to write the upper case D 
     21 * Command to sort the key interactions in a sequence of events. An example, the sequence to write 
     22 * the upper case D 
    2023 * <ul> 
    21  *   <li>press shift key</li> 
    22  *   <li>press D key</li> 
    23  *   <li>release shift key</li> 
    24  *   <li>release D key</li> 
     24 * <li>press shift key</li> 
     25 * <li>press D key</li> 
     26 * <li>release shift key</li> 
     27 * <li>release D key</li> 
    2528 * </ul> 
    2629 *  
     
    2831 *  
    2932 * <ul> 
    30  *   <li>press shift key</li> 
    31  *   <li>press D key</li> 
    32  *   <li>release D key</li> 
    33  *   <li>release shift key</li> 
     33 * <li>press shift key</li> 
     34 * <li>press D key</li> 
     35 * <li>release D key</li> 
     36 * <li>release shift key</li> 
    3437 * </ul> 
    3538 *  
    36  * in which the first pressed key (shift in this case) is always released last. The same is done 
    37  * for the alt and the ctrl keys. 
     39 * in which the first pressed key (shift in this case) is always released last. The same is done for 
     40 * the alt and the ctrl keys. 
    3841 *  
    3942 * </p> 
     
    6467        String sequencesName; 
    6568        String newSequencesName; 
     69        String modeString = "ADDITION"; 
    6670        try { 
    6771            sequencesName = (String) parameters.get(0); 
     
    7175            else { 
    7276                newSequencesName = sequencesName; 
     77            } 
     78            if (parameters.size() > 2) { 
     79                modeString = (String) parameters.get(2); 
    7380            } 
    7481        } 
     
    8895        } 
    8996 
     97        CleanupMode mode = null; 
     98        try { 
     99            mode = CleanupMode.valueOf(modeString); 
     100        } 
     101        catch (IllegalArgumentException e) { 
     102            Console.printerrln("Invalid mode. Only REMOVAL and ADDITION are allowed values!"); 
     103            return; 
     104        } 
     105 
    90106        sequences = (Collection<List<Event>>) dataObject; 
    91         SortedInteractionEventList sortedEventList; 
    92107 
    93108        Collection<List<Event>> newSequences = new LinkedList<List<Event>>(); 
    94          
     109 
     110        int i = 1; 
    95111        for (List<Event> sequence : sequences) { 
    96             sortedEventList = new SortedInteractionEventList(); 
    97              
    98             for (Event event : sequence) { 
    99                 sortedEventList.add(event); 
    100             } 
    101              
    102             newSequences.add(sortedEventList); 
     112            Console.traceln(Level.INFO, "Processing sequence " + i++); 
     113            newSequences.add(new KeyInteractionSorter(mode).sortKeyInteractions(sequence)); 
    103114        } 
    104115 
     
    106117            CommandHelpers.dataOverwritten(newSequencesName); 
    107118        } 
    108          
     119 
    109120    } 
    110121 
Note: See TracChangeset for help on using the changeset viewer.