javafx.embed.swt

## Class SWTFXUtils

- java.lang.Object
- - javafx.embed.swt.SWTFXUtils

-     public class SWTFXUtils
      extends Object

  This class provides utility methods for converting data types between SWT and JavaFX formats.
  Since:
    JavaFX 2.2

- - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static org.eclipse.swt.graphics.ImageData` | `fromFXImage(Image image, org.eclipse.swt.graphics.ImageData imageData)` Snapshots the specified JavaFX `Image` object and stores a copy of its pixels into a new `ImageData` object.
    `static WritableImage` | `toFXImage(org.eclipse.swt.graphics.ImageData imageData, WritableImage image)` Snapshots the specified `ImageData` and stores a copy of its pixels into a JavaFX `Image` object, creating a new object if needed.

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

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

- - ### Method Detail

    - #### toFXImage

          public static WritableImage toFXImage(org.eclipse.swt.graphics.ImageData imageData,
                                                WritableImage image)

      Snapshots the specified `ImageData` and stores a copy of its pixels into a JavaFX `Image` object, creating a new object if needed. The returned `Image` will be a static snapshot of the state of the pixels in the `ImageData` at the time the method completes. Further changes to the `ImageData` will not be reflected in the `Image`.

      The optional JavaFX `WritableImage` parameter may be reused to store the copy of the pixels. A new `Image` will be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.

      Parameters:
        `imageData` - the `ImageData` object to be converted
        `image` - an optional `WritableImage` object that can be used to store the returned pixel data
      Returns:
        an `Image` object representing a snapshot of the current pixels in the `ImageData`, or null if the `Image` is not readable.

    - #### fromFXImage

          public static org.eclipse.swt.graphics.ImageData fromFXImage(Image image,
                                                                       org.eclipse.swt.graphics.ImageData imageData)

      Snapshots the specified JavaFX `Image` object and stores a copy of its pixels into a new `ImageData` object. The method will only convert a JavaFX `Image` that is readable as per the conditions on the `Image.getPixelReader()` method. If the `Image` is not readable, as determined by its `getPixelReader()` method, then this method will return null. If the `Image` is a writable, or other dynamic image, then the `ImageData` will only be set to the current state of the pixels in the image as determined by its `PixelReader`. Further changes to the pixels of the `Image` will not be reflected in the returned `ImageData`.

      The optional `ImageData` parameter may be reused to store the copy of the pixels. A new `ImageData` will be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.

      Parameters:
        `image` - the JavaFX `Image` to be converted
        `imageData` - an optional `ImageData` object that may be used to store the returned pixel data
      Returns:
        a `ImageData` containing a snapshot of the JavaFX `Image`, or null if the `Image` is not readable.

Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.