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

Last change on this file was 2254, checked in by pharms, 7 years ago
  • solved some findbugs issues
File size: 3.3 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 * Event type for a double click, i.e., pressing the mouse, releasing it, pressing it, and releasing
20 * it again right away.
21 * </p>
22 *
23 * @version 1.0
24 * @author Patrick Harms
25 */
26public class MouseDoubleClick extends MouseButtonInteraction {
27
28    /**
29     * <p>
30     * Id for object serialization.
31     * </p>
32     */
33    private static final long serialVersionUID = 1L;
34
35    /**
36     * <p>
37     * Constructor. Creates a new {@link MouseDoubleClick} event type.
38     * </p>
39     *
40     * @see MouseButtonInteraction#MouseButtonInteraction(Button, int, int)
41     */
42    public MouseDoubleClick(Button button, int x, int y) {
43        super(button, x, y);
44    }
45
46    /*
47     * (non-Javadoc)
48     *
49     * @see de.harms.attef.userinteraction.Interaction#getName()
50     */
51    public String getName() {
52        if (super.getButton() == Button.LEFT) {
53            return "LeftMouseDoubleClick";
54        }
55        else if (super.getButton() == Button.MIDDLE) {
56            return "MiddleMouseDoubleClick";
57        }
58        else if (super.getButton() == Button.RIGHT) {
59            return "RightMouseDoubleClick";
60        }
61        else {
62            return "UnknownMouseButtonDoubleClick";
63        }
64    }
65
66    /*
67     * (non-Javadoc)
68     *
69     * @see java.lang.Object#toString()
70     */
71    @Override
72    public String toString() {
73        if (super.getButton() == Button.LEFT) {
74            return "left mouse btn \u21D5\u21D5 (" + getX() + "," + getY() + ")";
75        }
76        else if (super.getButton() == Button.MIDDLE) {
77            return "middle mouse btn \u21D5\u21D5 (" + getX() + "," + getY() + ")";
78        }
79        else if (super.getButton() == Button.RIGHT) {
80            return "right mouse btn \u21D5\u21D5 (" + getX() + "," + getY() + ")";
81        }
82        else {
83            return "unknown mouse button btn \u21D5\u21D5 (" + getX() + "," + getY() + ")";
84        }
85    }
86
87    /*
88     * (non-Javadoc)
89     *
90     * @see java.lang.Object#equals(java.lang.Object)
91     */
92    @Override
93    public boolean equals(Object obj) {
94        if (obj instanceof MouseDoubleClick) {
95            return
96                getButton().equals(((MouseDoubleClick) obj).getButton()) &&
97                (getX() == ((MouseDoubleClick) obj).getX()) &&
98                (getY() == ((MouseDoubleClick) obj).getY());
99        }
100        return false;
101    }
102
103    /*
104     * (non-Javadoc)
105     *
106     * @see java.lang.Object#hashCode()
107     */
108    @Override
109    public int hashCode() {
110        return getButton().hashCode() + getX() + getY();
111    }
112}
Note: See TracBrowser for help on using the repository browser.