Class ZoomPanHandler

java.lang.Object
org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<org.eclipse.gef.mvc.fx.parts.IVisualPart<? extends javafx.scene.Node>>
org.eclipse.gef.mvc.fx.handlers.AbstractHandler
com.amalgamasimulation.graphicaleditor.handlers.ZoomPanHandler
All Implemented Interfaces:
org.eclipse.gef.common.adapt.IAdaptable.Bound<org.eclipse.gef.mvc.fx.parts.IVisualPart<? extends javafx.scene.Node>>, org.eclipse.gef.mvc.fx.handlers.IHandler, org.eclipse.gef.mvc.fx.handlers.IOnDragHandler, org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler

public class ZoomPanHandler extends org.eclipse.gef.mvc.fx.handlers.AbstractHandler implements org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler, org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
  • Property Summary

    Properties inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

    adaptable

    Properties inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    adaptable
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<T extends org.eclipse.gef.common.adapt.IAdaptable>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    protected ViewportPolicy
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    protected double
    computeZoomFactor(javafx.scene.input.ScrollEvent event)
    Computes the zoom factor from the given ScrollEvent.
    protected ViewportPolicy
    Returns the ViewportPolicy that is to be used for changing the viewport.
    void
    drag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta)
     
    void
    endDrag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta)
     
    void
     
    protected org.eclipse.gef.mvc.fx.viewer.IViewer
     
    protected org.eclipse.gef.mvc.fx.handlers.CursorSupport
     
    protected final ViewportPolicy
    Returns the ViewportPolicy that is used for changing the viewport within the current scroll gesture.
    void
     
    protected boolean
    Returns true to signify that scrolling and zooming is restricted to the content bounds, false otherwise.
    boolean
    Checks whether a gesture (such as zoom or pan) is currently being processed by the handler.
    protected boolean
    isZoom(javafx.scene.input.ScrollEvent event)
    Returns true if the given ScrollEvent should trigger zooming.
    void
    scroll(javafx.scene.input.ScrollEvent event)
     
    boolean
    showIndicationCursor(javafx.scene.input.KeyEvent event)
     
    boolean
    showIndicationCursor(javafx.scene.input.MouseEvent event)
     
    void
    startDrag(javafx.scene.input.MouseEvent event)
     
    void
    startScroll(javafx.scene.input.ScrollEvent event)
     
    protected void
    zoom(javafx.scene.input.ScrollEvent event)
    Performs zooming according to the given ScrollEvent.

    Methods inherited from class org.eclipse.gef.mvc.fx.handlers.AbstractHandler

    commit, execute, getHost, init, isRegistered, isRegisteredForHost, restoreRefreshVisuals, rollback, storeAndDisableRefreshVisuals

    Methods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

    adaptableProperty, getAdaptable, setAdaptable

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

    adaptableProperty, getAdaptable, setAdaptable

    Methods inherited from interface org.eclipse.gef.mvc.fx.handlers.IHandler

    getHost
  • Field Details

  • Constructor Details

    • ZoomPanHandler

      public ZoomPanHandler()
  • Method Details

    • abortDrag

      public void abortDrag()
      Specified by:
      abortDrag in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • startDrag

      public void startDrag(javafx.scene.input.MouseEvent event)
      Specified by:
      startDrag in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • drag

      public void drag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta)
      Specified by:
      drag in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • endDrag

      public void endDrag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta)
      Specified by:
      endDrag in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • abortScroll

      public void abortScroll()
      Specified by:
      abortScroll in interface org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
    • endScroll

      public void endScroll()
      Specified by:
      endScroll in interface org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
    • scroll

      public void scroll(javafx.scene.input.ScrollEvent event)
      Specified by:
      scroll in interface org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
    • startScroll

      public void startScroll(javafx.scene.input.ScrollEvent event)
      Specified by:
      startScroll in interface org.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
    • zoom

      protected void zoom(javafx.scene.input.ScrollEvent event)
      Performs zooming according to the given ScrollEvent.
      Parameters:
      event - The ScrollEvent according to which zooming is performed.
    • hideIndicationCursor

      public void hideIndicationCursor()
      Specified by:
      hideIndicationCursor in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • showIndicationCursor

      public boolean showIndicationCursor(javafx.scene.input.KeyEvent event)
      Specified by:
      showIndicationCursor in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • showIndicationCursor

      public boolean showIndicationCursor(javafx.scene.input.MouseEvent event)
      Specified by:
      showIndicationCursor in interface org.eclipse.gef.mvc.fx.handlers.IOnDragHandler
    • computeZoomFactor

      protected double computeZoomFactor(javafx.scene.input.ScrollEvent event)
      Computes the zoom factor from the given ScrollEvent.
      Parameters:
      event - The ScrollEvent from which to compute the zoom factor.
      Returns:
      The zoom factor according to the given ScrollEvent.
    • getViewportPolicy

      protected final ViewportPolicy getViewportPolicy()
      Returns the ViewportPolicy that is used for changing the viewport within the current scroll gesture. This policy is set within startScroll(ScrollEvent) to the value determined by determineViewportPolicy().
      Returns:
      The ViewportPolicy that is used for changing the viewport within the current scroll gesture.
    • isContentRestricted

      protected boolean isContentRestricted()
      Returns true to signify that scrolling and zooming is restricted to the content bounds, false otherwise.

      When content-restricted, the policy behaves texteditor-like, i.e. the pivot point for zooming is at the top of the viewport and at the left of the contents, and free space is only allowed to the right and to the bottom of the contents. Therefore, the policy does not allow panning or zooming if it would result in free space within the viewport at the top or left sides of the contents.

      Returns:
      true to signify that scrolling and zooming is restricted to the content bounds, false otherwise.
    • isZoom

      protected boolean isZoom(javafx.scene.input.ScrollEvent event)
      Returns true if the given ScrollEvent should trigger zooming. Otherwise returns false.
      Parameters:
      event - The ScrollEvent in question.
      Returns:
      true if the given ScrollEvent should trigger zooming, otherwise false.
    • determineViewportPolicy

      protected ViewportPolicy determineViewportPolicy()
      Returns the ViewportPolicy that is to be used for changing the viewport. This method is called within startScroll(ScrollEvent) where the resulting policy is cached for the scroll gesture.
      Returns:
      The ViewportPolicy that is to be used for changing the viewport.
    • getContentViewer

      protected org.eclipse.gef.mvc.fx.viewer.IViewer getContentViewer()
    • getCursorSupport

      protected org.eclipse.gef.mvc.fx.handlers.CursorSupport getCursorSupport()
    • isScrollActive

      public boolean isScrollActive()
      Checks whether a gesture (such as zoom or pan) is currently being processed by the handler. This method is primarily used to prevent conflicts when external operations (e.g., programmatic zoom) attempt to modify the viewport while a gesture is in progress.
      Returns:
      true if a gesture is currently active.