[995] | 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 |
|
---|
| 15 | package de.ugoe.cs.autoquest.eventcore.gui;
|
---|
| 16 |
|
---|
| 17 | /**
|
---|
| 18 | * <p>
|
---|
| 19 | * Event type for a mouse drag and drop, i.e., pressing the left mouse button on an element,
|
---|
| 20 | * moving the mouse and releasing the mouse button afterwards.
|
---|
| 21 | * </p>
|
---|
| 22 | *
|
---|
| 23 | * @version 1.0
|
---|
| 24 | * @author Patrick Harms
|
---|
| 25 | */
|
---|
| 26 | public class MouseDragAndDrop extends MouseButtonInteraction {
|
---|
| 27 |
|
---|
| 28 | /**
|
---|
| 29 | * <p>
|
---|
| 30 | * Id for object serialization.
|
---|
| 31 | * </p>
|
---|
| 32 | */
|
---|
| 33 | private static final long serialVersionUID = 1L;
|
---|
| 34 |
|
---|
| 35 | /**
|
---|
| 36 | * <p>
|
---|
| 37 | * the x coordinate, where the drag started
|
---|
| 38 | * </p>
|
---|
| 39 | */
|
---|
| 40 | private int xStart;
|
---|
| 41 |
|
---|
| 42 | /**
|
---|
| 43 | * <p>
|
---|
| 44 | * the y coordinate, where the drag started
|
---|
| 45 | * </p>
|
---|
| 46 | */
|
---|
| 47 | private int yStart;
|
---|
| 48 |
|
---|
| 49 | /**
|
---|
| 50 | * <p>
|
---|
| 51 | * Constructor. Creates a new {@link MouseDragAndDrop} event type with the left mouse button
|
---|
| 52 | * as button per default
|
---|
| 53 | * </p>
|
---|
| 54 | *
|
---|
| 55 | * @param xStart the x coordinate, where the drag started
|
---|
| 56 | * @param yStart the y coordinate, where the drag started
|
---|
| 57 | * @param xEnd the x coordinate, where the drop ended
|
---|
| 58 | * @param yEnd the y coordinate, where the drop ended
|
---|
| 59 | *
|
---|
| 60 | *
|
---|
| 61 | * @see MouseButtonInteraction#MouseButtonInteraction(Button,int,int)
|
---|
| 62 | */
|
---|
| 63 | public MouseDragAndDrop(int xStart, int yStart, int xEnd, int yEnd) {
|
---|
| 64 | super(Button.LEFT, xEnd, yEnd);
|
---|
| 65 | this.xStart = xStart;
|
---|
| 66 | this.yStart = yStart;
|
---|
| 67 | }
|
---|
| 68 |
|
---|
| 69 | /*
|
---|
| 70 | * (non-Javadoc)
|
---|
| 71 | *
|
---|
| 72 | * @see de.harms.attef.userinteraction.Interaction#getName()
|
---|
| 73 | */
|
---|
| 74 | public String getName() {
|
---|
| 75 | return "MouseDragAndDrop";
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
| 79 | * @return the x coordinate, where the drag started
|
---|
| 80 | */
|
---|
| 81 | public int getXStart() {
|
---|
| 82 | return xStart;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
| 86 | * @return the y coordinate, where the drag started
|
---|
| 87 | */
|
---|
| 88 | public int getYStart() {
|
---|
| 89 | return yStart;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | /*
|
---|
| 93 | * (non-Javadoc)
|
---|
| 94 | *
|
---|
| 95 | * @see java.lang.Object#toString()
|
---|
| 96 | */
|
---|
| 97 | @Override
|
---|
| 98 | public String toString() {
|
---|
| 99 | return "mouse drag and drop ((" +
|
---|
| 100 | xStart + "," + yStart + ")-->(" + getX() + "," + getY() + "))";
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /*
|
---|
| 104 | * (non-Javadoc)
|
---|
| 105 | *
|
---|
| 106 | * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
|
---|
| 107 | */
|
---|
| 108 | public boolean startsLogicalSequence() {
|
---|
| 109 | return false;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | /*
|
---|
| 113 | * (non-Javadoc)
|
---|
| 114 | *
|
---|
| 115 | * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
|
---|
| 116 | */
|
---|
| 117 | public boolean finishesLogicalSequence() {
|
---|
| 118 | return false;
|
---|
| 119 | }
|
---|
| 120 |
|
---|
| 121 | /*
|
---|
| 122 | * (non-Javadoc)
|
---|
| 123 | *
|
---|
| 124 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
| 125 | */
|
---|
| 126 | @Override
|
---|
| 127 | public boolean equals(Object obj) {
|
---|
| 128 | if (obj instanceof MouseDragAndDrop) {
|
---|
| 129 | return
|
---|
| 130 | (getX() == ((MouseDragAndDrop) obj).getX()) &&
|
---|
| 131 | (getY() == ((MouseDragAndDrop) obj).getY()) &&
|
---|
| 132 | (getXStart() == ((MouseDragAndDrop) obj).getXStart()) &&
|
---|
| 133 | (getYStart() == ((MouseDragAndDrop) obj).getYStart());
|
---|
| 134 | }
|
---|
| 135 | return false;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | /*
|
---|
| 139 | * (non-Javadoc)
|
---|
| 140 | *
|
---|
| 141 | * @see java.lang.Object#hashCode()
|
---|
| 142 | */
|
---|
| 143 | @Override
|
---|
| 144 | public int hashCode() {
|
---|
| 145 | return getX() + getY() + getXStart() + getYStart();
|
---|
| 146 | }
|
---|
| 147 | }
|
---|