Package org.fife.ui.rtextarea

## Class ImageBackgroundPainterStrategy

- java.lang.Object
- - org.fife.ui.rtextarea.ImageBackgroundPainterStrategy

- All Implemented Interfaces:
    `BackgroundPainterStrategy`
  Direct Known Subclasses:
    `BufferedImageBackgroundPainterStrategy`, `VolatileImageBackgroundPainterStrategy`

      public abstract class ImageBackgroundPainterStrategy
      extends Object
      implements BackgroundPainterStrategy

  A strategy for painting the background of an `RTextAreaBase` as an image. The image is always stretched to completely fill the `RTextAreaBase`.

  You can set the scaling hint used when stretching/skewing the image to fit in the `RTextAreaBase`'s background via the `setScalingHint` method, but keep in mind the more accurate the scaling hint, the less responsive your application will be when stretching the window (as that's the only time the image's size is recalculated).

  See Also:
    `BufferedImageBackgroundPainterStrategy`, `VolatileImageBackgroundPainterStrategy`

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected MediaTracker` | `tracker` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ImageBackgroundPainterStrategy​(RTextAreaBase textArea)` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `Image` | `getMasterImage()` | Returns the "master" image; that is, the original, unscaled image.
    `RTextAreaBase` | `getRTextAreaBase()` | Returns the text area using this strategy.
    `int` | `getScalingHint()` | Returns the scaling hint being used.
    `void` | `paint​(Graphics g, Rectangle bounds)` | Paints the image at the specified location and at the specified size.
    `protected abstract void` | `paintImage​(Graphics g, int x, int y)` | Paints the image at the specified location.
    `protected abstract void` | `rescaleImage​(int width, int height, int hint)` | Rescales the displayed image to be the specified size.
    `void` | `setImage​(Image image)` | Sets the image this background painter displays.
    `void` | `setImage​(URL imageURL)` | Sets the image this background painter displays.
    `void` | `setScalingHint​(int hint)` | Sets the scaling hint to use when scaling the image.

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

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

- - ### Field Detail

    - #### tracker

          protected MediaTracker tracker

  - ### Constructor Detail

    - #### ImageBackgroundPainterStrategy

          public ImageBackgroundPainterStrategy​(RTextAreaBase textArea)

      Constructor.
      Parameters:
        `textArea` - The text area using this image as its background.

  - ### Method Detail

    - #### getRTextAreaBase

          public RTextAreaBase getRTextAreaBase()

      Returns the text area using this strategy.
      Returns:
        The text area.

    - #### getMasterImage

          public Image getMasterImage()

      Returns the "master" image; that is, the original, unscaled image. When the image needs to be rescaled, scaling should be done from this image, to prevent repeated scaling from distorting the image.
      Returns:
        The master image.

    - #### getScalingHint

          public int getScalingHint()

      Returns the scaling hint being used.
      Returns:
        The scaling hint to use when scaling an image.
      See Also:
        `setScalingHint(int)`

    - #### paint

          public final void paint​(Graphics g,
                                  Rectangle bounds)

      Paints the image at the specified location and at the specified size.
      Specified by:
        `paint` in interface `BackgroundPainterStrategy`
      Parameters:
        `g` - The graphics context.
        `bounds` - The bounds in which to paint the image. The image will be scaled to fit exactly in these bounds if necessary.

    - #### paintImage

          protected abstract void paintImage​(Graphics g,
                                             int x,
                                             int y)

      Paints the image at the specified location. This method assumes scaling has already been done, and simply paints the background image "as-is."
      Parameters:
        `g` - The graphics context.
        `x` - The x-coordinate at which to paint.
        `y` - The y-coordinate at which to paint.

    - #### rescaleImage

          protected abstract void rescaleImage​(int width,
                                               int height,
                                               int hint)

      Rescales the displayed image to be the specified size.
      Parameters:
        `width` - The new width of the image.
        `height` - The new height of the image.
        `hint` - The scaling hint to use.

    - #### setImage

          public void setImage​(URL imageURL)

      Sets the image this background painter displays.
      Parameters:
        `imageURL` - URL of a file containing the image to display.

    - #### setImage

          public void setImage​(Image image)

      Sets the image this background painter displays.
      Parameters:
        `image` - The new image to use for the background.

    - #### setScalingHint

          public void setScalingHint​(int hint)

      Sets the scaling hint to use when scaling the image.
      Parameters:
        `hint` - The hint to apply; e.g. `Image.SCALE_DEFAULT`.
      See Also:
        `getScalingHint()`