- java.lang.Object
-
- java.util.EventObject
-
- javafx.event.Event
-
- javafx.scene.input.InputEvent
-
- javafx.scene.input.GestureEvent
-
- javafx.scene.input.ZoomEvent
-
- All Implemented Interfaces:
Serializable,Cloneable
public final class ZoomEvent extends GestureEvent
Zoom event indicates that user performed zooming gesture such as dragging two fingers apart on track pad, touch screen or other similar device.The event is delivered to the top-most node picked on the gesture coordinates in time of the gesture start - the whole gesture is delivered to the same node even if the coordinates change during the gesture.
The event provides two values:
zoomFactoris the zooming amount of this event,totalZoomFactoris the zooming amount of the whole gesture. The values work well when multiplied with the node'sscaleproperties (values greater than1for zooming in).As all gestures, zooming can be direct (performed directly at the concrete coordinates as on touch screen - the center point among all the touches is usually used as the gesture coordinates) or indirect (performed indirectly as on track pad - the mouse cursor location is usually used as the gesture coordinates).
The gesture's
ZOOMevents are surounded byZOOM_STARTEDandZOOM_FINISHEDevents. If zooming inertia is active on the given platform, someZOOMevents withisInertia()returningtruecan come afterZOOM_FINISHED.- Since:
- JavaFX 2.2
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static EventType<ZoomEvent>ANYCommon supertype for all zoom event types.static EventType<ZoomEvent>ZOOMThis event occurs when user performs a zooming gesture such as dragging two fingers apart.static EventType<ZoomEvent>ZOOM_FINISHEDThis event occurs when a zooming gesture ends.static EventType<ZoomEvent>ZOOM_STARTEDThis event occurs when a zooming gesture is detected.-
Fields inherited from class javafx.event.Event
consumed, eventType, NULL_SOURCE_TARGET, target
-
Fields inherited from class java.util.EventObject
source
-
-
Constructor Summary
Constructors Constructor Description ZoomEvent(Object source, EventTarget target, EventType<ZoomEvent> 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, PickResult pickResult)Constructs new ZoomEvent event.ZoomEvent(EventType<ZoomEvent> 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, PickResult pickResult)Constructs new ZoomEvent event with null source and target.
-
Method Summary
Modifier and Type Method Description ZoomEventcopyFor(Object newSource, EventTarget newTarget)Creates and returns a copy of this event with the specified event source and target.ZoomEventcopyFor(Object newSource, EventTarget newTarget, EventType<ZoomEvent> type)Creates a copy of the given event with the given fields substituted.EventType<ZoomEvent>getEventType()Gets the event type of this event.doublegetTotalZoomFactor()Gets the zooming amount of this gesture.doublegetZoomFactor()Gets the zooming amount of this event.StringtoString()Returns a string representation of thisZoomEventobject.-
Methods inherited from class javafx.scene.input.GestureEvent
getPickResult, getSceneX, getSceneY, getScreenX, getScreenY, getX, getY, getZ, isAltDown, isControlDown, isDirect, isInertia, isMetaDown, isShiftDown, isShortcutDown
-
Methods inherited from class java.util.EventObject
getSource
-
-
-
-
Constructor Detail
-
ZoomEvent
public ZoomEvent(Object source, EventTarget target, EventType<ZoomEvent> 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, PickResult pickResult)
Constructs new ZoomEvent event.- Parameters:
source- the source of the event. Can be null.target- the target of the event. Can be null.eventType- The type of the event.x- The x with respect to the scene.y- The y with respect to the scene.screenX- The x coordinate relative to screen.screenY- The y coordinate relative to screen.shiftDown- true if shift modifier was pressed.controlDown- true if control modifier was pressed.altDown- true if alt modifier was pressed.metaDown- true if meta modifier was pressed.direct- true if the event was caused by direct input device. SeeGestureEvent.isDirect()inertia- if represents inertia of an already finished gesture.zoomFactor- zoom amounttotalZoomFactor- cumulative zoom amountpickResult- pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates and the target- Since:
- JavaFX 8.0
-
ZoomEvent
public ZoomEvent(EventType<ZoomEvent> 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, PickResult pickResult)
Constructs new ZoomEvent event with null source and target.- Parameters:
eventType- The type of the event.x- The x with respect to the scene.y- The y with respect to the scene.screenX- The x coordinate relative to screen.screenY- The y coordinate relative to screen.shiftDown- true if shift modifier was pressed.controlDown- true if control modifier was pressed.altDown- true if alt modifier was pressed.metaDown- true if meta modifier was pressed.direct- true if the event was caused by direct input device. SeeGestureEvent.isDirect()inertia- if represents inertia of an already finished gesture.zoomFactor- zoom amounttotalZoomFactor- cumulative zoom amountpickResult- pick result. Can be null, in this case a 2D pick result without any further values is constructed based on the scene coordinates- Since:
- JavaFX 8.0
-
-
Method Detail
-
getZoomFactor
public double getZoomFactor()
Gets the zooming amount of this event. The factor value works well when multiplied with the node'sscaleproperties (values greater than1for zooming in, values between0and1for zooming out).- Returns:
- The zooming amount of this event
-
getTotalZoomFactor
public double getTotalZoomFactor()
Gets the zooming amount of this gesture. The factor value works well when multiplied with the node'sscaleproperties (values greater than1for zooming in, values between0and1for zooming out).- Returns:
- The cumulative zooming amount of this gesture
-
toString
public String toString()
Returns a string representation of thisZoomEventobject.- Overrides:
toStringin classGestureEvent- Returns:
- a string representation of this
ZoomEventobject.
-
copyFor
public ZoomEvent copyFor(Object newSource, EventTarget newTarget)
Description copied from class:GestureEventCreates and returns a copy of this event with the specified event source and target. If the source or target is set tonull, it is replaced by theNULL_SOURCE_TARGETvalue.- Overrides:
copyForin classGestureEvent- Parameters:
newSource- the new source of the copied eventnewTarget- the new target of the copied event- Returns:
- the event copy with the new source and target
-
copyFor
public ZoomEvent copyFor(Object newSource, EventTarget newTarget, EventType<ZoomEvent> type)
Creates a copy of the given event with the given fields substituted.- Parameters:
newSource- the new source of the copied eventnewTarget- the new target of the copied eventtype- the new eventType- Returns:
- the event copy with the fields substituted
- Since:
- JavaFX 8.0
-
getEventType
public EventType<ZoomEvent> getEventType()
Description copied from class:EventGets the event type of this event. Objects of the sameEventclass can have different event types. These event types further specify what kind of event occurred.- Overrides:
getEventTypein classGestureEvent- Returns:
- the event type
-
-