Class PDColor
- java.lang.Object
-
- com.tom_roush.pdfbox.pdmodel.graphics.color.PDColor
-
public final class PDColor extends 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.
-
-
Constructor Summary
Constructors Constructor Description PDColor(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PDColorSpacegetColorSpace()Returns the color space in which this color value is defined.float[]getComponents()Returns the components of this color value.COSNamegetPatternName()Returns the pattern name from this color value.booleanisPattern()Returns true if this color value is a pattern.COSArraytoCOSArray()Returns the color component values as a COS arrayinttoRGB()Returns the packed RGB value for this color, if any.StringtoString()
-
-
-
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 valuecolorSpace- 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 valuescolorSpace- 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 dictionarycolorSpace- 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 valuespatternName- the name of a pattern in a pattern dictionarycolorSpace- 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
-
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 IOExceptionReturns 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
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.
-
-