// Copyright 2012 Georg-August-Universität Göttingen, Germany // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. package de.ugoe.cs.autoquest.eventcore.gui; /** *

* Base class for all mouse interaction event types. *

* * @version 1.0 * @author Patrick Harms */ public abstract class MouseButtonInteraction extends MouseInteraction { /** *

* Id for object serialization. *

*/ private static final long serialVersionUID = 1L; /** *

* Describes the pressed mouse button. *

* * @version 1.0 * @author Patrick Harms */ public static enum Button { LEFT, MIDDLE, RIGHT, X; } /** *

* The button used for mouse interaction *

*/ private Button button; /** *

* The x coordinate, where the mouse interaction took place *

*/ private int x; /** *

* The y coordinate, where the mouse interaction took place *

*/ private int y; /** *

* Constructor. Creates a new {@link MouseButtonInteraction} *

* * @param button * the button associated with the interaction * @param x * the x coordinate of where the interaction took place on the target * @param y * the y coordinate of where the interaction took place on the target */ public MouseButtonInteraction(Button button, int x, int y) { this.button = button; this.x = x; this.y = y; } /** *

* Returns the button associated with the interaction. *

* * @return the button */ public Button getButton() { return button; } /** *

* Returns the x coordinate of where the interaction took place on the target. *

* * @return the x coordinate */ public int getX() { return x; } /** *

* Returns the y coordinate of where the interaction took place on the target. *

* * @return the y coordinate */ public int getY() { return y; } /* * (non-Javadoc) * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj instanceof MouseButtonInteraction) { return getButton().equals(((MouseButtonInteraction) obj).getButton()); } return false; } /* * (non-Javadoc) * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { return getButton().hashCode(); } }