Changeset 1043


Ignore:
Timestamp:
01/24/13 18:21:15 (12 years ago)
Author:
pharms
Message:
  • improved comparison of mouse clicks to better identify iterations
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-core-tasktrees/src/main/java/de/ugoe/cs/autoquest/tasktrees/nodeequality/GUIEventTaskComparisonRule.java

    r969 r1043  
    22 
    33import de.ugoe.cs.autoquest.eventcore.gui.IInteraction; 
     4import de.ugoe.cs.autoquest.eventcore.gui.MouseClick; 
     5import de.ugoe.cs.autoquest.eventcore.gui.MouseDragAndDrop; 
    46import de.ugoe.cs.autoquest.eventcore.gui.TextInput; 
    57import de.ugoe.cs.autoquest.eventcore.gui.ValueSelection; 
     
    8486                ((ValueSelection<?>) interaction1, (ValueSelection<?>) interaction2); 
    8587        } 
     88        else if ((interaction1 instanceof MouseClick) && 
     89                 (interaction2 instanceof MouseClick)) 
     90        { 
     91            return compareMouseClicks((MouseClick) interaction1, (MouseClick) interaction2); 
     92        } 
     93        else if ((interaction1 instanceof MouseDragAndDrop) && 
     94                 (interaction2 instanceof MouseDragAndDrop)) 
     95        { 
     96            return compareMouseDragAndDrops 
     97                ((MouseDragAndDrop) interaction1, (MouseDragAndDrop) interaction2); 
     98        } 
    8699        else if (interaction1.equals(interaction2)) { 
    87100            return NodeEquality.LEXICALLY_EQUAL; 
     
    145158    } 
    146159 
     160    /** 
     161     * <p> 
     162     * compares two mouse clicks. If both clicks have the same coordinates, they are lexically 
     163     * equal. Otherwise, they are semantically equal. 
     164     * </p> 
     165     * 
     166     * @param interaction1 the first mouse click to compare 
     167     * @param interaction2 the second mouse click to compare 
     168     *  
     169     * @return as described 
     170     */ 
     171    private NodeEquality compareMouseClicks(MouseClick interaction1, 
     172                                            MouseClick interaction2) 
     173    { 
     174        int x1 = interaction1.getX(); 
     175        int x2 = interaction2.getX(); 
     176        int y1 = interaction1.getY(); 
     177        int y2 = interaction2.getY(); 
     178         
     179        if ((x1 == x2) && (y1 == y2)) { 
     180            return NodeEquality.LEXICALLY_EQUAL; 
     181        } 
     182        else { 
     183            return NodeEquality.SEMANTICALLY_EQUAL; 
     184        } 
     185    } 
     186 
     187    /** 
     188     * <p> 
     189     * compares two mouse drag and drops. If both drag and drops have the same start and end 
     190     * coordinates, they are lexically equal. Otherwise, they are semantically equal. 
     191     * </p> 
     192     * 
     193     * @param interaction1 the first mouse drag and drop to compare 
     194     * @param interaction2 the second mouse drag and drop to compare 
     195     *  
     196     * @return as described 
     197     */ 
     198    private NodeEquality compareMouseDragAndDrops(MouseDragAndDrop interaction1, 
     199                                                  MouseDragAndDrop interaction2) 
     200    { 
     201        int x1 = interaction1.getX(); 
     202        int x1Start = interaction1.getXStart(); 
     203        int x2 = interaction2.getX(); 
     204        int x2Start = interaction2.getXStart(); 
     205        int y1 = interaction1.getY(); 
     206        int y1Start = interaction1.getYStart(); 
     207        int y2 = interaction2.getY(); 
     208        int y2Start = interaction2.getYStart(); 
     209         
     210        if ((x1Start == x2Start) && (x1 == x2) && (y1Start == y2Start) && (y1 == y2)) { 
     211            return NodeEquality.LEXICALLY_EQUAL; 
     212        } 
     213        else { 
     214            return NodeEquality.SEMANTICALLY_EQUAL; 
     215        } 
     216    } 
     217 
    147218} 
Note: See TracChangeset for help on using the changeset viewer.