[927] | 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.
|
---|
[786] | 14 |
|
---|
[922] | 15 | package de.ugoe.cs.autoquest.eventcore.gui;
|
---|
[544] | 16 |
|
---|
| 17 | /**
|
---|
[786] | 18 | * <p>
|
---|
| 19 | * Event type for a mouse click, i.e., pressing and releasing it right away.
|
---|
| 20 | * </p>
|
---|
[544] | 21 | *
|
---|
[786] | 22 | * @version 1.0
|
---|
| 23 | * @author Patrick Harms
|
---|
[544] | 24 | */
|
---|
| 25 | public class MouseClick extends MouseButtonInteraction {
|
---|
| 26 |
|
---|
[786] | 27 | /**
|
---|
| 28 | * <p>
|
---|
| 29 | * Id for object serialization.
|
---|
| 30 | * </p>
|
---|
| 31 | */
|
---|
[544] | 32 | private static final long serialVersionUID = 1L;
|
---|
| 33 |
|
---|
| 34 | /**
|
---|
[786] | 35 | * <p>
|
---|
| 36 | * Constructor. Creates a new {@link MouseClick} event type.
|
---|
| 37 | * </p>
|
---|
| 38 | *
|
---|
[945] | 39 | * @see MouseButtonInteraction#MouseButtonInteraction(Button,int,int)
|
---|
[544] | 40 | */
|
---|
[945] | 41 | public MouseClick(Button button, int x, int y) {
|
---|
| 42 | super(button, x, y);
|
---|
[544] | 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) {
|
---|
[1359] | 73 | return "left mouse btn \u21D5 (" + getX() + "," + getY() + ")";
|
---|
[544] | 74 | }
|
---|
| 75 | else if (super.getButton() == Button.MIDDLE) {
|
---|
[1359] | 76 | return "middle mouse btn \u21D5 (" + getX() + "," + getY() + ")";
|
---|
[544] | 77 | }
|
---|
| 78 | else if (super.getButton() == Button.RIGHT) {
|
---|
[1359] | 79 | return "right mouse btn \u21D5 (" + getX() + "," + getY() + ")";
|
---|
[544] | 80 | }
|
---|
| 81 | else {
|
---|
[1359] | 82 | return "unknown mouse btn \u21D5 (" + getX() + "," + getY() + ")";
|
---|
[544] | 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 |
|
---|
[681] | 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) {
|
---|
[945] | 112 | return
|
---|
| 113 | getButton().equals(((MouseClick) obj).getButton()) &&
|
---|
| 114 | (getX() == ((MouseClick) obj).getX()) &&
|
---|
| 115 | (getY() == ((MouseClick) obj).getY());
|
---|
[681] | 116 | }
|
---|
| 117 | return false;
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | /*
|
---|
| 121 | * (non-Javadoc)
|
---|
| 122 | *
|
---|
| 123 | * @see java.lang.Object#hashCode()
|
---|
| 124 | */
|
---|
| 125 | @Override
|
---|
| 126 | public int hashCode() {
|
---|
[945] | 127 | return getButton().hashCode() + getX() + getY();
|
---|
[681] | 128 | }
|
---|
[544] | 129 | }
|
---|