[786] | 1 |
|
---|
[922] | 2 | package de.ugoe.cs.autoquest.eventcore.gui;
|
---|
[544] | 3 |
|
---|
| 4 | /**
|
---|
[786] | 5 | * <p>
|
---|
| 6 | * Event type for pressing a mouse button.
|
---|
| 7 | * </p>
|
---|
[544] | 8 | *
|
---|
[786] | 9 | * @version 1.0
|
---|
| 10 | * @author Patrick Harms
|
---|
[544] | 11 | */
|
---|
| 12 | public class MouseButtonDown extends MouseButtonInteraction {
|
---|
| 13 |
|
---|
[786] | 14 | /**
|
---|
| 15 | * <p>
|
---|
| 16 | * Id for object serialization.
|
---|
| 17 | * </p>
|
---|
| 18 | */
|
---|
[544] | 19 | private static final long serialVersionUID = 1L;
|
---|
| 20 |
|
---|
| 21 | /**
|
---|
[786] | 22 | * <p>
|
---|
| 23 | * Constructor. Creates a new {@link MouseButtonDown} event type.
|
---|
| 24 | * </p>
|
---|
| 25 | *
|
---|
| 26 | * @see MouseButtonInteraction#MouseButtonInteraction(Button)
|
---|
[544] | 27 | */
|
---|
| 28 | public MouseButtonDown(Button button) {
|
---|
| 29 | super(button);
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | /*
|
---|
| 33 | * (non-Javadoc)
|
---|
| 34 | *
|
---|
| 35 | * @see de.harms.attef.userinteraction.Interaction#getName()
|
---|
| 36 | */
|
---|
| 37 | public String getName() {
|
---|
| 38 | if (super.getButton() == Button.LEFT) {
|
---|
| 39 | return "LeftMouseButtonDown";
|
---|
| 40 | }
|
---|
| 41 | else if (super.getButton() == Button.MIDDLE) {
|
---|
| 42 | return "MiddleMouseButtonDown";
|
---|
| 43 | }
|
---|
| 44 | else if (super.getButton() == Button.RIGHT) {
|
---|
| 45 | return "RightMouseButtonDown";
|
---|
| 46 | }
|
---|
| 47 | else {
|
---|
| 48 | return "UnknownMouseButtonDown";
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | /*
|
---|
| 53 | * (non-Javadoc)
|
---|
| 54 | *
|
---|
| 55 | * @see java.lang.Object#toString()
|
---|
| 56 | */
|
---|
| 57 | @Override
|
---|
| 58 | public String toString() {
|
---|
| 59 | if (super.getButton() == Button.LEFT) {
|
---|
| 60 | return "left mouse button down";
|
---|
| 61 | }
|
---|
| 62 | else if (super.getButton() == Button.MIDDLE) {
|
---|
| 63 | return "middle mouse button down";
|
---|
| 64 | }
|
---|
| 65 | else if (super.getButton() == Button.RIGHT) {
|
---|
| 66 | return "right mouse button down";
|
---|
| 67 | }
|
---|
| 68 | else {
|
---|
| 69 | return "unknown mouse button down";
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | /*
|
---|
| 74 | * (non-Javadoc)
|
---|
| 75 | *
|
---|
| 76 | * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
|
---|
| 77 | */
|
---|
| 78 | public boolean startsLogicalSequence() {
|
---|
| 79 | return true;
|
---|
| 80 | }
|
---|
| 81 |
|
---|
| 82 | /*
|
---|
| 83 | * (non-Javadoc)
|
---|
| 84 | *
|
---|
| 85 | * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
|
---|
| 86 | */
|
---|
| 87 | public boolean finishesLogicalSequence() {
|
---|
| 88 | return false;
|
---|
| 89 | }
|
---|
[786] | 90 |
|
---|
[681] | 91 | /*
|
---|
| 92 | * (non-Javadoc)
|
---|
| 93 | *
|
---|
| 94 | * @see java.lang.Object#equals(java.lang.Object)
|
---|
| 95 | */
|
---|
| 96 | @Override
|
---|
| 97 | public boolean equals(Object obj) {
|
---|
| 98 | if (obj instanceof MouseButtonDown) {
|
---|
| 99 | return getButton().equals(((MouseButtonDown) obj).getButton());
|
---|
| 100 | }
|
---|
| 101 | return false;
|
---|
| 102 | }
|
---|
[544] | 103 |
|
---|
[681] | 104 | /*
|
---|
| 105 | * (non-Javadoc)
|
---|
| 106 | *
|
---|
| 107 | * @see java.lang.Object#hashCode()
|
---|
| 108 | */
|
---|
| 109 | @Override
|
---|
| 110 | public int hashCode() {
|
---|
| 111 | return getButton().hashCode();
|
---|
| 112 | }
|
---|
| 113 |
|
---|
[544] | 114 | }
|
---|