Interface GraphicObject

All Known Implementing Classes:
Flat, Picture, PNGPicture

public interface GraphicObject
Interface for graphic data.
Author:
Matthew Tropiano
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    int
     
    int
     
    int
    getPixel(int x, int y)
    Gets the pixel data at a location in the graphic.
    int
    getPixelAlpha(int x, int y)
    Gets a pixel's alpha value from 0 to 255.
    int
     
    default boolean
    isOpaque(int x, int y)
    Checks if a pixel in this graphic is opaque (not translucent - full alpha).
    void
    setOffsetX(int offset)
    Changes this graphic's offset, horizontally, in pixels.
    void
    setOffsetY(int offset)
    Changes this graphic's offset, vertically, in pixels.
    void
    setPixel(int x, int y, int value)
    Sets the pixel data at a location in the graphic.
  • Method Details

    • getOffsetX

      int getOffsetX()
      Returns:
      the offset from the center, horizontally, in pixels.
    • getOffsetY

      int getOffsetY()
      Returns:
      the offset from the center, vertically, in pixels.
    • setOffsetX

      void setOffsetX(int offset)
      Changes this graphic's offset, horizontally, in pixels.
      Parameters:
      offset - the new X offset.
      Since:
      2.22.0
    • setOffsetY

      void setOffsetY(int offset)
      Changes this graphic's offset, vertically, in pixels.
      Parameters:
      offset - the new Y offset.
      Since:
      2.22.0
    • getWidth

      int getWidth()
      Returns:
      the width of this graphic in pixels.
    • getHeight

      int getHeight()
      Returns:
      the height of this graphic in pixels.
    • getPixel

      int getPixel(int x, int y)
      Gets the pixel data at a location in the graphic.

      If this graphic is an indexed color graphic (i.e. Flat or Picture), this will return a palette index value from 0 to 255, or Picture.PIXEL_TRANSLUCENT if this pixel is translucent.

      For full-color graphics, this returns an ARGB integer value representing the pixel color in RGB space (with Alpha).

      Parameters:
      x - graphic x-coordinate.
      y - graphic y-coordinate.
      Returns:
      a palette index value from 0 to 255, Picture.PIXEL_TRANSLUCENT if translucent, or an ARGB value.
      Throws:
      ArrayIndexOutOfBoundsException - if the provided coordinates is outside the graphic.
    • setPixel

      void setPixel(int x, int y, int value)
      Sets the pixel data at a location in the graphic.

      For indexed color graphics, valid values are in the range of -1 to 255, with 0 to 255 being palette indexes and Picture.PIXEL_TRANSLUCENT being translucent pixels (if supported).

      For full-color graphics, the value is an ARGB integer value representing the pixel color in RGB space (with Alpha).

      Parameters:
      x - picture x-coordinate.
      y - picture y-coordinate.
      value - the value to set.
      Throws:
      IllegalArgumentException - if the value is outside a valid range.
      ArrayIndexOutOfBoundsException - if the provided coordinates is outside the graphic.
    • getPixelAlpha

      int getPixelAlpha(int x, int y)
      Gets a pixel's alpha value from 0 to 255.
      Parameters:
      x - picture x-coordinate.
      y - picture y-coordinate.
      Returns:
      a value from 0 to 255 representing no alpha to full opacity, respectively.
      Since:
      2.22.0
    • isOpaque

      default boolean isOpaque(int x, int y)
      Checks if a pixel in this graphic is opaque (not translucent - full alpha).
      Parameters:
      x - picture x-coordinate.
      y - picture y-coordinate.
      Returns:
      true if so, false if not.
      Since:
      2.22.0