source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/MouseButtonInteraction.java @ 927

Last change on this file since 927 was 927, checked in by sherbold, 12 years ago
  • added copyright under the Apache License, Version 2.0
  • Property svn:executable set to *
File size: 2.4 KB
Line 
1//   Copyright 2012 Georg-August-Universität Göttingen, Germany
2//
3//   Licensed under the Apache License, Version 2.0 (the "License");
4//   you may not use this file except in compliance with the License.
5//   You may obtain a copy of the License at
6//
7//       http://www.apache.org/licenses/LICENSE-2.0
8//
9//   Unless required by applicable law or agreed to in writing, software
10//   distributed under the License is distributed on an "AS IS" BASIS,
11//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//   See the License for the specific language governing permissions and
13//   limitations under the License.
14
15package de.ugoe.cs.autoquest.eventcore.gui;
16
17/**
18 * <p>
19 * Base class for all mouse interaction event types.
20 * </p>
21 *
22 * @version 1.0
23 * @author Patrick Harms
24 */
25public abstract class MouseButtonInteraction extends MouseInteraction {
26
27    /**
28     * <p>
29     * Id for object serialization.
30     * </p>
31     */
32    private static final long serialVersionUID = 1L;
33
34    /**
35     * <p>
36     * Describes the pressed mouse button.
37     * </p>
38     *
39     * @version 1.0
40     * @author Patrick Harms
41     */
42    public static enum Button {
43        LEFT, MIDDLE, RIGHT, X;
44    }
45
46    /**
47     * <p>
48     * The button used for mouse interaction
49     * </p>
50     */
51    private Button button;
52
53    /**
54     * <p>
55     * Constructor. Creates a new {@link MouseButtonInteraction}
56     * </p>
57     *
58     * @param button
59     *            the button associated with the interaction
60     */
61    public MouseButtonInteraction(Button button) {
62        this.button = button;
63    }
64
65    /**
66     * <p>
67     * Returns the button associated with the interaction.
68     * </p>
69     *
70     * @return the button
71     */
72    public Button getButton() {
73        return button;
74    }
75
76    /*
77     * (non-Javadoc)
78     *
79     * @see java.lang.Object#equals(java.lang.Object)
80     */
81    @Override
82    public boolean equals(Object obj) {
83        if (obj instanceof MouseButtonInteraction) {
84            return getButton().equals(((MouseButtonInteraction) obj).getButton());
85        }
86        return false;
87    }
88
89    /*
90     * (non-Javadoc)
91     *
92     * @see java.lang.Object#hashCode()
93     */
94    @Override
95    public int hashCode() {
96        return getButton().hashCode();
97    }
98}
Note: See TracBrowser for help on using the repository browser.