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
TheChangeViewportOperation
can 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 newChangeViewportOperation
to manipulate the givenInfiniteCanvas
.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset)
Creates a newChangeViewportOperation
to manipulate the givenInfiniteCanvas
.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, double newWidth, double newHeight, AffineTransform newContentTransform)
Creates a newChangeViewportOperation
to manipulate the givenInfiniteCanvas
.ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, AffineTransform newContentTransform)
Creates a newChangeViewportOperation
to manipulate the givenInfiniteCanvas
.ChangeViewportOperation(InfiniteCanvas canvas, AffineTransform newContentTransform)
Creates a newChangeViewportOperation
to manipulate the givenInfiniteCanvas
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
concatenateToNewContentTransform(AffineTransform t)
Concatenates the givenAffineTransform
to the contents transformation that will be applied when executing this operation.IStatus
execute(IProgressMonitor monitor, IAdaptable info)
InfiniteCanvas
getInfiniteCanvas()
Returns theInfiniteCanvas
that is manipulated by this operation.AffineTransform
getInitialContentTransform()
Returns the contents transformation that will be applied when undoing this operation.double
getInitialHeight()
Returns the viewport height that will be applied when undoing this operation.double
getInitialHorizontalScrollOffset()
Returns the horizontal translation that will be applied when undoing this operation.double
getInitialVerticalScrollOffset()
Returns the vertical translation that will be applied when undoing this operation.double
getInitialWidth()
Returns the viewport width that will be applied when undoing this operation.AffineTransform
getNewContentTransform()
Returns the contents transformation that will be applied when executing this operation.double
getNewHeight()
Returns the viewport height that will be applied when executing this operation.double
getNewHorizontalScrollOffset()
Returns the horizontal translation that will be applied when executing this operation.double
getNewVerticalScrollOffset()
Returns the vertical translation that will be applied when executing this operation.double
getNewWidth()
Returns the viewport width that will be applied when executing this operation.boolean
isContentRelevant()
Returnstrue
if thisITransactionalOperation
is actually changing model data (instead of only affecting the visualization).boolean
isNoOp()
Returnstrue
if thisITransactionalOperation
has no effect (in comparison to its initial state).protected void
readViewport(InfiniteCanvas canvas)
Stores all relevant viewport values in fields, so that they can be restored later.IStatus
redo(IProgressMonitor monitor, IAdaptable info)
void
setInitialContentTransform(AffineTransform initialContentTransform)
Sets the initial content transform before applying the new value.void
setInitialHeight(double initialHeight)
Sets the initial height before applying the new value.void
setInitialHorizontalScrollOffset(double initialHorizontalScrollOffset)
Sets the initial horizontal scroll offset before applying the new value.void
setInitialVerticalScrollOffset(double initialVerticalScrollOffset)
Sets the initial vertical scroll offset before applying the new value.void
setInitialWidth(double initialWidth)
Sets the initial width before applying the new value.void
setNewContentTransform(AffineTransform newContentTransform)
Sets the contents transformation that will be applied when executing this operation to the given value.void
setNewHeight(double newHeight)
Sets the viewport height that will be applied when executing this operation to the given value.void
setNewHorizontalScrollOffset(double newHorizontalScrollOffset)
Sets the horizontal translation that will be applied when executing this operation to the given value.void
setNewVerticalScrollOffset(double newVerticalScrollOffset)
Sets the vertical translation that will be applied when executing this operation to the given value.void
setNewWidth(double newWidth)
Sets the viewport width that will be applied when executing this operation to the given value.IStatus
undo(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 newChangeViewportOperation
to manipulate the givenInfiniteCanvas
. The current viewport values are read and used when undoing this operation.- Parameters:
canvas
- TheInfiniteCanvas
which is manipulated by this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, AffineTransform newContentTransform)
Creates a newChangeViewportOperation
to manipulate the givenInfiniteCanvas
. The current viewport values are read and used when undoing this operation. The givenAffineTransform
will be applied when executing this operation.- Parameters:
canvas
- TheInfiniteCanvas
that is manipulated.newContentTransform
- The contents transformation which is applied when executing this operation.
-
ChangeViewportOperation
public ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset)
Creates a newChangeViewportOperation
to 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
- TheInfiniteCanvas
that 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 newChangeViewportOperation
to 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
- TheInfiniteCanvas
that 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 newChangeViewportOperation
to 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
- TheInfiniteCanvas
that 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 givenAffineTransform
to the contents transformation that will be applied when executing this operation.- Parameters:
t
- TheAffineTransform
which 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:
execute
in interfaceIUndoableOperation
- Specified by:
execute
in classAbstractOperation
- Throws:
ExecutionException
-
getInfiniteCanvas
public InfiniteCanvas getInfiniteCanvas()
Returns theInfiniteCanvas
that is manipulated by this operation.- Returns:
- The
InfiniteCanvas
that 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:ITransactionalOperation
Returnstrue
if thisITransactionalOperation
is actually changing model data (instead of only affecting the visualization). Otherwise returnsfalse
. The content relevance of anITransactionalOperation
can 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:
isContentRelevant
in interfaceITransactionalOperation
- Returns:
true
if thisITransactionalOperation
is actually changing model data, otherwisefalse
.
-
isNoOp
public boolean isNoOp()
Description copied from interface:ITransactionalOperation
Returnstrue
if thisITransactionalOperation
has no effect (in comparison to its initial state). Otherwise returnsfalse
.- Specified by:
isNoOp
in interfaceITransactionalOperation
- Returns:
true
if thisITransactionalOperation
has 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
- TheInfiniteCanvas
from which the values are read.
-
redo
public IStatus redo(IProgressMonitor monitor, IAdaptable info) throws ExecutionException
- Specified by:
redo
in interfaceIUndoableOperation
- Specified by:
redo
in 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:
undo
in interfaceIUndoableOperation
- Specified by:
undo
in classAbstractOperation
- Throws:
ExecutionException
-
-