Class ChangeViewportOperation
- java.lang.Object
-
- org.eclipse.core.commands.operations.AbstractOperation
-
- org.eclipse.gef.mvc.fx.operations.ChangeViewportOperation
-
- All Implemented Interfaces:
IUndoableOperation,ITransactionalOperation
public class ChangeViewportOperation extends AbstractOperation implements ITransactionalOperation
TheChangeViewportOperationcan be used to alter the scroll offset and the content transformation of anInfiniteCanvas. It is used by scroll/pan and zoom policies.
-
-
Constructor Summary
Constructors Constructor Description ChangeViewportOperation(InfiniteCanvas canvas)Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset)Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, double newWidth, double newHeight, AffineTransform newContentTransform)Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, AffineTransform newContentTransform)Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas.ChangeViewportOperation(InfiniteCanvas canvas, AffineTransform newContentTransform)Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconcatenateToNewContentTransform(AffineTransform t)Concatenates the givenAffineTransformto the contents transformation that will be applied when executing this operation.IStatusexecute(IProgressMonitor monitor, IAdaptable info)InfiniteCanvasgetInfiniteCanvas()Returns theInfiniteCanvasthat is manipulated by this operation.AffineTransformgetInitialContentTransform()Returns the contents transformation that will be applied when undoing this operation.doublegetInitialHeight()Returns the viewport height that will be applied when undoing this operation.doublegetInitialHorizontalScrollOffset()Returns the horizontal translation that will be applied when undoing this operation.doublegetInitialVerticalScrollOffset()Returns the vertical translation that will be applied when undoing this operation.doublegetInitialWidth()Returns the viewport width that will be applied when undoing this operation.AffineTransformgetNewContentTransform()Returns the contents transformation that will be applied when executing this operation.doublegetNewHeight()Returns the viewport height that will be applied when executing this operation.doublegetNewHorizontalScrollOffset()Returns the horizontal translation that will be applied when executing this operation.doublegetNewVerticalScrollOffset()Returns the vertical translation that will be applied when executing this operation.doublegetNewWidth()Returns the viewport width that will be applied when executing this operation.booleanisContentRelevant()Returnstrueif thisITransactionalOperationis actually changing model data (instead of only affecting the visualization).booleanisNoOp()Returnstrueif thisITransactionalOperationhas no effect (in comparison to its initial state).protected voidreadViewport(InfiniteCanvas canvas)Stores all relevant viewport values in fields, so that they can be restored later.IStatusredo(IProgressMonitor monitor, IAdaptable info)voidsetInitialContentTransform(AffineTransform initialContentTransform)Sets the initial content transform before applying the new value.voidsetInitialHeight(double initialHeight)Sets the initial height before applying the new value.voidsetInitialHorizontalScrollOffset(double initialHorizontalScrollOffset)Sets the initial horizontal scroll offset before applying the new value.voidsetInitialVerticalScrollOffset(double initialVerticalScrollOffset)Sets the initial vertical scroll offset before applying the new value.voidsetInitialWidth(double initialWidth)Sets the initial width before applying the new value.voidsetNewContentTransform(AffineTransform newContentTransform)Sets the contents transformation that will be applied when executing this operation to the given value.voidsetNewHeight(double newHeight)Sets the viewport height that will be applied when executing this operation to the given value.voidsetNewHorizontalScrollOffset(double newHorizontalScrollOffset)Sets the horizontal translation that will be applied when executing this operation to the given value.voidsetNewVerticalScrollOffset(double newVerticalScrollOffset)Sets the vertical translation that will be applied when executing this operation to the given value.voidsetNewWidth(double newWidth)Sets the viewport width that will be applied when executing this operation to the given value.IStatusundo(IProgressMonitor monitor, IAdaptable info)-
Methods inherited from class org.eclipse.core.commands.operations.AbstractOperation
addContext, canExecute, canRedo, canUndo, dispose, getContexts, getLabel, hasContext, removeContext, setLabel, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.eclipse.core.commands.operations.IUndoableOperation
addContext, canExecute, canRedo, canUndo, dispose, getContexts, getLabel, hasContext, removeContext
-
-
-
-
Constructor Detail
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas)
Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas. The current viewport values are read and used when undoing this operation.- Parameters:
canvas- TheInfiniteCanvaswhich is manipulated by this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, AffineTransform newContentTransform)
Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas. The current viewport values are read and used when undoing this operation. The givenAffineTransformwill be applied when executing this operation.- Parameters:
canvas- TheInfiniteCanvasthat is manipulated.newContentTransform- The contents transformation which is applied when executing this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset)
Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas. The current viewport values are read and used when undoing this operation. The given translation values will be applied when executing this operation.- Parameters:
canvas- TheInfiniteCanvasthat is manipulated.newHorizontalScrollOffset- The horizontal translation that is applied when executing this operation.newVerticalScrollOffset- The vertical translation that is applied when executing this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, AffineTransform newContentTransform)
Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas. The current viewport values are read and used when undoing this operation. The given translation values and contents transformation will be applied when executing this operation.- Parameters:
canvas- TheInfiniteCanvasthat is manipulated.newHorizontalScrollOffset- The horizontal translation that is applied when executing this operation.newVerticalScrollOffset- The vertical translation that is applied when executing this operation.newContentTransform- The contents transformation which is applied when executing this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, double newWidth, double newHeight, AffineTransform newContentTransform)
Creates a newChangeViewportOperationto manipulate the givenInfiniteCanvas. The current viewport values are read and used when undoing this operation. The given translation values, dimensions, and contents transformation will be applied when executing this operation.- Parameters:
canvas- TheInfiniteCanvasthat is manipulated.newHorizontalScrollOffset- The horizontal translation that is applied when executing this operation.newVerticalScrollOffset- The vertical translation that is applied when executing this operation.newWidth- The viewport width that is applied when executing this operation.newHeight- The viewport height that is applied when executing this operation.newContentTransform- The contents transformation which is applied when executing this operation.
-
-
Method Detail
-
concatenateToNewContentTransform
public void concatenateToNewContentTransform(AffineTransform t)
Concatenates the givenAffineTransformto the contents transformation that will be applied when executing this operation.- Parameters:
t- TheAffineTransformwhich is concatenated to the transformation that will be applied when executing this operation.
-
execute
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
executein interfaceIUndoableOperation- Specified by:
executein classAbstractOperation- Throws:
ExecutionException
-
getInfiniteCanvas
public InfiniteCanvas getInfiniteCanvas()
Returns theInfiniteCanvasthat is manipulated by this operation.- Returns:
- The
InfiniteCanvasthat is manipulated by this operation.
-
getInitialContentTransform
public AffineTransform getInitialContentTransform()
Returns the contents transformation that will be applied when undoing this operation.- Returns:
- The contents transformation that will be applied when undoing this operation.
-
getInitialHeight
public double getInitialHeight()
Returns the viewport height that will be applied when undoing this operation.- Returns:
- The viewport height that will be applied when undoing this operation.
-
getInitialHorizontalScrollOffset
public double getInitialHorizontalScrollOffset()
Returns the horizontal translation that will be applied when undoing this operation.- Returns:
- The horizontal translation that will be applied when undoing this operation.
-
getInitialVerticalScrollOffset
public double getInitialVerticalScrollOffset()
Returns the vertical translation that will be applied when undoing this operation.- Returns:
- The vertical translation that will be applied when undoing this operation.
-
getInitialWidth
public double getInitialWidth()
Returns the viewport width that will be applied when undoing this operation.- Returns:
- The viewport width that will be applied when undoing this operation.
-
getNewContentTransform
public AffineTransform getNewContentTransform()
Returns the contents transformation that will be applied when executing this operation.- Returns:
- The contents transformation that will be applied when executing this operation.
-
getNewHeight
public double getNewHeight()
Returns the viewport height that will be applied when executing this operation.- Returns:
- The viewport height that will be applied when executing this operation.
-
getNewHorizontalScrollOffset
public double getNewHorizontalScrollOffset()
Returns the horizontal translation that will be applied when executing this operation.- Returns:
- The horizontal translation that will be applied when executing this operation.
-
getNewVerticalScrollOffset
public double getNewVerticalScrollOffset()
Returns the vertical translation that will be applied when executing this operation.- Returns:
- The vertical translation that will be applied when executing this operation.
-
getNewWidth
public double getNewWidth()
Returns the viewport width that will be applied when executing this operation.- Returns:
- The viewport width that will be applied when executing this operation.
-
isContentRelevant
public boolean isContentRelevant()
Description copied from interface:ITransactionalOperationReturnstrueif thisITransactionalOperationis actually changing model data (instead of only affecting the visualization). Otherwise returnsfalse. The content relevance of anITransactionalOperationcan be checked to determine if the execution of the operation will affect the model, for example, to set an editor's dirty flag.- Specified by:
isContentRelevantin interfaceITransactionalOperation- Returns:
trueif thisITransactionalOperationis actually changing model data, otherwisefalse.
-
isNoOp
public boolean isNoOp()
Description copied from interface:ITransactionalOperationReturnstrueif thisITransactionalOperationhas no effect (in comparison to its initial state). Otherwise returnsfalse.- Specified by:
isNoOpin interfaceITransactionalOperation- Returns:
trueif thisITransactionalOperationhas no effect, otherwisefalse.
-
readViewport
protected void readViewport(InfiniteCanvas canvas)
Stores all relevant viewport values in fields, so that they can be restored later.- Parameters:
canvas- TheInfiniteCanvasfrom which the values are read.
-
redo
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
redoin interfaceIUndoableOperation- Specified by:
redoin classAbstractOperation- Throws:
ExecutionException
-
setInitialContentTransform
public void setInitialContentTransform(AffineTransform initialContentTransform)
Sets the initial content transform before applying the new value.- Parameters:
initialContentTransform- The initialContentTransform to set.
-
setInitialHeight
public void setInitialHeight(double initialHeight)
Sets the initial height before applying the new value.- Parameters:
initialHeight- The initialHeight to set.
-
setInitialHorizontalScrollOffset
public void setInitialHorizontalScrollOffset(double initialHorizontalScrollOffset)
Sets the initial horizontal scroll offset before applying the new value.- Parameters:
initialHorizontalScrollOffset- The initialHorizontalScrollOffset to set.
-
setInitialVerticalScrollOffset
public void setInitialVerticalScrollOffset(double initialVerticalScrollOffset)
Sets the initial vertical scroll offset before applying the new value.- Parameters:
initialVerticalScrollOffset- The initialVerticalScrollOffset to set.
-
setInitialWidth
public void setInitialWidth(double initialWidth)
Sets the initial width before applying the new value.- Parameters:
initialWidth- The initialWidth to set.
-
setNewContentTransform
public void setNewContentTransform(AffineTransform newContentTransform)
Sets the contents transformation that will be applied when executing this operation to the given value.- Parameters:
newContentTransform- The contents transformation to apply when executing this operation.
-
setNewHeight
public void setNewHeight(double newHeight)
Sets the viewport height that will be applied when executing this operation to the given value.- Parameters:
newHeight- The viewport height to apply when executing this operation.
-
setNewHorizontalScrollOffset
public void setNewHorizontalScrollOffset(double newHorizontalScrollOffset)
Sets the horizontal translation that will be applied when executing this operation to the given value.- Parameters:
newHorizontalScrollOffset- The horizontal translation to apply when executing this operation.
-
setNewVerticalScrollOffset
public void setNewVerticalScrollOffset(double newVerticalScrollOffset)
Sets the vertical translation that will be applied when executing this operation to the given value.- Parameters:
newVerticalScrollOffset- The vertical translation to apply when executing this operation.
-
setNewWidth
public void setNewWidth(double newWidth)
Sets the viewport width that will be applied when executing this operation to the given value.- Parameters:
newWidth- The viewport width to apply when executing this operation.
-
undo
public IStatus undo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
undoin interfaceIUndoableOperation- Specified by:
undoin classAbstractOperation- Throws:
ExecutionException
-
-