Record Class TrayPicture

java.lang.Object
java.lang.Record
limn.backend.spi.TrayPicture
Record Components:
icon - the application's icon
badge - the dot's colour, or null for no dot
badgeAtLeft - whether the dot is at the top left corner and not the top right
frame - the frame of an animated icon to draw, from 0; 0 for a still one

public record TrayPicture(Icon icon, @Nullable Color badge, boolean badgeAtLeft, int frame) extends Record
A tray icon's picture at whatever size a system asks for: the application's icon, and the dot that says attention when it has one.

Two pictures are equal when they would draw the same thing, so a backend can tell a state that changed its picture from one that did not. An animated icon is played by the tray, which hands the peer a state for each frame as it falls due: a picture of the frame that changed is not equal to the one before, and is shown as any new picture is.

  • Constructor Summary

    Constructors
    Constructor
    Description
    TrayPicture(Icon icon, @Nullable Color badge, boolean badgeAtLeft, int frame)
    Checks the icon and the frame.
  • Method Summary

    Modifier and Type
    Method
    Description
    @Nullable Color
    Returns the value of the badge record component.
    boolean
    Returns the value of the badgeAtLeft record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    int
    Returns the value of the frame record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the icon record component.
    render(int pixelSize, @Nullable Color tint, boolean dark)
    Draws the picture into a square of pixelSize: the icon's frame fitted and centred, in tint when it is one that takes a colour and a tint is given, and the dot over it, which every frame carries.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • TrayPicture

      public TrayPicture(Icon icon, @Nullable Color badge, boolean badgeAtLeft, int frame)
      Checks the icon and the frame.
      Throws:
      IndexOutOfBoundsException - when the icon has no such frame
  • Method Details

    • render

      public Image render(int pixelSize, @Nullable Color tint, boolean dark)
      Draws the picture into a square of pixelSize: the icon's frame fitted and centred, in tint when it is one that takes a colour and a tint is given, and the dot over it, which every frame carries.
      Parameters:
      pixelSize - the square's side in device pixels, at least 1
      tint - the colour of a tintable icon, or null to leave it as it is
      dark - whether the surface behind is dark, for an icon with a light and a dark form
      Returns:
      the picture, straight alpha
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • icon

      public Icon icon()
      Returns the value of the icon record component.
      Returns:
      the value of the icon record component
    • badge

      public @Nullable Color badge()
      Returns the value of the badge record component.
      Returns:
      the value of the badge record component
    • badgeAtLeft

      public boolean badgeAtLeft()
      Returns the value of the badgeAtLeft record component.
      Returns:
      the value of the badgeAtLeft record component
    • frame

      public int frame()
      Returns the value of the frame record component.
      Returns:
      the value of the frame record component