source: trunk/autoquest-core-events/src/main/java/de/ugoe/cs/autoquest/eventcore/gui/MouseClick.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: 3.2 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 mouse click, i.e., pressing and releasing it right away.
20 * </p>
21 *
22 * @version 1.0
23 * @author Patrick Harms
24 */
25public class MouseClick extends MouseButtonInteraction {
26
27    /**
28     * <p>
29     * Id for object serialization.
30     * </p>
31     */
32    private static final long serialVersionUID = 1L;
33
34    /**
35     * <p>
36     * Constructor. Creates a new {@link MouseClick} event type.
37     * </p>
38     *
39     * @see MouseButtonInteraction#MouseButtonInteraction(Button)
40     */
41    public MouseClick(Button button) {
42        super(button);
43    }
44
45    /*
46     * (non-Javadoc)
47     *
48     * @see de.harms.attef.userinteraction.Interaction#getName()
49     */
50    public String getName() {
51        if (super.getButton() == Button.LEFT) {
52            return "LeftMouseClick";
53        }
54        else if (super.getButton() == Button.MIDDLE) {
55            return "MiddleMouseClick";
56        }
57        else if (super.getButton() == Button.RIGHT) {
58            return "RightMouseClick";
59        }
60        else {
61            return "UnknownMouseButtonClick";
62        }
63    }
64
65    /*
66     * (non-Javadoc)
67     *
68     * @see java.lang.Object#toString()
69     */
70    @Override
71    public String toString() {
72        if (super.getButton() == Button.LEFT) {
73            return "left mouse click";
74        }
75        else if (super.getButton() == Button.MIDDLE) {
76            return "middle mouse click";
77        }
78        else if (super.getButton() == Button.RIGHT) {
79            return "right mouse click";
80        }
81        else {
82            return "unknown mouse button click";
83        }
84    }
85
86    /*
87     * (non-Javadoc)
88     *
89     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
90     */
91    public boolean startsLogicalSequence() {
92        return false;
93    }
94
95    /*
96     * (non-Javadoc)
97     *
98     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
99     */
100    public boolean finishesLogicalSequence() {
101        return false;
102    }
103
104    /*
105     * (non-Javadoc)
106     *
107     * @see java.lang.Object#equals(java.lang.Object)
108     */
109    @Override
110    public boolean equals(Object obj) {
111        if (obj instanceof MouseClick) {
112            return getButton().equals(((MouseClick) obj).getButton());
113        }
114        return false;
115    }
116
117    /*
118     * (non-Javadoc)
119     *
120     * @see java.lang.Object#hashCode()
121     */
122    @Override
123    public int hashCode() {
124        return getButton().hashCode();
125    }
126}
Note: See TracBrowser for help on using the repository browser.