Runtime

## org.eclipse.gmf.runtime.draw2d.ui.render.figures
Class ScalableImageFigure

    java.lang.Object
      org.eclipse.draw2d.Figure
          org.eclipse.draw2d.ImageFigure
              org.eclipse.gmf.runtime.draw2d.ui.render.figures.ScalableImageFigure

All Implemented Interfaces:
  IFigure

public class ScalableImageFigure
extends ImageFigure

An implementation of `ImageFigure` that allows scaling the underlying image to the containing Figure's bounds, rather then being fixed to the image size.

Any image that can be implemented inside the RenderedImage interface can be supported.

Nested Class Summary

Nested classes inherited from class org.eclipse.draw2d.Figure
`Figure.FigureIterator, Figure.IdentitySearch`

Nested classes inherited from class org.eclipse.draw2d.IFigure
`IFigure.NoInsets`

Field Summary

Fields inherited from class org.eclipse.draw2d.Figure
`bgColor, border, bounds, fgColor, flags, font, MAX_FLAG, maxSize, minSize, NO_MANAGER, prefSize, toolTip`

Fields inherited from interface org.eclipse.draw2d.IFigure
`MAX_DIMENSION, MIN_DIMENSION, NO_INSETS`

Constructor Summary
`ScalableImageFigure(Image img)`
`ScalableImageFigure(RenderedImage renderedImage)`
`ScalableImageFigure(RenderedImage renderedImage, boolean antiAlias)` Constructor for meta image sources.
`ScalableImageFigure(RenderedImage renderedImage, boolean useDefaultImageSize, boolean useOriginalColors, boolean antiAlias)` Constructor for meta image sources.

Method Summary
`Image` `getImage()` Override to return an image that is scaled to fit the bounds of the figure.
`Dimension` `getPreferredSize(int wHint, int hHint)` Returns the size set specified by setPreferredImageSize() or the size specified by the image.
`RenderedImage` `getRenderedImage()` Gets the `RenderedImage` that is being displayed by this figure.
`boolean` `isAntiAlias()` Accessor to determine if the rendered image will be anti-aliased (if possible).
`boolean` `isMaintainAspectRatio()` Accessor to determine if the rendered image will respect the original aspect ratio of the default image when resized.
`protected void` `paintFigure(Graphics graphics)`
`protected void` `paintFigureWhileRendering(Graphics g)` If the rendering is occuring on a separate thread, this method is a hook to draw a temporary image onto the drawing surface.
`void` `setAntiAlias(boolean antiAlias)` Sets a property to determine if the rendered image will be anti-aliased (if possible).
`void` `setBounds(Rectangle rect)`
`void` `setMaintainAspectRatio(boolean maintainAspectRatio)` Sets a property to determine if the rendered image will respect the original aspect ratio of the default image when resized.
`void` `setPreferredImageSize(int w, int h)` Sets the preferred size of the image figure.
`void` `setRenderedImage(RenderedImage renderedImage)` Sets the `RenderedImage` that is to be displayed by this figure
`boolean` `useOriginalColors()`

Methods inherited from class org.eclipse.draw2d.ImageFigure
`setAlignment, setImage`

Methods inherited from class org.eclipse.draw2d.Figure

`add, add, add, add, addAncestorListener, addCoordinateListener, addFigureListener, addFocusListener, addKeyListener, addLayoutListener, addListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, containsPoint, containsPoint, erase, findDescendantAtExcluding, findFigureAt, findFigureAt, findFigureAt, findFigureAtExcluding, findMouseEventTargetAt, findMouseEventTargetInDescendantsAt, fireCoordinateSystemChanged, fireFigureMoved, fireMoved, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundColor, getBorder, getBounds, getChildren, getClientArea, getClientArea, getCursor, getFlag, getFont, getForegroundColor, getInsets, getLayoutManager, getListeners, getLocalBackgroundColor, getLocalFont, getLocalForegroundColor, getLocation, getMaximumSize, getMinimumSize, getMinimumSize, getParent, getPreferredSize, getSize, getToolTip, getUpdateManager, handleFocusGained, handleFocusLost, handleKeyPressed, handleKeyReleased, handleMouseDoubleClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseHover, handleMouseMoved, handleMousePressed, handleMouseReleased, hasFocus, internalGetEventDispatcher, intersects, invalidate, invalidateTree, isCoordinateSystem, isEnabled, isFocusTraversable, isMirrored, isMouseEventTarget, isOpaque, isRequestFocusEnabled, isShowing, isValid, isValidationRoot, isVisible, layout, paint, paintBorder, paintChildren, paintClientArea, primTranslate, remove, removeAll, removeAncestorListener, removeCoordinateListener, removeFigureListener, removeFocusListener, removeKeyListener, removeLayoutListener, removeListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, revalidate, setBackgroundColor, setBorder, setChildrenDirection, setChildrenEnabled, setChildrenOrientation, setConstraint, setCursor, setEnabled, setFlag, setFocusTraversable, setFont, setForegroundColor, setLayoutManager, setLocation, setMaximumSize, setMinimumSize, setOpaque, setParent, setPreferredSize, setPreferredSize, setRequestFocusEnabled, setSize, setSize, setToolTip, setValid, setVisible, translate, translateFromParent, translateToAbsolute, translateToParent, translateToRelative, useLocalCoordinates, validate`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ScalableImageFigure

    public ScalableImageFigure(Image img)

Parameters:
  `img` - the `Image` to render

### ScalableImageFigure

    public ScalableImageFigure(RenderedImage renderedImage)

Parameters:
  `renderedImage` -

### ScalableImageFigure

    public ScalableImageFigure(RenderedImage renderedImage,
                               boolean antiAlias)

  Constructor for meta image sources.

Parameters:
  `renderedImage` - the `RenderedImage` that is used for rendering the image.

### ScalableImageFigure

    public ScalableImageFigure(RenderedImage renderedImage,
                               boolean useDefaultImageSize,
                               boolean useOriginalColors,
                               boolean antiAlias)

  Constructor for meta image sources.

Parameters:
  `renderedImage` - the `RenderedImage` that is used for rendering the image.
  `useDefaultImageSize` - `boolean` indicating whether to initialize the preferred size with the default image size. Otherwise, a set default will be used instead.
  `useOriginalColors` - `boolean` indicating whether to use the original colors of the `RenderedImage` or to replace black with outline color and white with the fill color.

Method Detail

### isAntiAlias

    public boolean isAntiAlias()

  Accessor to determine if the rendered image will be anti-aliased (if possible).

  Returns:
    `boolean` `true` if anti aliasing is on, `false` otherwise.

### setAntiAlias

    public void setAntiAlias(boolean antiAlias)

  Sets a property to determine if the rendered image will be anti-aliased (if possible).

  Parameters:
    `antiAlias` - `boolean` `true` if anti-aliasing is to be turned on, `false` otherwise

### isMaintainAspectRatio

    public boolean isMaintainAspectRatio()

  Accessor to determine if the rendered image will respect the original aspect ratio of the default image when resized.

  Returns:
    `boolean` `true` if maintain aspect ratio is on, `false` otherwise.

### setMaintainAspectRatio

    public void setMaintainAspectRatio(boolean maintainAspectRatio)

  Sets a property to determine if the rendered image will respect the original aspect ratio of the default image when resized.

  Parameters:
    `maintainAspectRatio` - `boolean` `true` if maintain aspect ratio is to be turned on, `false` otherwise

### setPreferredImageSize

    public void setPreferredImageSize(int w,
                                      int h)

  Sets the preferred size of the image figure.

  Parameters:
    `w` - the preferred width of the image
    `h` - the preferred height of the image

### getPreferredSize

    public Dimension getPreferredSize(int wHint,
                                      int hHint)

  Returns the size set specified by setPreferredImageSize() or the size specified by the image. In the case of meta-images a preferred size of 32x32 is returned.

### setBounds

    public void setBounds(Rectangle rect)

### getImage

    public Image getImage()

  Override to return an image that is scaled to fit the bounds of the figure.

### useOriginalColors

    public boolean useOriginalColors()

  Returns:
    a `boolean` `true` if the original colors of the image should be used for rendering, or `false` indicates that black and white colors can replaced by the specified outline and fill colors respectively of the `RenderInfo`.

### paintFigureWhileRendering

    protected void paintFigureWhileRendering(Graphics g)

  If the rendering is occuring on a separate thread, this method is a hook to draw a temporary image onto the drawing surface.

  Parameters:
    `g` - the `Graphics` object to paint the temporary image to

### paintFigure

    protected void paintFigure(Graphics graphics)

### getRenderedImage

    public RenderedImage getRenderedImage()

  Gets the `RenderedImage` that is being displayed by this figure.

  Returns:
    `RenderedImage` that is being displayed by this figure.

### setRenderedImage

    public void setRenderedImage(RenderedImage renderedImage)

  Sets the `RenderedImage` that is to be displayed by this figure

Runtime

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.