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

Last change on this file since 2252 was 1359, checked in by pharms, 10 years ago
  • shortened result of toString calls to events
  • Property svn:executable set to *
File size: 3.5 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,int,int)
40     */
41    public MouseClick(Button button, int x, int y) {
42        super(button, x, y);
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 btn \u21D5 (" + getX() + "," + getY() + ")";
74        }
75        else if (super.getButton() == Button.MIDDLE) {
76            return "middle mouse btn \u21D5 (" + getX() + "," + getY() + ")";
77        }
78        else if (super.getButton() == Button.RIGHT) {
79            return "right mouse btn \u21D5 (" + getX() + "," + getY() + ")";
80        }
81        else {
82            return "unknown mouse btn \u21D5 (" + getX() + "," + getY() + ")";
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
113                getButton().equals(((MouseClick) obj).getButton()) &&
114                (getX() == ((MouseClick) obj).getX()) &&
115                (getY() == ((MouseClick) obj).getY());
116        }
117        return false;
118    }
119
120    /*
121     * (non-Javadoc)
122     *
123     * @see java.lang.Object#hashCode()
124     */
125    @Override
126    public int hashCode() {
127        return getButton().hashCode() + getX() + getY();
128    }
129}
Note: See TracBrowser for help on using the repository browser.