[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 | * Base class for all mouse interaction event types.
|
---|
| 20 | * </p>
|
---|
[544] | 21 | *
|
---|
[786] | 22 | * @version 1.0
|
---|
| 23 | * @author Patrick Harms
|
---|
[544] | 24 | */
|
---|
| 25 | public abstract class MouseButtonInteraction extends MouseInteraction {
|
---|
| 26 |
|
---|
[786] | 27 | /**
|
---|
| 28 | * <p>
|
---|
| 29 | * Id for object serialization.
|
---|
| 30 | * </p>
|
---|
| 31 | */
|
---|
[544] | 32 | private static final long serialVersionUID = 1L;
|
---|
| 33 |
|
---|
[786] | 34 | /**
|
---|
| 35 | * <p>
|
---|
| 36 | * Describes the pressed mouse button.
|
---|
| 37 | * </p>
|
---|
| 38 | *
|
---|
| 39 | * @version 1.0
|
---|
| 40 | * @author Patrick Harms
|
---|
| 41 | */
|
---|
[544] | 42 | public static enum Button {
|
---|
[590] | 43 | LEFT, MIDDLE, RIGHT, X;
|
---|
[544] | 44 | }
|
---|
| 45 |
|
---|
[786] | 46 | /**
|
---|
| 47 | * <p>
|
---|
| 48 | * The button used for mouse interaction
|
---|
| 49 | * </p>
|
---|
| 50 | */
|
---|
[550] | 51 | private Button button;
|
---|
[544] | 52 |
|
---|
| 53 | /**
|
---|
[786] | 54 | * <p>
|
---|
[945] | 55 | * The x coordinate, where the mouse interaction took place
|
---|
| 56 | * </p>
|
---|
| 57 | */
|
---|
| 58 | private int x;
|
---|
| 59 |
|
---|
| 60 | /**
|
---|
| 61 | * <p>
|
---|
| 62 | * The y coordinate, where the mouse interaction took place
|
---|
| 63 | * </p>
|
---|
| 64 | */
|
---|
| 65 | private int y;
|
---|
| 66 |
|
---|
| 67 | /**
|
---|
| 68 | * <p>
|
---|
[786] | 69 | * Constructor. Creates a new {@link MouseButtonInteraction}
|
---|
| 70 | * </p>
|
---|
[544] | 71 | *
|
---|
[786] | 72 | * @param button
|
---|
| 73 | * the button associated with the interaction
|
---|
[945] | 74 | * @param x
|
---|
| 75 | * the x coordinate of where the interaction took place on the target
|
---|
| 76 | * @param y
|
---|
| 77 | * the y coordinate of where the interaction took place on the target
|
---|
[544] | 78 | */
|
---|
[945] | 79 | public MouseButtonInteraction(Button button, int x, int y) {
|
---|
[550] | 80 | this.button = button;
|
---|
[945] | 81 | this.x = x;
|
---|
| 82 | this.y = y;
|
---|
[544] | 83 | }
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
[786] | 86 | * <p>
|
---|
| 87 | * Returns the button associated with the interaction.
|
---|
| 88 | * </p>
|
---|
| 89 | *
|
---|
| 90 | * @return the button
|
---|
[544] | 91 | */
|
---|
| 92 | public Button getButton() {
|
---|
[550] | 93 | return button;
|
---|
[544] | 94 | }
|
---|
[786] | 95 |
|
---|
[945] | 96 | /**
|
---|
| 97 | * <p>
|
---|
| 98 | * Returns the x coordinate of where the interaction took place on the target.
|
---|
| 99 | * </p>
|
---|
| 100 | *
|
---|
| 101 | * @return the x coordinate
|
---|
| 102 | */
|
---|
| 103 | public int getX() {
|
---|
| 104 | return x;
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 | /**
|
---|
| 108 | * <p>
|
---|
| 109 | * Returns the y coordinate of where the interaction took place on the target.
|
---|
| 110 | * </p>
|
---|
| 111 | *
|
---|
| 112 | * @return the y coordinate
|
---|
| 113 | */
|
---|
| 114 | public int getY() {
|
---|
| 115 | return y;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
[681] | 118 | /*
|
---|
| 119 | * (non-Javadoc)
|
---|
| 120 | *
|
---|
| 121 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
| 122 | */
|
---|
| 123 | @Override
|
---|
| 124 | public boolean equals(Object obj) {
|
---|
| 125 | if (obj instanceof MouseButtonInteraction) {
|
---|
| 126 | return getButton().equals(((MouseButtonInteraction) obj).getButton());
|
---|
| 127 | }
|
---|
| 128 | return false;
|
---|
| 129 | }
|
---|
[544] | 130 |
|
---|
[681] | 131 | /*
|
---|
| 132 | * (non-Javadoc)
|
---|
| 133 | *
|
---|
| 134 | * @see java.lang.Object#hashCode()
|
---|
| 135 | */
|
---|
| 136 | @Override
|
---|
| 137 | public int hashCode() {
|
---|
| 138 | return getButton().hashCode();
|
---|
| 139 | }
|
---|
[544] | 140 | }
|
---|