Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.graphics.color

public final Class PDColor

extends Object
Class Inheritance
Imports
org.apache.pdfbox.cos.COSArray, .COSName, .COSNumber, .COSBase, java.io.IOException, java.util.Arrays, org.apache.commons.logging.Log, .LogFactory

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

Field Summary

Modifier and TypeField and Description
private final PDColorSpace
private final float[]
private static final Log
private final COSName

Constructor Summary

AccessConstructor and Description
public
PDColor(COSArray
a COS array containing the color value
array
,
PDColorSpace
color space in which the color value is defined
colorSpace
)

Creates a PDColor containing the given color value.

public
PDColor(float[]
array of color component values
components
,
PDColorSpace
color space in which the components are defined
colorSpace
)

Creates a PDColor containing the given color component values.

public
PDColor(COSName
the name of a pattern in a pattern dictionary
patternName
,
PDColorSpace
color space in which the pattern is defined
colorSpace
)

Creates a PDColor containing the given pattern name.

public
PDColor(float[]
array of color component values
components
,
COSName
the name of a pattern in a pattern dictionary
patternName
,
PDColorSpace
color space in which the pattern/components are defined
colorSpace
)

Creates a PDColor containing the given color component values and pattern name.

Method Summary

Modifier and TypeMethod and Description
public PDColorSpace

Returns:

the color space in which this color value is defined
getColorSpace
()

Returns the color space in which this color value is defined.

public float[]

Returns:

the components of this color value, never null.
getComponents
()

Returns the components of this color value.

public COSName

Returns:

the pattern name from this color value
getPatternName
()

Returns the pattern name from this color value.

private void
public boolean

Returns:

true if this color value is a pattern
isPattern
()

Returns true if this color value is a pattern.

public COSArray

Returns:

the color component values as a COS array
toCOSArray
()

Returns the color component values as a COS array

public int

Returns:

RGB
toRGB
()

Returns the packed RGB value for this color, if any.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

colorSpaceback to summary
private final PDColorSpace colorSpace
componentsback to summary
private final float[] components
LOGback to summary
private static final Log LOG
patternNameback to summary
private final COSName patternName

Constructor Detail

PDColorback to summary
public PDColor(COSArray array, PDColorSpace colorSpace)

Creates a PDColor containing the given color value.

Parameters
array:COSArray

a COS array containing the color value

colorSpace:PDColorSpace

color space in which the color value is defined

PDColorback to summary
public PDColor(float[] components, PDColorSpace colorSpace)

Creates a PDColor containing the given color component values.

Parameters
components:float[]

array of color component values

colorSpace:PDColorSpace

color space in which the components are defined

PDColorback to summary
public PDColor(COSName patternName, PDColorSpace colorSpace)

Creates a PDColor containing the given pattern name.

Parameters
patternName:COSName

the name of a pattern in a pattern dictionary

colorSpace:PDColorSpace

color space in which the pattern is defined

PDColorback to summary
public PDColor(float[] components, COSName patternName, PDColorSpace colorSpace)

Creates a PDColor containing the given color component values and pattern name.

Parameters
components:float[]

array of color component values

patternName:COSName

the name of a pattern in a pattern dictionary

colorSpace:PDColorSpace

color space in which the pattern/components are defined

Method Detail

getColorSpaceback to summary
public PDColorSpace getColorSpace()

Returns the color space in which this color value is defined.

Returns:PDColorSpace

the color space in which this color value is defined

getComponentsback to summary
public float[] getComponents()

Returns the components of this color value.

Returns:float[]

the components of this color value, never null.

getPatternNameback to summary
public COSName getPatternName()

Returns the pattern name from this color value.

Returns:COSName

the pattern name from this color value

initComponentsback to summary
private void initComponents(COSArray array)
isPatternback to summary
public boolean isPattern()

Returns true if this color value is a pattern.

Returns:boolean

true if this color value is a pattern

toCOSArrayback to summary
public COSArray toCOSArray()

Returns the color component values as a COS array

Returns:COSArray

the color component values as a COS array

toRGBback to summary
public int toRGB() throws IOException

Returns the packed RGB value for this color, if any.

Returns:int

RGB

Exceptions
IOException:
if the color conversion fails
UnsupportedOperationException:
if this color value is a pattern.
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override