[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;
|
---|
[591] | 16 |
|
---|
| 17 | /**
|
---|
[786] | 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>
|
---|
[591] | 22 | *
|
---|
[786] | 23 | * @version 1.0
|
---|
| 24 | * @author Patrick Harms
|
---|
[591] | 25 | */
|
---|
| 26 | public class MouseDoubleClick extends MouseButtonInteraction {
|
---|
| 27 |
|
---|
[786] | 28 | /**
|
---|
| 29 | * <p>
|
---|
| 30 | * Id for object serialization.
|
---|
| 31 | * </p>
|
---|
| 32 | */
|
---|
[591] | 33 | private static final long serialVersionUID = 1L;
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
[786] | 36 | * <p>
|
---|
| 37 | * Constructor. Creates a new {@link MouseDoubleClick} event type.
|
---|
| 38 | * </p>
|
---|
| 39 | *
|
---|
[945] | 40 | * @see MouseButtonInteraction#MouseButtonInteraction(Button, int, int)
|
---|
[591] | 41 | */
|
---|
[945] | 42 | public MouseDoubleClick(Button button, int x, int y) {
|
---|
| 43 | super(button, x, y);
|
---|
[591] | 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) {
|
---|
[945] | 74 | return "left mouse double click (" + getX() + "," + getY() + ")";
|
---|
[591] | 75 | }
|
---|
| 76 | else if (super.getButton() == Button.MIDDLE) {
|
---|
[945] | 77 | return "middle mouse double click (" + getX() + "," + getY() + ")";
|
---|
[591] | 78 | }
|
---|
| 79 | else if (super.getButton() == Button.RIGHT) {
|
---|
[945] | 80 | return "right mouse double click (" + getX() + "," + getY() + ")";
|
---|
[591] | 81 | }
|
---|
| 82 | else {
|
---|
[945] | 83 | return "unknown mouse button double click (" + getX() + "," + getY() + ")";
|
---|
[591] | 84 | }
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | /*
|
---|
| 88 | * (non-Javadoc)
|
---|
| 89 | *
|
---|
| 90 | * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
|
---|
| 91 | */
|
---|
| 92 | public boolean startsLogicalSequence() {
|
---|
| 93 | return false;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | /*
|
---|
| 97 | * (non-Javadoc)
|
---|
| 98 | *
|
---|
| 99 | * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
|
---|
| 100 | */
|
---|
| 101 | public boolean finishesLogicalSequence() {
|
---|
| 102 | return false;
|
---|
| 103 | }
|
---|
| 104 |
|
---|
[681] | 105 | /*
|
---|
| 106 | * (non-Javadoc)
|
---|
| 107 | *
|
---|
| 108 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
| 109 | */
|
---|
| 110 | @Override
|
---|
| 111 | public boolean equals(Object obj) {
|
---|
| 112 | if (obj instanceof MouseDoubleClick) {
|
---|
[945] | 113 | return
|
---|
| 114 | getButton().equals(((MouseDoubleClick) obj).getButton()) &&
|
---|
| 115 | (getX() == ((MouseDoubleClick) obj).getX()) &&
|
---|
| 116 | (getY() == ((MouseDoubleClick) obj).getY());
|
---|
[681] | 117 | }
|
---|
| 118 | return false;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /*
|
---|
| 122 | * (non-Javadoc)
|
---|
| 123 | *
|
---|
| 124 | * @see java.lang.Object#hashCode()
|
---|
| 125 | */
|
---|
| 126 | @Override
|
---|
| 127 | public int hashCode() {
|
---|
[945] | 128 | return getButton().hashCode() + getX() + getY();
|
---|
[681] | 129 | }
|
---|
[591] | 130 | }
|
---|