Package org.eclipse.gef.mvc.fx.policies
Class ViewportPolicy
- java.lang.Object
-
- org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<IVisualPart<? extends javafx.scene.Node>>
-
- org.eclipse.gef.mvc.fx.policies.AbstractPolicy
-
- org.eclipse.gef.mvc.fx.policies.ViewportPolicy
-
- All Implemented Interfaces:
IAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>,IPolicy
public class ViewportPolicy extends AbstractPolicy
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound
IAdaptable.Bound.Impl<T extends IAdaptable>
-
-
Constructor Summary
Constructors Constructor Description ViewportPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ITransactionalOperationcreateOperation()Creates anITransactionalOperationthat is used to encapsulate the changes that are applied by thisAbstractPolicythrough its "work" methods.voidfitToSize()Centers the contents within the viewport and zooms the viewport so that the contents are fully visible.voidfitToSize(double zoomMin)Centers the contents within the viewport and zooms the viewport so that the contents are fully visible (if possible given the specified zoom factor range).voidfitToSize(double zoomMin, double zoomMax)Centers the contents within the viewport and zooms the viewport so that the contents are fully visible (if possible given the specified zoom factor range).protected ChangeViewportOperationgetChangeViewportOperation()Returns anChangeViewportOperationthat is extracted from the operation created bycreateOperation().voidscroll(boolean concatenate, double deltaTranslateX, double deltaTranslateY)Advances the viewport transformation by the given translation values.voidsetScroll(double tx, double ty)Sets the x and y translation of the viewport to the given values.voidsetZoom(double zoom)Sets the x and y scaling of the viewport to the given zoom factor.voidzoom(boolean concatenate, boolean discretize, double relativeZoom, double sceneX, double sceneY)Concatenates a scaling transformation to the current viewport transformation.-
Methods inherited from class org.eclipse.gef.mvc.fx.policies.AbstractPolicy
checkInitialized, commit, getOperation, init, isInitialized, locallyExecuteOperation, rollback
-
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
-
-
-
-
Method Detail
-
createOperation
protected ITransactionalOperation createOperation()
Description copied from class:AbstractPolicyCreates anITransactionalOperationthat is used to encapsulate the changes that are applied by thisAbstractPolicythrough its "work" methods. The created operation should allow forlocal executionat each time.- Specified by:
createOperationin classAbstractPolicy- Returns:
- A new
ITransactionalOperationto encapsulate all applied changes.
-
fitToSize
public void fitToSize()
Centers the contents within the viewport and zooms the viewport so that the contents are fully visible.
-
fitToSize
public void fitToSize(double zoomMin)
Centers the contents within the viewport and zooms the viewport so that the contents are fully visible (if possible given the specified zoom factor range).- Parameters:
zoomMin- The minimum zoom factor.
-
fitToSize
public void fitToSize(double zoomMin, double zoomMax)Centers the contents within the viewport and zooms the viewport so that the contents are fully visible (if possible given the specified zoom factor range).- Parameters:
zoomMin- The minimum zoom factor.zoomMax- The maximum zoom factor.
-
getChangeViewportOperation
protected ChangeViewportOperation getChangeViewportOperation()
Returns anChangeViewportOperationthat is extracted from the operation created bycreateOperation().- Returns:
- An
ChangeViewportOperationthat is extracted from the operation created bycreateOperation().
-
scroll
public void scroll(boolean concatenate, double deltaTranslateX, double deltaTranslateY)Advances the viewport transformation by the given translation values.- Parameters:
concatenate-trueto concatenate the specified zoom to the current transformation,falseto not concatenate the specified scroll to the current but to the initial transformation.deltaTranslateX- The horizontal translation delta.deltaTranslateY- The vertical translation delta.
-
setScroll
public void setScroll(double tx, double ty)Sets the x and y translation of the viewport to the given values. Does not alter scaling.- Parameters:
tx- The new x translation.ty- The new y translation.
-
setZoom
public void setZoom(double zoom)
Sets the x and y scaling of the viewport to the given zoom factor. Does not alter translation/scroll-offset.- Parameters:
zoom- The new x and y scaling for the viewport.
-
zoom
public void zoom(boolean concatenate, boolean discretize, double relativeZoom, double sceneX, double sceneY)Concatenates a scaling transformation to the current viewport transformation.- Parameters:
concatenate-trueto concatenate the specified zoom to the current transformation,falseto not concatenate the specified zoom to the current but to the initial transformation.discretize-trueto discretize the resulting zoom level, i.e. round it to 6 decimal places and do not skip integer zoom levels,falseto not change the resulting zoom level.relativeZoom- The scale factor.sceneX- The pivot x-coordinate.sceneY- The pivot y-coordinate.
-
-