Ignore:
Timestamp:
01/30/15 18:01:08 (9 years ago)
Author:
funger
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/autoquest-plugin-android/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/TouchSingle.java

    r1819 r1868  
    1717/** 
    1818 * <p> 
    19  * Event type for a single touch events, i.e., touch on a mobile phone. 
     19 * Event type for a single touch events, i.e. touch on a mobile phone. 
    2020 * </p> 
    2121 *  
     
    104104    @Override 
    105105    public boolean equals(Object obj) { 
    106         if (obj instanceof TouchSingle) { 
    107             return (((TouchSingle) obj).getX() == getX()) && (((TouchSingle) obj).getY() == getY()); 
     106        if(obj == this){ 
     107            return true; 
    108108        } 
    109         return false; 
     109        if(!(obj instanceof TouchSingle)){ 
     110            return false; 
     111        } 
     112        TouchSingle touch = (TouchSingle)obj; 
     113        return touch.getX() == x && touch.getY() == y; 
    110114    } 
    111115 
     
    117121    @Override 
    118122    public int hashCode() { 
    119         //TODO create a hashCode 
    120         return 0; 
     123        // 17 due to the reason that this is a prime number. 
     124        int result = 17; 
     125        /* 
     126         * 31 due to the reason that a lot of VM's could optimize this multiplication by a shift. 
     127         * Source: Effective Java, Joshua Bloch, 2008, p.48 
     128         */ 
     129        result = 31 * result + Float.floatToIntBits(x); 
     130        result = 31 * result + Float.floatToIntBits(y); 
     131        return result; 
    121132    } 
    122133 
Note: See TracChangeset for help on using the changeset viewer.