1 /*
   2  * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.input;
  27 
  28 import javafx.beans.NamedArg;
  29 import javafx.event.EventTarget;
  30 import javafx.event.EventType;
  31 
  32 /**
  33  * Scroll event indicates that user performed scrolling by mouse wheel,
  34  * track pad, touch screen or other similar device.
  35  * <p>
  36  * When the scrolling is produced by a touch gesture (such as dragging a finger
  37  * over a touch screen), it is surrounded by the {@code SCROLL_STARTED} and
  38  * {@code SCROLL_FINISHED} events. Changing number of involved touch points during
  39  * the scrolling is considered a new gesture, so the pair of
  40  * {@code SCROLL_FINISHED} and {@code SCROLL_STARTED} notifications is delivered
  41  * each time the {@code touchCount} changes. When the scrolling is caused by a mouse
  42  * wheel rotation, only a one-time {@code SCROLL} event is delivered, without
  43  * the started/finished surroundings. If scrolling inertia is active on the
  44  * given platform, some {@code SCROLL} events with {@code isInertia()} returning
  45  * {@code true} can come after {@code SCROLL_FINISHED}.
  46  * <p>
  47  * The event is delivered to the top-most
  48  * node picked on the gesture coordinates in time of the gesture start - the
  49  * whole gesture is delivered to the same node even if the coordinates change
  50  * during the gesture. For mouse wheel rotation the event is delivered to the
  51  * top-most node picked on mouse cursor location. The delivery is independent
  52  * of current focus owner.
  53  * <p>
  54  * The event provides two different types of scrolling values: pixel-based and
  55  * character/line-based. The basic {@code deltaX} and {@code deltaY} values
  56  * give reasonable results when used as number of pixels
  57  * to scroll (The {@code totalDeltaX} and {@code totalDeltaY} contain the
  58  * cumulative values for the whole gesture, zeros for mouse wheel).
  59  * For scrolling text (or other line-based content as tables) the
  60  * {@code textDelta} values should be used if they are available. The
  61  * {@code textDeltaXUnits} and {@code textDeltaYUnits} determine how to
  62  * interpret the {@code textDeltaX} and {@code textDeltaY} values. If the
  63  * units are set to {@code NONE}, the text-based values are not available
  64  * (not provided by the underlying platform) and the pixel-based values
  65  * need to be used.
  66  * <p>
  67  * As all gestures, scrolling can be direct (performed directly at
  68  * the concrete coordinates as on touch screen - the center point among all
  69  * the touches is usually used as the gesture coordinates) or indirect (performed
  70  * indirectly as on track pad or with mouse - the mouse cursor location
  71  * is usually used as the gesture coordinates).
  72  * <p>
  73  * For example, scrolling a graphical node can be achieved by following code:
  74  * <code><pre>
  75     node.setOnScroll(new EventHandler<ScrollEvent>() {
  76         @Override public void handle(ScrollEvent event) {
  77             node.setTranslateX(node.getTranslateX() + event.getDeltaX());
  78             node.setTranslateY(node.getTranslateY() + event.getDeltaY());
  79         }
  80     });
  81 </pre></code>
  82  * <p>
  83  * A scroll event handler on text-based component behaving
  84  * according to system settings on all platforms should contain following logic:
  85  * <code><pre>
  86     switch(event.getTextDeltaYUnits()) {
  87         case LINES:
  88             // scroll about event.getTextDeltaY() lines
  89             break;
  90         case PAGES:
  91             // scroll about event.getTextDeltaY() pages
  92             break;
  93         case NONE:
  94             // scroll about event.getDeltaY() pixels
  95             break;
  96     }
  97  </pre></code>
  98  *
  99  * @since JavaFX 2.0
 100  */
 101 public final class ScrollEvent extends GestureEvent {
 102 
 103     private static final long serialVersionUID = 20121107L;
 104 
 105     /**
 106      * Common supertype for all scroll event types.
 107      */
 108     public static final EventType<ScrollEvent> ANY =
 109             new EventType<ScrollEvent> (GestureEvent.ANY, "ANY_SCROLL");
 110 
 111     /**
 112      * This event occurs when user performs a scrolling action such as
 113      * rotating mouse wheel or dragging a finger over touch screen.
 114      */
 115     public static final EventType<ScrollEvent> SCROLL =
 116             new EventType<ScrollEvent> (ScrollEvent.ANY, "SCROLL");
 117 
 118     /**
 119      * This event occurs when a scrolling gesture is detected. It doesn't
 120      * occur for mouse wheel scrolling.
 121      * @since JavaFX 2.2
 122      */
 123     public static final EventType<ScrollEvent> SCROLL_STARTED =
 124             new EventType<ScrollEvent> (ScrollEvent.ANY, "SCROLL_STARTED");
 125 
 126     /**
 127      * This event occurs when a scrolling gesture ends. It doesn't
 128      * occur for mouse wheel scrolling.
 129      * @since JavaFX 2.2
 130      */
 131     public static final EventType<ScrollEvent> SCROLL_FINISHED =
 132             new EventType<ScrollEvent> (ScrollEvent.ANY, "SCROLL_FINISHED");
 133 
 134 
 135     private ScrollEvent(Object source, EventTarget target,
 136                        final EventType<ScrollEvent> eventType,
 137                        double x, double y,
 138                        double screenX, double screenY,
 139                        boolean shiftDown,
 140                        boolean controlDown,
 141                        boolean altDown,
 142                        boolean metaDown,
 143                        boolean direct,
 144                        boolean inertia,
 145                        double deltaX, double deltaY,
 146                        double totalDeltaX, double totalDeltaY,
 147                        double multiplierX, double multiplierY,
 148                        HorizontalTextScrollUnits textDeltaXUnits, double textDeltaX,
 149                        VerticalTextScrollUnits textDeltaYUnits, double textDeltaY,
 150                        int touchCount, PickResult pickResult) {
 151 
 152         super(source, target, eventType, x, y, screenX, screenY,
 153                 shiftDown, controlDown, altDown, metaDown, direct, inertia,
 154                 pickResult);
 155         this.deltaX = deltaX;
 156         this.deltaY = deltaY;
 157         this.totalDeltaX = totalDeltaX;
 158         this.totalDeltaY = totalDeltaY;
 159         this.textDeltaXUnits = textDeltaXUnits;
 160         this.textDeltaX = textDeltaX;
 161         this.textDeltaYUnits = textDeltaYUnits;
 162         this.textDeltaY = textDeltaY;
 163         this.touchCount = touchCount;
 164         this.multiplierX = multiplierX;
 165         this.multiplierY = multiplierY;
 166     }
 167 
 168     /**
 169      * Constructs new ScrollEvent event.
 170      * @param source the source of the event. Can be null.
 171      * @param target the target of the event. Can be null.
 172      * @param eventType The type of the event.
 173      * @param x The x with respect to the scene.
 174      * @param y The y with respect to the scene.
 175      * @param screenX The x coordinate relative to screen.
 176      * @param screenY The y coordinate relative to screen.
 177      * @param shiftDown true if shift modifier was pressed.
 178      * @param controlDown true if control modifier was pressed.
 179      * @param altDown true if alt modifier was pressed.
 180      * @param metaDown true if meta modifier was pressed.
 181      * @param direct true if the event was caused by direct input device. See {@link #isDirect() }
 182      * @param inertia if represents inertia of an already finished gesture.
 183      * @param deltaX horizontal scroll amount
 184      * @param deltaY vertical scroll amount
 185      * @param totalDeltaX cumulative horizontal scroll amount
 186      * @param totalDeltaY cumulative vertical scroll amount
 187      * @param textDeltaXUnits units for horizontal text-based scroll amount
 188      * @param textDeltaX horizontal text-based scroll amount
 189      * @param textDeltaYUnits units for vertical text-based scroll amount
 190      * @param textDeltaY vertical text-based scroll amount
 191      * @param touchCount number of touch points
 192      * @param pickResult pick result. Can be null, in this case a 2D pick result
 193      *                   without any further values is constructed
 194      *                   based on the scene coordinates and the target
 195      * @since JavaFX 8.0
 196      */
 197     public ScrollEvent(@NamedArg("source") Object source, @NamedArg("target") EventTarget target,
 198                        final @NamedArg("eventType") EventType<ScrollEvent> eventType,
 199                        @NamedArg("x") double x, @NamedArg("y") double y,
 200                        @NamedArg("screenX") double screenX, @NamedArg("screenY") double screenY,
 201                        @NamedArg("shiftDown") boolean shiftDown,
 202                        @NamedArg("controlDown") boolean controlDown,
 203                        @NamedArg("altDown") boolean altDown,
 204                        @NamedArg("metaDown") boolean metaDown,
 205                        @NamedArg("direct") boolean direct,
 206                        @NamedArg("inertia") boolean inertia,
 207                        @NamedArg("deltaX") double deltaX, @NamedArg("deltaY") double deltaY,
 208                        @NamedArg("totalDeltaX") double totalDeltaX, @NamedArg("totalDeltaY") double totalDeltaY,
 209                        @NamedArg("textDeltaXUnits") HorizontalTextScrollUnits textDeltaXUnits, @NamedArg("textDeltaX") double textDeltaX,
 210                        @NamedArg("textDeltaYUnits") VerticalTextScrollUnits textDeltaYUnits, @NamedArg("textDeltaY") double textDeltaY,
 211                        @NamedArg("touchCount") int touchCount, @NamedArg("pickResult") PickResult pickResult) {
 212         this(source, target, eventType, x, y, screenX, screenY, shiftDown, controlDown,
 213                 altDown, metaDown, direct, inertia, deltaX, deltaY, totalDeltaX,
 214                 totalDeltaY, 1.0, 1.0, textDeltaXUnits, textDeltaX, textDeltaYUnits, textDeltaY,
 215                 touchCount, pickResult);
 216     }
 217 
 218     /**
 219      * Constructs new ScrollEvent event with null source and target
 220      * @param eventType The type of the event.
 221      * @param x The x with respect to the scene.
 222      * @param y The y with respect to the scene.
 223      * @param screenX The x coordinate relative to screen.
 224      * @param screenY The y coordinate relative to screen.
 225      * @param shiftDown true if shift modifier was pressed.
 226      * @param controlDown true if control modifier was pressed.
 227      * @param altDown true if alt modifier was pressed.
 228      * @param metaDown true if meta modifier was pressed.
 229      * @param direct true if the event was caused by direct input device. See {@link #isDirect() }
 230      * @param inertia if represents inertia of an already finished gesture.
 231      * @param deltaX horizontal scroll amount
 232      * @param deltaY vertical scroll amount
 233      * @param totalDeltaX cumulative horizontal scroll amount
 234      * @param totalDeltaY cumulative vertical scroll amount
 235      * @param textDeltaXUnits units for horizontal text-based scroll amount
 236      * @param textDeltaX horizontal text-based scroll amount
 237      * @param textDeltaYUnits units for vertical text-based scroll amount
 238      * @param textDeltaY vertical text-based scroll amount
 239      * @param touchCount number of touch points
 240      * @param pickResult pick result. Can be null, in this case a 2D pick result
 241      *                   without any further values is constructed
 242      *                   based on the scene coordinates
 243      * @since JavaFX 8.0
 244      */
 245     public ScrollEvent(final @NamedArg("eventType") EventType<ScrollEvent> eventType,
 246             @NamedArg("x") double x, @NamedArg("y") double y,
 247             @NamedArg("screenX") double screenX, @NamedArg("screenY") double screenY,
 248             @NamedArg("shiftDown") boolean shiftDown,
 249             @NamedArg("controlDown") boolean controlDown,
 250             @NamedArg("altDown") boolean altDown,
 251             @NamedArg("metaDown") boolean metaDown,
 252             @NamedArg("direct") boolean direct,
 253             @NamedArg("inertia") boolean inertia,
 254             @NamedArg("deltaX") double deltaX, @NamedArg("deltaY") double deltaY,
 255             @NamedArg("totalDeltaX") double totalDeltaX, @NamedArg("totalDeltaY") double totalDeltaY,
 256             @NamedArg("textDeltaXUnits") HorizontalTextScrollUnits textDeltaXUnits, @NamedArg("textDeltaX") double textDeltaX,
 257             @NamedArg("textDeltaYUnits") VerticalTextScrollUnits textDeltaYUnits, @NamedArg("textDeltaY") double textDeltaY,
 258             @NamedArg("touchCount") int touchCount,
 259             @NamedArg("pickResult") PickResult pickResult) {
 260         this(null, null, eventType, x, y, screenX, screenY, shiftDown, controlDown,
 261                 altDown, metaDown, direct, inertia, deltaX, deltaY, totalDeltaX,
 262                 totalDeltaY, 1.0, 1.0, textDeltaXUnits, textDeltaX, textDeltaYUnits, textDeltaY,
 263                 touchCount, pickResult);
 264     }
 265 
 266     /**
 267      * Constructs new ScrollEvent event with null source and target
 268      * @param eventType The type of the event.
 269      * @param x The x with respect to the scene.
 270      * @param y The y with respect to the scene.
 271      * @param screenX The x coordinate relative to screen.
 272      * @param screenY The y coordinate relative to screen.
 273      * @param shiftDown true if shift modifier was pressed.
 274      * @param controlDown true if control modifier was pressed.
 275      * @param altDown true if alt modifier was pressed.
 276      * @param metaDown true if meta modifier was pressed.
 277      * @param direct true if the event was caused by direct input device. See {@link #isDirect() }
 278      * @param inertia if represents inertia of an already finished gesture.
 279      * @param deltaX horizontal scroll amount
 280      * @param deltaY vertical scroll amount
 281      * @param totalDeltaX cumulative horizontal scroll amount
 282      * @param totalDeltaY cumulative vertical scroll amount
 283      * @param multiplierX an X multiplier used to convert wheel rotations to pixels
 284      * @param multiplierY an Y multiplier used to convert wheel rotations to pixels
 285      * @param textDeltaXUnits units for horizontal text-based scroll amount
 286      * @param textDeltaX horizontal text-based scroll amount
 287      * @param textDeltaYUnits units for vertical text-based scroll amount
 288      * @param textDeltaY vertical text-based scroll amount
 289      * @param touchCount number of touch points
 290      * @param pickResult pick result. Can be null, in this case a 2D pick result
 291      *                   without any further values is constructed
 292      *                   based on the scene coordinates
 293      * @since JavaFX 8.0
 294      */
 295     public ScrollEvent(final @NamedArg("eventType") EventType<ScrollEvent> eventType,
 296                        @NamedArg("x") double x, @NamedArg("y") double y,
 297                        @NamedArg("screenX") double screenX, @NamedArg("screenY") double screenY,
 298                        @NamedArg("shiftDown") boolean shiftDown,
 299                        @NamedArg("controlDown") boolean controlDown,
 300                        @NamedArg("altDown") boolean altDown,
 301                        @NamedArg("metaDown") boolean metaDown,
 302                        @NamedArg("direct") boolean direct,
 303                        @NamedArg("inertia") boolean inertia,
 304                        @NamedArg("deltaX") double deltaX, @NamedArg("deltaY") double deltaY,
 305                        @NamedArg("totalDeltaX") double totalDeltaX, @NamedArg("totalDeltaY") double totalDeltaY,
 306                        @NamedArg("multiplierX") double multiplierX, @NamedArg("multiplierY") double multiplierY,
 307                        @NamedArg("textDeltaXUnits") HorizontalTextScrollUnits textDeltaXUnits, @NamedArg("textDeltaX") double textDeltaX,
 308                        @NamedArg("textDeltaYUnits") VerticalTextScrollUnits textDeltaYUnits, @NamedArg("textDeltaY") double textDeltaY,
 309                        @NamedArg("touchCount") int touchCount,
 310                        @NamedArg("pickResult") PickResult pickResult) {
 311         this(null, null, eventType, x, y, screenX, screenY, shiftDown, controlDown,
 312                 altDown, metaDown, direct, inertia, deltaX, deltaY, totalDeltaX,
 313                 totalDeltaY, multiplierX, multiplierY, textDeltaXUnits, textDeltaX,
 314                 textDeltaYUnits, textDeltaY, touchCount, pickResult);
 315     }
 316 
 317     private final double deltaX;
 318 
 319     /**
 320      * Gets the horizontal scroll amount. This value should be interpreted
 321      * as a number of pixels to scroll. When scrolling a text-based content,
 322      * the {@code textDeltaX} and {@code textDeltaXUnits} values should be
 323      * considered first.
 324      * <p>
 325      * The sign of the value is reversed compared to the coordinate system
 326      * (when you scroll right, the content actually needs to go left). So the
 327      * returned value can be simply added to the content's {@code X}
 328      * coordinate.
 329      *
 330      * @return Number of pixels to scroll horizontally.
 331      */
 332     public double getDeltaX() {
 333         return deltaX;
 334     }
 335 
 336     private final double deltaY;
 337 
 338     /**
 339      * Gets the vertical scroll amount. This value should be interpreted
 340      * as a number of pixels to scroll. When scrolling a line-based content,
 341      * the {@code textDeltaY} and {@code textDeltaYUnits} values should be
 342      * considered first.
 343      * <p>
 344      * The sign of the value is reversed compared to the coordinate system
 345      * (when you scroll down, the content actually needs to go up). So the
 346      * returned value can be simply added to the content's {@code Y}
 347      * coordinate.
 348      *
 349      * @return Number of pixels to scroll vertically.
 350      */
 351     public double getDeltaY() {
 352         return deltaY;
 353     }
 354 
 355     private double totalDeltaX;
 356 
 357     /**
 358      * Gets the cumulative horizontal scroll amount for the whole gesture.
 359      * This value should be interpreted as a number of pixels to scroll
 360      * relatively to the state at the beginning of the gesture.
 361      * Contains zeros for mouse wheel scrolling.
 362      * <p>
 363      * The sign of the value is reversed compared to the coordinate system
 364      * (when you scroll right, the content actually needs to go left). So the
 365      * returned value can be simply added to the content's {@code X}
 366      * coordinate.
 367      *
 368      * @return Number of pixels scrolled horizontally during the gesture
 369      * @since JavaFX 2.2
 370      */
 371     public double getTotalDeltaX() {
 372         return totalDeltaX;
 373     }
 374 
 375     private final double totalDeltaY;
 376 
 377     /**
 378      * Gets the cumulative vertical scroll amount for the whole gesture.
 379      * This value should be interpreted as a number of pixels to scroll
 380      * relatively to the state at the beginning of the gesture.
 381      * Contains zeros for mouse wheel scrolling.
 382      * <p>
 383      * The sign of the value is reversed compared to the coordinate system
 384      * (when you scroll down, the content actually needs to go up). So the
 385      * returned value can be simply added to the content's {@code Y}
 386      * coordinate.
 387      *
 388      * @return Number of pixels to scrolled vertically during the gesture
 389      * @since JavaFX 2.2
 390      */
 391     public double getTotalDeltaY() {
 392         return totalDeltaY;
 393     }
 394 
 395     private final HorizontalTextScrollUnits textDeltaXUnits;
 396 
 397     /**
 398      * Gets the horizontal scrolling units for text-based scrolling.
 399      * The returned value indicates how to interpret the {@code getTextDeltaX()}
 400      * value. If the returned value is {@code NONE}, the text-based
 401      * scrolling value is not available and the pixel-based
 402      * {@code getDeltaX()} value needs to be used.
 403      *
 404      * @return the horizontal scrolling units for text-based scrolling
 405      */
 406     public HorizontalTextScrollUnits getTextDeltaXUnits() {
 407         return textDeltaXUnits;
 408     }
 409 
 410     private final VerticalTextScrollUnits textDeltaYUnits;
 411 
 412     /**
 413      * Gets the vertical scrolling units for text-based scrolling.
 414      * The returned value indicates how to interpret the {@code getTextDeltaY()}
 415      * value. If the returned value is {@code NONE}, the text-based
 416      * scrolling value is not available and the pixel-based
 417      * {@code getDeltaY()} value needs to be used.
 418      *
 419      * @return the vertical scrolling units for text-based scrolling
 420      */
 421     public VerticalTextScrollUnits getTextDeltaYUnits() {
 422         return textDeltaYUnits;
 423     }
 424 
 425     private final double textDeltaX;
 426 
 427     /**
 428      * Gets the horizontal text-based scroll amount. This value should be
 429      * interpreted according to the {@code getTextDeltaXUnits()} value.
 430      *
 431      * @return Number of units to scroll horizontally, zero if the text-based
 432      * horizontal scrolling data is not available {@code getTextDeltaXUnits()}
 433      * returns {@code NONE}
 434      */
 435     public double getTextDeltaX() {
 436         return textDeltaX;
 437     }
 438 
 439     private final double textDeltaY;
 440 
 441     /**
 442      * Gets the vertical text-based scroll amount. This value should be
 443      * interpreted according to the {@code getTextDeltaYUnits()} value.
 444      *
 445      * @return Number of units to scroll vertically, zero if the text-based
 446      * vertical scrolling data is not available {@code getTextDeltaYUnits()}
 447      * returns {@code NONE}
 448      */
 449     public double getTextDeltaY() {
 450         return textDeltaY;
 451     }
 452 
 453     private final int touchCount;
 454 
 455     /**
 456      * Gets number of touch points that caused this event. For non-touch source
 457      * devices as mouse wheel and for inertia events after gesture finish
 458      * it returns zero.
 459      * @return Number of touch points that caused this event
 460      * @since JavaFX 2.2
 461      */
 462     public int getTouchCount() {
 463         return touchCount;
 464     }
 465 
 466     private final double multiplierX;
 467 
 468     /**
 469      * Gets the multiplier used to convert mouse wheel rotation units to pixels
 470      * @return the x multiplier
 471      * @since JavaFX 8.0
 472      */
 473     public double getMultiplierX() {
 474         return multiplierX;
 475     }
 476 
 477     private final double multiplierY;
 478 
 479     /**
 480      * Gets the multiplier used to convert mouse wheel rotation units to pixels
 481      * @return the y multiplier
 482      * @since JavaFX 8.0
 483      */
 484     public double getMultiplierY() {
 485         return multiplierY;
 486     }
 487 
 488     /**
 489      * Returns a string representation of this {@code ScrollEvent} object.
 490      * @return a string representation of this {@code ScrollEvent} object.
 491      */
 492     @Override public String toString() {
 493         final StringBuilder sb = new StringBuilder("ScrollEvent [");
 494 
 495         sb.append("source = ").append(getSource());
 496         sb.append(", target = ").append(getTarget());
 497         sb.append(", eventType = ").append(getEventType());
 498         sb.append(", consumed = ").append(isConsumed());
 499 
 500         sb.append(", deltaX = ").append(getDeltaX())
 501                 .append(", deltaY = ").append(getDeltaY());
 502         sb.append(", totalDeltaX = ").append(getTotalDeltaX())
 503                 .append(", totalDeltaY = ").append(getTotalDeltaY());
 504         sb.append(", textDeltaXUnits = ").append(getTextDeltaXUnits())
 505                 .append(", textDeltaX = ").append(getTextDeltaX());
 506         sb.append(", textDeltaYUnits = ").append(getTextDeltaYUnits())
 507                 .append(", textDeltaY = ").append(getTextDeltaY());
 508         sb.append(", touchCount = ").append(getTouchCount());
 509         sb.append(", x = ").append(getX()).append(", y = ").append(getY())
 510                 .append(", z = ").append(getZ());
 511         sb.append(isDirect() ? ", direct" : ", indirect");
 512 
 513         if (isInertia()) {
 514             sb.append(", inertia");
 515         }
 516 
 517         if (isShiftDown()) {
 518             sb.append(", shiftDown");
 519         }
 520         if (isControlDown()) {
 521             sb.append(", controlDown");
 522         }
 523         if (isAltDown()) {
 524             sb.append(", altDown");
 525         }
 526         if (isMetaDown()) {
 527             sb.append(", metaDown");
 528         }
 529         if (isShortcutDown()) {
 530             sb.append(", shortcutDown");
 531         }
 532         sb.append(", pickResult = ").append(getPickResult());
 533 
 534         return sb.append("]").toString();
 535     }
 536 
 537     @Override
 538     public ScrollEvent copyFor(Object newSource, EventTarget newTarget) {
 539         return (ScrollEvent) super.copyFor(newSource, newTarget);
 540     }
 541 
 542     /**
 543      * Creates a copy of the given event with the given fields substituted.
 544      * @param newSource the new source of the copied event
 545      * @param newTarget the new target of the copied event
 546      * @param type the new eventType
 547      * @return the event copy with the fields substituted
 548      * @since JavaFX 8.0
 549      */
 550     public ScrollEvent copyFor(Object newSource, EventTarget newTarget, EventType<ScrollEvent> type) {
 551         ScrollEvent e = copyFor(newSource, newTarget);
 552         e.eventType = type;
 553         return e;
 554     }
 555 
 556     @Override
 557     public EventType<ScrollEvent> getEventType() {
 558         return (EventType<ScrollEvent>) super.getEventType();
 559     }
 560 
 561     /**
 562      * Horizontal text-based scrolling units.
 563      * @since JavaFX 2.0
 564      */
 565     public static enum HorizontalTextScrollUnits {
 566         /**
 567          * The horizontal text-based scrolling data is not available (not
 568          * provided by the underlying platform).
 569          */
 570         NONE,
 571 
 572         /**
 573          * The horizontal text-based scrolling amount is a number of characters
 574          * to scroll.
 575          */
 576         CHARACTERS
 577     }
 578 
 579     /**
 580      * Vertical text-based scrolling units.
 581      * @since JavaFX 2.0
 582      */
 583     public static enum VerticalTextScrollUnits {
 584         /**
 585          * The vertical text-based scrolling data is not available (not
 586          * provided by the underlying platform).
 587          */
 588         NONE,
 589 
 590         /**
 591          * The vertical text-based scrolling amount is a number of lines
 592          * to scroll.
 593          */
 594         LINES,
 595 
 596         /**
 597          * The vertical text-based scrolling amount is a number of pages
 598          * to scroll.
 599          */
 600         PAGES
 601     }
 602 }