org.eclipse.gef.mvc.fx.operations

## Class ChangeViewportOperation

- java.lang.Object
- - org.eclipse.core.commands.operations.AbstractOperation
  - - org.eclipse.gef.mvc.fx.operations.ChangeViewportOperation

All Implemented Interfaces:
  org.eclipse.core.commands.operations.IUndoableOperation, ITransactionalOperation

    public class ChangeViewportOperation
    extends org.eclipse.core.commands.operations.AbstractOperation
    implements ITransactionalOperation

The `ChangeViewportOperation` can be used to alter the scroll offset and the content transformation of an `InfiniteCanvas`. It is used by scroll/pan and zoom policies.

### Constructor Summary

Constructors
Constructor and Description
`ChangeViewportOperation(InfiniteCanvas canvas)` Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`.
`ChangeViewportOperation(InfiniteCanvas canvas, AffineTransform newContentTransform)` Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`.
`ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset)` Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`.
`ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, AffineTransform newContentTransform)` Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`.
`ChangeViewportOperation(InfiniteCanvas canvas, double newHorizontalScrollOffset, double newVerticalScrollOffset, double newWidth, double newHeight, AffineTransform newContentTransform)` Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `concatenateToNewContentTransform(AffineTransform t)` Concatenates the given `AffineTransform` to the contents transformation that will be applied when executing this operation.
`org.eclipse.core.runtime.IStatus` `execute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)`
`InfiniteCanvas` `getInfiniteCanvas()` Returns the `InfiniteCanvas` 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()` Returns `true` if this `ITransactionalOperation` is actually changing model data (instead of only affecting the visualization).
`boolean` `isNoOp()` Returns `true` if this `ITransactionalOperation` 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.
`org.eclipse.core.runtime.IStatus` `redo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.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.
`org.eclipse.core.runtime.IStatus` `undo(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.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 new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`. The current viewport values are read and used when undoing this operation.

Parameters:
  `canvas` - The `InfiniteCanvas` which is manipulated by this operation.

#### ChangeViewportOperation

    public ChangeViewportOperation(InfiniteCanvas canvas,
                                   AffineTransform newContentTransform)

Creates a new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`. The current viewport values are read and used when undoing this operation. The given `AffineTransform` will be applied when executing this operation.

Parameters:
  `canvas` - The `InfiniteCanvas` 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 new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`. 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` - The `InfiniteCanvas` 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 new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`. 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` - The `InfiniteCanvas` 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 new `ChangeViewportOperation` to manipulate the given `InfiniteCanvas`. 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` - The `InfiniteCanvas` 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 given `AffineTransform` to the contents transformation that will be applied when executing this operation.

Parameters:
  `t` - The `AffineTransform` which is concatenated to the transformation that will be applied when executing this operation.

#### execute

    public org.eclipse.core.runtime.IStatus execute(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                    org.eclipse.core.runtime.IAdaptable info)
                                             throws org.eclipse.core.commands.ExecutionException

Specified by:
  `execute` in interface `org.eclipse.core.commands.operations.IUndoableOperation`
Specified by:
  `execute` in class `org.eclipse.core.commands.operations.AbstractOperation`
Throws:
  `org.eclipse.core.commands.ExecutionException`

#### getInfiniteCanvas

    public InfiniteCanvas getInfiniteCanvas()

Returns the `InfiniteCanvas` 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`
Returns `true` if this `ITransactionalOperation` is actually changing model data (instead of only affecting the visualization). Otherwise returns `false`. The content relevance of an `ITransactionalOperation` 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 interface `ITransactionalOperation`
Returns:
  `true` if this `ITransactionalOperation` is actually changing model data, otherwise `false`.

#### isNoOp

    public boolean isNoOp()

Description copied from interface: `ITransactionalOperation`
Returns `true` if this `ITransactionalOperation` has no effect (in comparison to its initial state). Otherwise returns `false`.

Specified by:
  `isNoOp` in interface `ITransactionalOperation`
Returns:
  `true` if this `ITransactionalOperation` has no effect, otherwise `false`.

#### readViewport

    protected void readViewport(InfiniteCanvas canvas)

Stores all relevant viewport values in fields, so that they can be restored later.

Parameters:
  `canvas` - The `InfiniteCanvas` from which the values are read.

#### redo

    public org.eclipse.core.runtime.IStatus redo(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                 org.eclipse.core.runtime.IAdaptable info)
                                          throws org.eclipse.core.commands.ExecutionException

Specified by:
  `redo` in interface `org.eclipse.core.commands.operations.IUndoableOperation`
Specified by:
  `redo` in class `org.eclipse.core.commands.operations.AbstractOperation`
Throws:
  `org.eclipse.core.commands.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 org.eclipse.core.runtime.IStatus undo(org.eclipse.core.runtime.IProgressMonitor monitor,
                                                 org.eclipse.core.runtime.IAdaptable info)
                                          throws org.eclipse.core.commands.ExecutionException

Specified by:
  `undo` in interface `org.eclipse.core.commands.operations.IUndoableOperation`
Specified by:
  `undo` in class `org.eclipse.core.commands.operations.AbstractOperation`
Throws:
  `org.eclipse.core.commands.ExecutionException`