Class PDColor
java.lang.Object
org.apache.pdfbox.pdmodel.graphics.color.PDColor
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.
- Author:
- John Hewson
-
Constructor Summary
ConstructorsConstructorDescriptionPDColor
(float[] components, COSName patternName, PDColorSpace colorSpace) Creates a PDColor containing the given color component values and pattern name.PDColor
(float[] components, PDColorSpace colorSpace) Creates a PDColor containing the given color component values.PDColor
(COSArray array, PDColorSpace colorSpace) Creates a PDColor containing the given color value.PDColor
(COSName patternName, PDColorSpace colorSpace) Creates a PDColor containing the given pattern name. -
Method Summary
Modifier and TypeMethodDescriptionReturns the color space in which this color value is defined.float[]
Returns the components of this color value.Returns the pattern name from this color value.boolean
Returns true if this color value is a pattern.Returns the color component values as a COS arrayint
toRGB()
Returns the packed RGB value for this color, if any.toString()
-
Constructor Details
-
PDColor
Creates a PDColor containing the given color value.- Parameters:
array
- a COS array containing the color valuecolorSpace
- color space in which the color value is defined
-
PDColor
Creates a PDColor containing the given color component values.- Parameters:
components
- array of color component valuescolorSpace
- color space in which the components are defined
-
PDColor
Creates a PDColor containing the given pattern name.- Parameters:
patternName
- the name of a pattern in a pattern dictionarycolorSpace
- color space in which the pattern is defined
-
PDColor
Creates a PDColor containing the given color component values and pattern name.- Parameters:
components
- array of color component valuespatternName
- the name of a pattern in a pattern dictionarycolorSpace
- color space in which the pattern/components are defined
-
-
Method Details
-
getComponents
public float[] getComponents()Returns the components of this color value.- Returns:
- the components of this color value, never null.
-
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
Returns the packed RGB value for this color, if any.- Returns:
- RGB
- Throws:
IOException
- if the color conversion failsIllegalStateException
- if this color value is a pattern.
-
toCOSArray
Returns the color component values as a COS array- Returns:
- the color component values as a COS array
-
getColorSpace
Returns the color space in which this color value is defined. -
toString
-