org.eclipse.draw2d

## Class UpdateManager

- java.lang.Object
- - org.eclipse.draw2d.UpdateManager

Direct Known Subclasses:
  DeferredUpdateManager, SubordinateUpdateManager

    public abstract class UpdateManager
    extends java.lang.Object

Update managers handle the job of laying out and repainting figures. A desirable implementation is to batches work to be done and collapses any redundant work. For example, clients may be making multiple changes to figures, which require laying out the same container or repainting the same region.

The update manager receives requests to validate certain figures, and repaint certain areas of figures. An update manager could process every request synchronously, or it could batch these requests and process them asynchronously.

The update process occurs in two phases. The first phase is laying out invalid figures. This phase comes first because it usually introduces additional damage regions. In some cases, while validating figures, new invalid figures may be appended to the update manager. Of course, damage regions will be reported too as figures are layed out.

The second phase is to repaint all damaged areas. The update manager will typically batch, clip, and union, all rectangles and perform a single paint of the overall damaged area.

### Constructor Summary

Constructors
Constructor and Description
`UpdateManager()`

### Method Summary

Methods
`abstract void` `addDirtyRegion(IFigure figure, int x, int y, int w, int h)` Adds the dirty region defined by the coordinates on the IFigure figure.
`void` `addDirtyRegion(IFigure figure, Rectangle rect)`
`abstract void` `addInvalidFigure(IFigure figure)` The receiver should call validate() on the IFigure figure in a timely fashion.
`void` `addUpdateListener(UpdateListener listener)` Adds the given listener to the list of listeners to be notified of painting and validation.
`void` `dispose()` Called when the EditPartViewer is being disposed.
`protected void` `firePainting(Rectangle damage, java.util.Map dirtyRegions)` Notifies listeners that painting is about to occur, passing them the damaged rectangle and the map of dirty regions.
`protected void` `fireValidating()` Notifies listeners that validation is about to occur.
`protected boolean` `isDisposed()`
`protected void` `paint(GC gc)` Invoked by the `LightweightSystem` ( `LightweightSystem.paint(GC)`) to have the update manger paint its contents.
`abstract void` `performUpdate()` Forces an update to occur.
`abstract void` `performUpdate(Rectangle exposed)` Performs an update on the given exposed rectangle.
`void` `performValidation()` Performs a partial update if supported (validation only).
`void` `removeUpdateListener(UpdateListener listener)` Removes one occurrence of the given UpdateListener by identity.
`void` `runWithUpdate(java.lang.Runnable run)` Causes an update to occur at some time, and the given runnable to be executed following the update.
`abstract void` `setGraphicsSource(GraphicsSource gs)` Sets the GraphicsSource for this update manager.
`abstract void` `setRoot(IFigure figure)` Sets the root figure.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### UpdateManager

    public UpdateManager()

### Method Detail

#### addDirtyRegion

    public abstract void addDirtyRegion(IFigure figure,
                      int x,
                      int y,
                      int w,
                      int h)

Adds the dirty region defined by the coordinates on the IFigure figure. The update manager should repaint the dirty region in a timely fashion.

Parameters:
  `figure` - the dirty figure
  `x` - the x coordinate of the dirty region
  `y` - the y coordinate of the dirty region
  `w` - the width of the dirty region
  `h` - the height of the dirty region

#### addDirtyRegion

    public void addDirtyRegion(IFigure figure,
                      Rectangle rect)

See Also:
  `addDirtyRegion(IFigure, int, int, int, int)`

#### runWithUpdate

    public void runWithUpdate(java.lang.Runnable run)

Causes an update to occur at some time, and the given runnable to be executed following the update.

Parameters:
  `run` - the runnable
Since:
  3.1

#### addInvalidFigure

    public abstract void addInvalidFigure(IFigure figure)

The receiver should call validate() on the IFigure figure in a timely fashion.

Parameters:
  `figure` - the invalid figure

#### addUpdateListener

    public void addUpdateListener(UpdateListener listener)

Adds the given listener to the list of listeners to be notified of painting and validation.

Parameters:
  `listener` - the listener to add

#### dispose

    public void dispose()

Called when the EditPartViewer is being disposed.

#### firePainting

    protected void firePainting(Rectangle damage,
                    java.util.Map dirtyRegions)

Notifies listeners that painting is about to occur, passing them the damaged rectangle and the map of dirty regions.

Parameters:
  `damage` - the damaged rectangle
  `dirtyRegions` - map of dirty regions to figures

#### fireValidating

    protected void fireValidating()

Notifies listeners that validation is about to occur.

#### isDisposed

    protected boolean isDisposed()

Returns:
  whether this update manager has been disposed.

#### performUpdate

    public abstract void performUpdate()

Forces an update to occur. Update managers will perform updates automatically, but may do so asynchronously. Calling this method forces a synchronous update.

#### paint

    protected void paint(GC gc)

Invoked by the `LightweightSystem` ( `LightweightSystem.paint(GC)`) to have the update manger paint its contents. Delegates to `performUpdate(Rectangle)` with the passed in gc's clipping region (`GC.getClipping()`) by default. Subclasses may override if they need to access the `GC` for updating.

Parameters:
  `gc` - The `GC` to be used for updating
Since:
  3.10

#### performUpdate

    public abstract void performUpdate(Rectangle exposed)

Performs an update on the given exposed rectangle.

Parameters:
  `exposed` - the exposed rectangle

#### removeUpdateListener

    public void removeUpdateListener(UpdateListener listener)

Removes one occurrence of the given UpdateListener by identity.

Parameters:
  `listener` - the listener to remove

#### setGraphicsSource

    public abstract void setGraphicsSource(GraphicsSource gs)

Sets the GraphicsSource for this update manager.

Parameters:
  `gs` - the new GraphicsSource

#### setRoot

    public abstract void setRoot(IFigure figure)

Sets the root figure.

Parameters:
  `figure` - the new root figure

#### performValidation

    public void performValidation()

Performs a partial update if supported (validation only). Fires notification to listeners that validation has been performed. By default this method calls `performUpdate()`. Subclasses should override this method to support validation without repainting.

Since:
  3.2