]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.eclipse.swt.win32.win32.x86_64/src/org/eclipse/swt/widgets/Touch.java
f28d9a087ecb75fc755c85d11a5c6268437497c7
[simantics/platform.git] / bundles / org.eclipse.swt.win32.win32.x86_64 / src / org / eclipse / swt / widgets / Touch.java
1 /*******************************************************************************
2  * Copyright (c) 2010, 2011 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.swt.widgets;
15
16 /**
17  * Instances of this class are created in response to a
18  * touch-based input device being touched. They are found
19  * in the <code>touches</code> field of an Event or TouchEvent.
20  *
21  * @see org.eclipse.swt.events.TouchEvent
22  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
23  *
24  * @since 3.7
25  */
26 public final class Touch {
27
28         /**
29          * The unique identity of the touch. Use this value to track changes to a touch
30          * during the touch's life. Two touches may have the same identity even if they
31          * come from different sources.
32          */
33         public long id;
34
35         /**
36          * The object representing the input source that generated the touch.
37          */
38         public TouchSource source;
39
40         /**
41          * The state of this touch at the time it was generated. If this field is 0
42          * then the finger is still touching the device but has not moved
43          * since the last <code>TouchEvent</code> was generated.
44          *
45          * @see org.eclipse.swt.SWT#TOUCHSTATE_DOWN
46          * @see org.eclipse.swt.SWT#TOUCHSTATE_MOVE
47          * @see org.eclipse.swt.SWT#TOUCHSTATE_UP
48          */
49         public int state;
50
51         /**
52          * A flag indicating that the touch is the first touch from a previous
53          * state of no touch points. Once designated as such, the touch remains
54          * the primary touch until all fingers are removed from the device.
55          */
56         public boolean primary;
57
58         /**
59          * The x location of the touch in TouchSource coordinates.
60          */
61         public int x;
62
63         /**
64          * The y location of the touch in TouchSource coordinates.
65          */
66         public int y;
67
68 /**
69  * Constructs a new touch state from the given inputs.
70  *
71  * @param identity Identity of the touch
72  * @param source Object representing the device that generated the touch
73  * @param state One of the state constants representing the state of this touch
74  * @param primary Whether or not the touch is the primary touch
75  * @param x X location of the touch in screen coordinates
76  * @param y Y location of the touch in screen coordinates
77  */
78 Touch (long identity, TouchSource source, int state, boolean primary, int x, int y) {
79         this.id = identity;
80         this.source = source;
81         this.state = state;
82         this.primary = primary;
83         this.x = x;
84         this.y = y;
85 }
86
87 /**
88  * Returns a string containing a concise, human-readable
89  * description of the receiver.
90  *
91  * @return a string representation of the event
92  */
93 @Override
94 public String toString() {
95         return "Touch {id=" + id
96         + " source=" + source
97         + " state=" + state
98         + " primary=" + primary
99         + " x=" + x
100         + " y=" + y
101         + "}";
102 }
103
104 }