01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package jsx.ui.event;
21 
22 import js.Id;
23 import js.Initializer;
24 import jsx.Configurable;
25 import jsx.Source;
26 import jsx.ui.Component;
27 import jsx.ui.Widget;
28 
29 /**
30  * <p>An abstract type of high level events that may be fired from a source widget when 
31  * the mouse has position data to report to the element wrapped by the widget.</p>
32  * <p>This class is designed generic with the type parameter being the type of its 
33  * corresponding listener type. A subclass must be concrete and final if it is to be an 
34  * event type. As an event type, the subclass must also declare the type parameter of 
35  * this class as the type of its own listener.</p>
36  * <p>An event listener is typically of an interface with a declared method to react on 
37  * the event it handles so that the class of the event can implement the {@link jsx.Source.Event#execute(Object)} 
38  * method by simply calling that declared method passing the event itself as the argument. 
39  * A subclass of this class defines events uniquely typed by the subclass itself and 
40  * designates a listener type corresponding to that type of events.</p>
41  * <p>For an event source to fire an event, the listener of the event must have been 
42  * registered onto the source object with a call to the {@link Source#addListener(Class, Object)} 
43  * method which asks both the type of the event and the listener object for arguments.</p>
44  * <p>Note that, high level events are {@link Configurable}.</p>
45  * 
46  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
47  */
48 public abstract class Position<T> extends Widget.Event<T>
49 {
50     /**
51      * <p>A global identifier for a configurable property of a {@link Position} object.</p>
52      * <p>The identified configurable property of a {@link Position} object 
53      * refers to an integer value specifying the X coordinate of the mouse position, 
54      * in pixels when the event is fired.</p>
55      * @since 1.0
56      */
57     public final static Id<Number> X = new Id<Number>();
58     /**
59      * <p>A global identifier for a configurable property of a {@link Position} object.</p>
60      * <p>The identified configurable property of a {@link Position} object 
61      * refers to an integer value specifying the Y coordinate of the mouse position, 
62      * in pixels when the event is fired.</p>
63      * @since 1.0
64      */
65     public final static Id<Number> Y = new Id<Number>();
66 
67     /**
68      * <p>Constructs an event of this type.</p>
69      * <p>This constructor simply invokes the default constructor of the superclass and 
70      * sets its configurable property {@link jsx.ui.Widget.Event#TARGET} to the first 
71      * argument, {@link #X} to the second, and {@link #Y} to the third.</p>
72      * <p>Note that, this constructor does not change the configurable properties 
73      * {@link jsx.Source.Event#BUBBLE} and {@link jsx.Source.Event#UPDATE}.</p>
74      * @param target A related mouse target when this event is fired.
75      * @param x The X coordinate, in pixels,  of the mouse position.
76      * @param y The y coordinate, in pixels,  of the mouse position.
77      * @since 1.0
78      */
79     protected Position(Component target, Number x, Number y) {
80         super(new Initializer().set(TARGET, target)
81                 .set(X, x).set(Y, y).var());
82     }
83 }