@ SuppressWarnings ( { "checkstyle:cyclomaticcomplexity" , "checkstyle:npathcomplexity" , "checkstyle:nestedifdepth" } ) protected void setupMousing ( ) { final ZoomableCanvas < T > canvas = getDocumentCanvas ( ) ; canvas . addEventHandler ( MouseEvent . MOUSE_PRESSED , e -> { this . pressX = e . getX ( ) ; this . pressY = e . getY ( ) ; this . hbarValue = this . hbar . getValue ( ) ; this . vbarValue = this . vbar . getValue ( ) ; } ) ; setOnDragDetected ( getDefaultOnDragDetectedEventHandler ( ) ) ; addEventFilter ( MouseEvent . MOUSE_RELEASED , e -> { if ( this . dragDetected ) { this . dragDetected = false ; final Cursor scurs = this . savedCursor ; this . savedCursor = null ; if ( scurs != null ) { getDocumentCanvas ( ) . setCursor ( scurs ) ; requestLayout ( ) ; } } } ) ; addEventHandler ( DragEvent . DRAG_DONE , event -> { if ( this . dragDetected ) { this . dragDetected = false ; final Cursor scurs = this . savedCursor ; this . savedCursor = null ; if ( scurs != null ) { getDocumentCanvas ( ) . setCursor ( scurs ) ; requestLayout ( ) ; } } } ) ; addEventHandler ( MouseEvent . MOUSE_DRAGGED , getDefaultOnMouseDraggedEventHandler ( ) ) ; addEventHandler ( ScrollEvent . SCROLL_STARTED , event -> { this . scrollDetected = true ; } ) ; addEventHandler ( ScrollEvent . SCROLL_FINISHED , event -> { this . scrollDetected = false ; } ) ; addEventHandler ( ScrollEvent . SCROLL , event -> { if ( ! this . scrollDetected ) { event . consume ( ) ; final double delta ; if ( event . getDeltaY ( ) != 0. ) { delta = event . getDeltaY ( ) ; } else { delta = event . getDeltaX ( ) ; } if ( delta < 0 ) { zoomOut ( ) ; } else { zoomIn ( ) ; } } } ) ; }
Setup the response of the pane to mouse events .