Class Color

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Color extends ProxyInstance
The PangoColor structure is used to represent a color in an uncalibrated RGB color-space.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Allocate a new Color.
    Color(short red, short green, short blue)
    Allocate a new Color with the fields set to the provided values.
    Color(short red, short green, short blue, Arena arena)
    Allocate a new Color with the fields set to the provided values.
    Color(Arena arena)
    Allocate a new Color.
    Create a Color proxy instance for the provided memory address.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Color
    Creates a copy of src.
    void
    Frees a color allocated by copy().
    The memory layout of the native struct.
    static @Nullable Type
    Get the GType of the Color class.
    boolean
    parse(String spec)
    Fill in the fields of a color from a string specification.
    boolean
    parseWithAlpha(@Nullable Out<Short> alpha, String spec)
    Fill in the fields of a color from a string specification.
    short
    Read the value of the field blue.
    short
    Read the value of the field green.
    short
    Read the value of the field red.
    Returns a textual specification of color.
    void
    writeBlue(short blue)
    Write a value in the field blue.
    void
    writeGreen(short green)
    Write a value in the field green.
    void
    writeRed(short red)
    Write a value in the field red.

    Methods inherited from class ProxyInstance

    equals, handle, hashCode

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Color

      public Color(MemorySegment address)
      Create a Color proxy instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Color

      public Color(Arena arena)
      Allocate a new Color.
      Parameters:
      arena - to control the memory allocation scope
    • Color

      public Color()
      Allocate a new Color. The memory is allocated with Arena.ofAuto().
    • Color

      public Color(short red, short green, short blue, Arena arena)
      Allocate a new Color with the fields set to the provided values.
      Parameters:
      red - value for the field red
      green - value for the field green
      blue - value for the field blue
      arena - to control the memory allocation scope
    • Color

      public Color(short red, short green, short blue)
      Allocate a new Color with the fields set to the provided values. The memory is allocated with Arena.ofAuto().
      Parameters:
      red - value for the field red
      green - value for the field green
      blue - value for the field blue
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Color class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • readRed

      public short readRed()
      Read the value of the field red.
      Returns:
      The value of the field red
    • writeRed

      public void writeRed(short red)
      Write a value in the field red.
      Parameters:
      red - The new value for the field red
    • readGreen

      public short readGreen()
      Read the value of the field green.
      Returns:
      The value of the field green
    • writeGreen

      public void writeGreen(short green)
      Write a value in the field green.
      Parameters:
      green - The new value for the field green
    • readBlue

      public short readBlue()
      Read the value of the field blue.
      Returns:
      The value of the field blue
    • writeBlue

      public void writeBlue(short blue)
      Write a value in the field blue.
      Parameters:
      blue - The new value for the field blue
    • copy

      public @Nullable Color copy()

      Creates a copy of src.

      The copy should be freed with free(). Primarily used by language bindings, not that useful otherwise (since colors can just be copied by assignment in C).

      Returns:
      the newly allocated PangoColor, which should be freed with free()
    • free

      public void free()
      Frees a color allocated by copy().
    • parse

      public boolean parse(String spec)

      Fill in the fields of a color from a string specification.

      The string can either one of a large set of standard names. (Taken from the CSS Color specification, or it can be a value in the form #rgb, #rrggbb, #rrrgggbbb or #rrrrggggbbbb, where r, g and b are hex digits of the red, green, and blue components of the color, respectively. (White in the four forms is #fff, #ffffff, #fffffffff and #ffffffffffff.)

      Parameters:
      spec - a string specifying the new color
      Returns:
      true if parsing of the specifier succeeded, otherwise false
    • parseWithAlpha

      public boolean parseWithAlpha(@Nullable Out<Short> alpha, String spec)

      Fill in the fields of a color from a string specification.

      The string can either one of a large set of standard names. (Taken from the CSS Color specification, or it can be a hexadecimal value in the form #rgb, #rrggbb, #rrrgggbbb or #rrrrggggbbbb where r, g and b are hex digits of the red, green, and blue components of the color, respectively. (White in the four forms is #fff, #ffffff, #fffffffff and #ffffffffffff.)

      Additionally, parse strings of the form #rgba, #rrggbbaa, #rrrrggggbbbbaaaa, if alpha is not null, and set alpha to the value specified by the hex digits for a. If no alpha component is found in spec, alpha is set to 0xffff (for a solid color).

      Parameters:
      alpha - return location for alpha
      spec - a string specifying the new color
      Returns:
      true if parsing of the specifier succeeded, otherwise false
      Since:
      1.46
    • toString

      public String toString()

      Returns a textual specification of color.

      The string is in the hexadecimal form #rrrrggggbbbb, where r, g and b are hex digits representing the red, green, and blue components respectively.

      Overrides:
      toString in class Object
      Returns:
      a newly-allocated text string that must be freed with g_free().
      Since:
      1.16