javafx.scene.input.*Event classes construction (original) (raw)
Richard Bair richard.bair at oracle.com
Fri Nov 2 10:41:34 PDT 2012
- Previous message: API REVIEW REQUEST: Public API for Node Orientation
- Next message: javafx.scene.input.*Event classes construction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Looks OK to me. Lets not deprecated the protected constructors though, unless there is a good reason to (even if they are more or less useless).
Richard
On Jun 21, 2012, at 1:58 AM, Martin Sladecek <martin.sladecek at oracle.com> wrote:
Hi, here's my proposal for new constructors and methods for events in javafx.scene.input package (for 3.0)
I changed all impl*event factory methods to constructors and added a variant with (Object source, EventTarget target, ...), as Event, InputEvent, GestureEvent already had such constructors as part of public API. Usually, these constructors are used only when the target (or source) is known, so no copies must be made during the event dispatch process. Because Event has a "copyFor" method that returns a copy of the current object, changing some properties to the values passed in, I used the same pattern for all the implcopy methods. I also added copyFor(Object source, EvenTarget target, EventType type) to events that have multiple types. Regarding the rest of @treatAsPrivate methods, I think all of them may be part of public API, as they don't expose any internal information or structures. I also made most of the classes final. ContextMenuEvent: public ContextMenuEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, boolean keyboardTrigger) public ContextMenuEvent(EventType eventType, double x, double y, double screenX, double screenY, boolean keyboardTrigger) DragEvent: public DragEvent(Object source, EventTarget target, EventType eventType, Dragboard dragboard, double x, double y, double screenX, double screenY, TransferMode transferMode, Object gestureSource, Object gestureTarget) public DragEvent(EventType eventType, Dragboard dragboard,double x, double y, double screenX, double screenY, TransferMode transferMode, Object gestureSource, Object gestureTarget) public DragEvent copyFor(Object source, EventTarget target, Object gestureSource, Object gestureTarget, Dragboard dragboard) public DragEvent copyFor(Object source, EventTarget target, Object gestureSource, Object gestureTarget, EventType eventType) public DragEvent copyFor(Object source, EventTarget target, Object gestureSource, Object gestureTarget, TransferMode transferMode, EventType eventType) public DragEvent copyFor(Object newSource, EventTarget newTarget, EventType type) public Object getAcceptingObject() // source that accepted the drag GestureEvent: (there were 2 protected constructors that were creating empty events, I'd like to make them deprecated) protected GestureEvent(Object source, EventTarget target, EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia) protected GestureEvent(EventType<? extends GestureEvent> eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia) InputMethodEvent: public InputMethodEvent(Object source, EventTarget target, EventType eventType, List composed, String committed, int caretPosition) InputMethodTextRun: public InputMethodTextRun(String text, InputMethodHighlight highlight) KeyEvent: public KeyEvent(Object source, EventTarget target, EventType eventType, String character, String text, int code, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown) public KeyEvent(EventType eventType, String character, String text, int code, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown) public KeyEvent(EventType eventType, String character, String text, KeyCode code, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown) public KeyEvent copyFor(Object newSource, EventTarget newTarget, EventType type) MouseEvent: public MouseEvent(EventType<? extends MouseEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button,int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger) public MouseEvent(EventType<? extends MouseEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button,int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, boolean stillSincePress) public MouseEvent(Object source, EventTarget target, EventType<? extends MouseEvent> eventType, double x, double y, double screenX, double screenY, MouseButton button,int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, boolean stillSincePress) public MouseEvent copyFor(Object newSource, EventTarget newTarget, EventType<? extends MouseEvent> type) public boolean isPopupTrigger() //This was impl before, but it's used in some controls, so it might be useful public static MouseDragEvent copyForMouseDragEvent(MouseEvent e, Object newSource, EventTarget newTarget, EventType type, Object gestureSource) // this will do a copy of mouse event, creating a mouseDragEvent from it. It's used internally and it's just a convenience, so can it doesn't have to be added at all to the public API MouseDragEvent: public MouseDragEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, Object gestureSource) public MouseDragEvent( EventType eventType, double x, double y, double screenX, double screenY, MouseButton button, int clickCount, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean primaryButtonDown, boolean middleButtonDown, boolean secondaryButtonDown, boolean synthesized, boolean popupTrigger, Object gestureSource) RotateEvent: public RotateEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double angle, double totalAngle) public RotateEvent(EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double angle, double totalAngle) public RotateEvent copyFor(Object newSource, EventTarget newTarget, EventType type) ScrollEvent: public ScrollEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double deltaX, double deltaY, double gestureDeltaX, double gestureDeltaY, HorizontalTextScrollUnits textDeltaXUnits, double textDeltaX, VerticalTextScrollUnits textDeltaYUnits, double textDeltaY, int touchCount) public ScrollEvent(EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double deltaX, double deltaY, double gestureDeltaX, double gestureDeltaY, HorizontalTextScrollUnits textDeltaXUnits, double textDeltaX, VerticalTextScrollUnits textDeltaYUnits, double textDeltaY, int touchCount) public ScrollEvent copyFor(Object newSource, EventTarget newTarget, EventType type) SwipeEvent: public SwipeEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, int touchCount) public SwipeEvent(EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, int touchCount) public SwipeEvent copyFor(Object newSource, EventTarget newTarget, EventType type) ZoomEvent: public ZoomEvent(Object source, EventTarget target, EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double zoomFactor, double totalZoomFactor) public ZoomEvent(EventType eventType, double x, double y, double screenX, double screenY, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct, boolean inertia, double zoomFactor, double totalZoomFactor) public ZoomEvent copyFor(Object newSource, EventTarget newTarget, EventType type) TouchEvent: public TouchEvent(Object source, EventTarget target, EventType eventType, TouchPoint touchPoint, List touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct) public TouchEvent(EventType eventType, TouchPoint touchPoint, List touchPoints, int eventSetId, boolean shiftDown, boolean controlDown, boolean altDown, boolean metaDown, boolean direct) public TouchEvent copyFor(Object newSource, EventTarget newTarget, EventType type) public boolean isDirect() // was impl because (according to a comment in code) there are no indirect events yet, but GestureEvent already has this public. javafx.stage.WindowEvent: public WindowEvent copyFor(Object newSource, EventTarget newTarget, EventType type)
-Martin On 06/15/2012 11:44 PM, Richard Bair wrote:
As for the approach, I think you do the constructors with all params (since events are immutable you have no choice really -- static factory or constructor and I prefer in this case a constructor) + builder (auto generated). And what do you think about implcopy methods? Personally I think we should remove them completely and turn them to some internal utility methods. My initial thought was a copy constructor. Also, some events are not 100% immutable, as they are modified during the Scene processing through some implmethods, like MouseEvent.implsetClickParam. We'd either need to make some/all of the Event fields protected and do this modifications through subclasses or create some "accessor" in javafx.scene.input package for calling these methods from javafx.scene package. Good question, I guess we can revisit these in context of the other impl method removal things we're working on. Richard
- Previous message: API REVIEW REQUEST: Public API for Node Orientation
- Next message: javafx.scene.input.*Event classes construction
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]