Class RGBChannelNames

Object
RGBChannelNames

public class RGBChannelNames extends Object
Constants for referring to the channels in a RGB-stack or RGBA-stack.
Author:
Owen Feehan
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Name for the alpha channel.
    static final String
    Name for the blue channel.
    static final String
    Name for the green channel.
    static final String
    Name for the red channel.
  • Method Summary

    Modifier and Type
    Method
    Description
    static String[]
    asArray(boolean includeAlpha)
    Creates an array with all channel-names in R-G-B order.
    static List<String>
    asList(boolean includeAlpha)
    Creates a list with all channel-names in R-G-B order.
    static Set<String>
    asSet(boolean includeAlpha)
    Creates a set of the channel names.
    deriveIndex(String channelName)
    Derives the index of a channel for a channel name.
    static boolean
    isValidName(String channelName, boolean includeAlpha)
    Whether the channel-name is one of red, green, or blue, or alpha.
    static boolean
    isValidNameSet(Set<String> channelNames)
    Do the channel-names correspond exactly to those expected either RGB or RGBA.
    static boolean
    isValidNameSet(Set<String> channelNames, boolean includeAlpha)
    Do the channel-names correspond exactly to those expected for one of RGB or RGBA.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Method Details

    • asArray

      public static String[] asArray(boolean includeAlpha)
      Creates an array with all channel-names in R-G-B order.
      Parameters:
      includeAlpha - if true, the alpha channel is also accepted as valid. if false, it is not accepted.
      Returns:
      the array.
    • asList

      public static List<String> asList(boolean includeAlpha)
      Creates a list with all channel-names in R-G-B order.
      Parameters:
      includeAlpha - if true, the alpha channel is also accepted as valid. if false, it is not accepted.
      Returns:
      the list.
    • asSet

      public static Set<String> asSet(boolean includeAlpha)
      Creates a set of the channel names.
      Parameters:
      includeAlpha - if true, the alpha channel is also accepted as valid. if false, it is not accepted.
      Returns:
      the set.
    • deriveIndex

      public static Optional<Integer> deriveIndex(String channelName)
      Derives the index of a channel for a channel name.

      Names match only if lower-case.

      Parameters:
      channelName - the name of the channel
      Returns:
      0 for red, 1 for green, 2 for blue or Optional.empty() if name is anything else.
    • isValidName

      public static boolean isValidName(String channelName, boolean includeAlpha)
      Whether the channel-name is one of red, green, or blue, or alpha.

      Names match only if lower-case.

      Parameters:
      channelName - name to check if it is valid.
      includeAlpha - if true, the alpha channel is also accepted as valid. if false, it is not accepted.
      Returns:
      true iff channelName is red, green, or blue.
    • isValidNameSet

      public static boolean isValidNameSet(Set<String> channelNames)
      Do the channel-names correspond exactly to those expected either RGB or RGBA.
      Parameters:
      channelNames - the channel names to check.
      Returns:
      true if there are exactly the expected number of channel-names, and they correspond exactly to the expected names (which are lower-case).
    • isValidNameSet

      public static boolean isValidNameSet(Set<String> channelNames, boolean includeAlpha)
      Do the channel-names correspond exactly to those expected for one of RGB or RGBA.
      Parameters:
      channelNames - the channel names to check.
      includeAlpha - if true, expect RGBA. if false, expect RGB.
      Returns:
      true if there are exactly the expected number of channel-names, and they correspond exactly to the expected names (which are lower-case).