Project

General

Profile

Download (1.61 KB) Statistics
| Branch: | Tag: | Revision:
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.draw2d;
12

    
13
import org.eclipse.draw2d.geometry.Point;
14

    
15
/**
16
 * An event caused by the user interacting with the mouse.
17
 */
18
public class MouseEvent extends InputEvent {
19

    
20
	/** The X coordinate of the mouse event. */
21
	public int x;
22
	/** The Y coordinate of the mouse event. */
23
	public int y;
24

    
25
	/** The button that was pressed or released: {1, 2, 3}. */
26
	public int button;
27

    
28
	/**
29
	 * Constructor for MouseEvent.
30
	 * 
31
	 * @param x
32
	 * @param y
33
	 * @param dispatcher
34
	 * @param f
35
	 * @param button
36
	 * @param stateMask
37
	 * @since 3.6
38
	 */
39
	public MouseEvent(int x, int y, EventDispatcher dispatcher, IFigure f,
40
			int button, int stateMask) {
41
		super(dispatcher, f, stateMask);
42
		Point pt = Point.SINGLETON;
43
		pt.setLocation(x, y);
44
		f.translateToRelative(pt);
45
		this.button = button;
46
		this.x = pt.x;
47
		this.y = pt.y;
48
	}
49

    
50
	/**
51
	 * @return the location of this mouse event
52
	 */
53
	public Point getLocation() {
54
		return new Point(x, y);
55
	}
56

    
57
	/**
58
	 * @see Object#toString()
59
	 */
60
	public String toString() {
61
		return "MouseEvent(" + x + ',' + y + ") to Figure: " + source;//$NON-NLS-2$//$NON-NLS-1$
62
	}
63

    
64
}
(107-107/171)