Class PDColor


  • public final class PDColor
    extends java.lang.Object
    A color value, consisting of one or more color components, or for pattern color spaces, a name and optional color components. Color values are not associated with any given color space. Instances of PDColor are immutable.
    • Field Detail

      • components

        private final float[] components
      • patternName

        private final COSName patternName
    • Constructor Detail

      • PDColor

        public PDColor​(COSArray array,
                       PDColorSpace colorSpace)
        Creates a PDColor containing the given color value.
        Parameters:
        array - a COS array containing the color value
        colorSpace - color space in which the color value is defined
      • PDColor

        public PDColor​(float[] components,
                       PDColorSpace colorSpace)
        Creates a PDColor containing the given color component values.
        Parameters:
        components - array of color component values
        colorSpace - color space in which the components are defined
      • PDColor

        public PDColor​(COSName patternName,
                       PDColorSpace colorSpace)
        Creates a PDColor containing the given pattern name.
        Parameters:
        patternName - the name of a pattern in a pattern dictionary
        colorSpace - color space in which the pattern is defined
      • PDColor

        public PDColor​(float[] components,
                       COSName patternName,
                       PDColorSpace colorSpace)
        Creates a PDColor containing the given color component values and pattern name.
        Parameters:
        components - array of color component values
        patternName - the name of a pattern in a pattern dictionary
        colorSpace - color space in which the pattern/components are defined
    • Method Detail

      • getComponents

        public float[] getComponents()
        Returns the components of this color value.
        Returns:
        the components of this color value, never null.
      • getPatternName

        public COSName getPatternName()
        Returns the pattern name from this color value.
        Returns:
        the pattern name from this color value
      • isPattern

        public boolean isPattern()
        Returns true if this color value is a pattern.
        Returns:
        true if this color value is a pattern
      • toRGB

        public int toRGB()
                  throws java.io.IOException
        Returns the packed RGB value for this color, if any.
        Returns:
        RGB
        Throws:
        java.io.IOException - if the color conversion fails
        java.lang.IllegalStateException - if this color value is a pattern.
      • toCOSArray

        public COSArray toCOSArray()
        Returns the color component values as a COS array
        Returns:
        the color component values as a COS array
      • getColorSpace

        public PDColorSpace getColorSpace()
        Returns the color space in which this color value is defined.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object