jv.objectGui

## Class PsImage

- java.lang.Object
- - jv.objectGui.PsImage

-     public class PsImage
      extends java.lang.Object

  A class for loading and handling images.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `PsImage(java.awt.Image image, java.lang.String alternateText)` Create an PsImage using the image specified.
    `PsImage(java.lang.String imageName)` Create an PsImage using the image at relative path specified by the string.
    `PsImage(java.net.URL url)` Create an PsImage using the image at an absolute URL specified by the string.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static java.awt.Image` | `createImageFromPixels(java.awt.Component comp, int[] pixels, int width, int height, int offset, int scan)` Load image with a media tracker and return when image is loaded or failure occurred.
    `int` | `getHeight()` Get height of loaded image.
    `java.awt.Image` | `getImage()` Get the image after loading it if not done yet.
    `static java.awt.Image` | `getImage(java.lang.String imageName)` Get image relative to codeBase of applet, or from file system.
    `static java.awt.Image` | `getImage(java.net.URL url)` Get image from absolute URL.
    `static java.awt.Image` | `getImageResource(java.lang.String s)` Get a GIF or JPG (and now PNG too) image from a resource including the current jar archives.
    `static int[]` | `getPixels(java.awt.Image image)` Convert an image to an array of pixels.
    `static int[]` | `getPixels(java.awt.Image image, int x, int y, int width, int height, int[] pixels, int off, int scan)`
    `int` | `getWidth()` Get width of loaded image.
    `void` | `init()` Create MediaTracker.
    `boolean` | `loadImage()` Makes sure that the Image is loaded before returning from this method.
    `static boolean` | `loadImage(java.awt.Component comp, java.awt.Image image)` Load image with a media tracker and return when image is loaded or failure occurred.
    `void` | `setParentComponent(java.awt.Component comp)` Set component used for MediaTracker in `init()` method
    `void` | `setSize(int width, int height)` Resizes the image after loading it if not done yet.

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

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

- - ### Constructor Detail

    - #### PsImage

          public PsImage(java.net.URL url)

      Create an PsImage using the image at an absolute URL specified by the string.
      Parameters:
        `url` - A String specifying the absolute URL of the image.

    - #### PsImage

          public PsImage(java.lang.String imageName)

      Create an PsImage using the image at relative path specified by the string.
      Parameters:
        `imageName` - name of image file including a relative path.

    - #### PsImage

          public PsImage(java.awt.Image image,
                 java.lang.String alternateText)

      Create an PsImage using the image specified. The other constructors eventually call this one, but you may want to call it directly if you already have an image (e.g. created via createImage).
      Parameters:
        `image` - The image
        `alternateText` - Alternate text used if image cannot be retrieved

  - ### Method Detail

    - #### init

          public void init()

      Create MediaTracker.

    - #### setParentComponent

          public void setParentComponent(java.awt.Component comp)

      Set component used for MediaTracker in `init()` method

    - #### loadImage

          public boolean loadImage()

      Makes sure that the Image is loaded before returning from this method. Caller of this method may spin off a separate thread to do the loading. On the other hand, postponing the waiting as long as possible is more efficient, since loading can go on in the background.

    - #### getWidth

          public int getWidth()

      Get width of loaded image.

    - #### getHeight

          public int getHeight()

      Get height of loaded image.

    - #### getImage

          public java.awt.Image getImage()

      Get the image after loading it if not done yet.

    - #### setSize

          public void setSize(int width,
                     int height)

      Resizes the image after loading it if not done yet.

    - #### getPixels

          public static int[] getPixels(java.awt.Image image,
                        int x,
                        int y,
                        int width,
                        int height,
                        int[] pixels,
                        int off,
                        int scan)

      Parameters:
        `image` - the image to retrieve pixels from
        `x` - the x coordinate of the upper left corner of the rectangle of pixels to retrieve from the image, relative to the default (unscaled) size of the image
        `y` - the y coordinate of the upper left corner of the rectangle of pixels to retrieve from the image
        `width` - the width of the rectangle of pixels to retrieve
        `height` - the height of the rectangle of pixels to retrieve
        `pixels` - the array of integers which are to be used to hold the RGB pixels retrieved from the image
        `off` - the offset into the array of where to store the first pixel
        `scan` - the distance from one row of pixels to the next in the array

    - #### getPixels

          public static int[] getPixels(java.awt.Image image)

      Convert an image to an array of pixels.
      Parameters:
        `image` - the image to retrieve pixels from
      Returns:
        array of pixels on success, `null` on failure.

    - #### getImage

          public static java.awt.Image getImage(java.lang.String imageName)

      Get image relative to codeBase of applet, or from file system.
      Parameters:
        `imageName` - name of image file with relative url or absolute path.

    - #### getImage

          public static java.awt.Image getImage(java.net.URL url)

      Get image from absolute URL.

    - #### loadImage

          public static boolean loadImage(java.awt.Component comp,
                          java.awt.Image image)

      Load image with a media tracker and return when image is loaded or failure occurred.
      Parameters:
        `comp` - the component on which the images will eventually be drawn.
        `image` - the image to be loaded and tracked by the media tracker.
      Returns:
        `true` on success.

    - #### createImageFromPixels

          public static java.awt.Image createImageFromPixels(java.awt.Component comp,
                                             int[] pixels,
                                             int width,
                                             int height,
                                             int offset,
                                             int scan)

      Load image with a media tracker and return when image is loaded or failure occurred.
      Parameters:
        `comp` - the component on which the images will eventually be drawn.
        `pixels` - array of pixels of the image.
        `width` - width of the image
        `height` - height of the image
        `offset` - starting pixel in pixel array
        `scan` - length of a scan line in pixel array
      Returns:
        image on success, else return `null`

    - #### getImageResource

          public static java.awt.Image getImageResource(java.lang.String s)

      Get a GIF or JPG (and now PNG too) image from a resource including the current jar archives. If image is not available as resource in a JAR file then give it another try and search below the current codebase in the file system.
      Since:
        JavaView 2.66.002

"

The software JavaView? is copyright protected. All Rights Reserved.
"