1 /*******************************************************************************
2 * Copyright (c) 2010, 2018 IBM Corporation and others.
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/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.widgets;
17 import org.eclipse.swt.graphics.*;
20 * Instances of this class represent sources of touch input that generate <code>Touch</code> objects.
21 * They also provide information about the input source, which is important for interpreting the
22 * information in the <code>Touch</code> object.
24 * Instances of this class can be marked as direct or indirect:
26 * <li>When an instance is <em>direct</em>, the touch source is a touch-sensitive digitizer surface such
27 * as a tablet or a touch screen. There is a one-to-one mapping between a touch point and a location in
30 * When an instance is <em>indirect</em> (more precisely, not direct), the touch source is a track pad or
31 * other device that normally moves the cursor, but is also able to interpret multiple touches on its surface.
32 * In this case there is not a one-to-one mapping between the location of the touch on the device and a
33 * location on the display because the user can remove their finger or stylus and touch another part of
34 * the device and resume what they were doing.
39 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
43 public final class TouchSource {
49 * Constructs a new touch source from the given inputs.
51 * @param direct Is the touch source direct or indirect?
52 * @param height height of the source in points.
53 * @param width width of the source in points.
55 TouchSource (long handle, boolean direct, Rectangle bounds) {
62 * Returns the type of touch input this source generates, <code>true</code> for direct or <code>false</code> for indirect.
64 * @return <code>true</code> if the input source is direct, or <code>false</code> otherwise
66 public boolean isDirect () {
71 * Returns the bounding rectangle of the device. For a direct source, this corresponds to the bounds of
72 * the display device in pixels. For an indirect source, this contains the size of the device in points.
74 * Note that the x and y values may not necessarily be 0 if the TouchSource is a direct source.
76 * @return the bounding rectangle of the input source
78 public Rectangle getBounds () {
79 return new Rectangle (bounds.x, bounds.y, bounds.width, bounds.height);
83 * Returns a string containing a concise, human-readable
84 * description of the receiver.
86 * @return a string representation of the event
89 public String toString () {
90 return "TouchSource {handle=" + handle + " direct=" + direct + " bounds=" + bounds + "}";