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
adaptableProperties inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound
adaptable -
Nested Class Summary
Nested ClassesNested 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidprotected doublecomputeZoomFactor(javafx.scene.input.ScrollEvent event) Computes the zoom factor from the givenScrollEvent.protected ViewportPolicyReturns theViewportPolicythat is to be used for changing the viewport.voiddrag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta) voidendDrag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta) voidprotected org.eclipse.gef.mvc.fx.viewer.IViewerprotected org.eclipse.gef.mvc.fx.handlers.CursorSupportprotected final ViewportPolicyReturns theViewportPolicythat is used for changing the viewport within the current scroll gesture.voidprotected booleanReturnstrueto signify that scrolling and zooming is restricted to the content bounds,falseotherwise.booleanChecks whether a gesture (such as zoom or pan) is currently being processed by the handler.protected booleanisZoom(javafx.scene.input.ScrollEvent event) Returnstrueif the givenScrollEventshould trigger zooming.voidscroll(javafx.scene.input.ScrollEvent event) booleanshowIndicationCursor(javafx.scene.input.KeyEvent event) booleanshowIndicationCursor(javafx.scene.input.MouseEvent event) voidstartDrag(javafx.scene.input.MouseEvent event) voidstartScroll(javafx.scene.input.ScrollEvent event) protected voidzoom(javafx.scene.input.ScrollEvent event) Performs zooming according to the givenScrollEvent.Methods inherited from class org.eclipse.gef.mvc.fx.handlers.AbstractHandler
commit, execute, getHost, init, isRegistered, isRegisteredForHost, restoreRefreshVisuals, rollback, storeAndDisableRefreshVisualsMethods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl
adaptableProperty, getAdaptable, setAdaptableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound
adaptableProperty, getAdaptable, setAdaptableMethods inherited from interface org.eclipse.gef.mvc.fx.handlers.IHandler
getHost
-
Field Details
-
currentMode
-
viewportPolicy
-
-
Constructor Details
-
ZoomPanHandler
public ZoomPanHandler()
-
-
Method Details
-
abortDrag
public void abortDrag()- Specified by:
abortDragin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
startDrag
public void startDrag(javafx.scene.input.MouseEvent event) - Specified by:
startDragin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
drag
public void drag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta) - Specified by:
dragin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
endDrag
public void endDrag(javafx.scene.input.MouseEvent e, org.eclipse.gef.geometry.planar.Dimension delta) - Specified by:
endDragin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
abortScroll
public void abortScroll()- Specified by:
abortScrollin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
-
endScroll
public void endScroll()- Specified by:
endScrollin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
-
scroll
public void scroll(javafx.scene.input.ScrollEvent event) - Specified by:
scrollin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
-
startScroll
public void startScroll(javafx.scene.input.ScrollEvent event) - Specified by:
startScrollin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnScrollHandler
-
zoom
protected void zoom(javafx.scene.input.ScrollEvent event) Performs zooming according to the givenScrollEvent.- Parameters:
event- TheScrollEventaccording to which zooming is performed.
-
hideIndicationCursor
public void hideIndicationCursor()- Specified by:
hideIndicationCursorin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
showIndicationCursor
public boolean showIndicationCursor(javafx.scene.input.KeyEvent event) - Specified by:
showIndicationCursorin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
showIndicationCursor
public boolean showIndicationCursor(javafx.scene.input.MouseEvent event) - Specified by:
showIndicationCursorin interfaceorg.eclipse.gef.mvc.fx.handlers.IOnDragHandler
-
computeZoomFactor
protected double computeZoomFactor(javafx.scene.input.ScrollEvent event) Computes the zoom factor from the givenScrollEvent.- Parameters:
event- TheScrollEventfrom which to compute the zoom factor.- Returns:
- The zoom factor according to the given
ScrollEvent.
-
getViewportPolicy
Returns theViewportPolicythat is used for changing the viewport within the current scroll gesture. This policy is set withinstartScroll(ScrollEvent)to the value determined bydetermineViewportPolicy().- Returns:
- The
ViewportPolicythat is used for changing the viewport within the current scroll gesture.
-
isContentRestricted
protected boolean isContentRestricted()Returnstrueto signify that scrolling and zooming is restricted to the content bounds,falseotherwise.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:
trueto signify that scrolling and zooming is restricted to the content bounds,falseotherwise.
-
isZoom
protected boolean isZoom(javafx.scene.input.ScrollEvent event) Returnstrueif the givenScrollEventshould trigger zooming. Otherwise returnsfalse.- Parameters:
event- TheScrollEventin question.- Returns:
trueif the givenScrollEventshould trigger zooming, otherwisefalse.
-
determineViewportPolicy
Returns theViewportPolicythat is to be used for changing the viewport. This method is called withinstartScroll(ScrollEvent)where the resulting policy is cached for the scroll gesture.- Returns:
- The
ViewportPolicythat 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:
trueif a gesture is currently active.
-