1 16 package com.buchuki.ensmer.input.event; 17 18 import java.awt.event.*; 19 20 29 public class LateralMouseMoveEvent extends EnsmerMouseEvent implements Measurable { 30 31 38 public LateralMouseMoveEvent(int magnitude) { 39 this.magnitude = magnitude; 40 } 41 42 50 @Override 51 public boolean equals(Object obj) { 52 if (!getClass().equals(obj.getClass())) { 53 return false; 54 } 55 int newmag = (int) ((LateralMouseMoveEvent) obj).getMagnitude(); 56 if (newmag < 0 && magnitude < 0) { 57 return true; 58 } 59 else if (newmag > 0 && magnitude > 0) { 60 return true; 61 } 62 else if (newmag == 0 && magnitude == 0) { 63 return true; 64 } 65 else { 66 return false; 67 } 68 } 69 70 76 @Override 77 public int hashCode() { 78 int classcode = getClass().hashCode(); 79 if (magnitude < 1) { 80 return classcode - 1; 81 } 82 else if (magnitude > 1) { 83 return classcode + 1; 84 } 85 else { 86 return classcode; 87 } 88 } 89 90 95 public float getMagnitude() { 96 return magnitude; 97 } 98 99 102 private int magnitude; 103 } 104 105 | Popular Tags |