Package com.itextpdf.kernel.colors
Class Color
java.lang.Object
com.itextpdf.kernel.colors.Color
- Direct Known Subclasses:
-
CalGray
,CalRgb
,DeviceCmyk
,DeviceGray
,DeviceN
,DeviceRgb
,IccBased
,Indexed
,Lab
,PatternColor
,Separation
Represents a color
-
Field Summary
Modifier and TypeFieldDescriptionprotected PdfColorSpace
The color space of the colorprotected float[]
The color value of the color -
Constructor Summary
ModifierConstructorDescriptionprotected
Color
(PdfColorSpace colorSpace, float[] colorValue) Creates a Color of certain color space and color value. -
Method Summary
Modifier and TypeMethodDescriptionstatic DeviceRgb
convertCmykToRgb
(DeviceCmyk cmykColor) ConvertsDeviceCmyk
color toDeviceRgb
colorstatic DeviceCmyk
convertRgbToCmyk
(DeviceRgb rgbColor) ConvertsDeviceRgb
color toDeviceCmyk
colorstatic Color
createColorWithColorSpace
(float[] colorValue) Creates a color object based on the passed through values.boolean
Indicates whether the color is equal to the given color.Returns thecolor space
to which the color is related.float[]
Returns the color value of the colorint
Returns the number of color value componentsint
hashCode()
static Color
makeColor
(PdfColorSpace colorSpace) Makes a Color of certain color space.static Color
makeColor
(PdfColorSpace colorSpace, float[] colorValue) Makes a Color of certain color space and color value.void
setColorValue
(float[] value) Sets the color value of the color
-
Field Details
-
colorSpace
The color space of the color -
colorValue
protected float[] colorValueThe color value of the color
-
-
Constructor Details
-
Color
Creates a Color of certain color space and color value. If color value is set in null, all value components will be initialised with zeroes.- Parameters:
-
colorSpace
- the color space to which the created Color object relates -
colorValue
- the color value of the created Color object
-
-
Method Details
-
makeColor
Makes a Color of certain color space. All color value components will be initialised with zeroes.- Parameters:
-
colorSpace
- the color space to which the returned Color object relates - Returns:
- the created Color object.
-
makeColor
Makes a Color of certain color space and color value. If color value is set in null, all value components will be initialised with zeroes.- Parameters:
-
colorSpace
- the color space to which the returned Color object relates -
colorValue
- the color value of the returned Color object - Returns:
- the created Color object.
-
convertCmykToRgb
ConvertsDeviceCmyk
color toDeviceRgb
color- Parameters:
-
cmykColor
- the DeviceCmyk color which will be converted to DeviceRgb color - Returns:
- converted color
-
convertRgbToCmyk
ConvertsDeviceRgb
color toDeviceCmyk
color- Parameters:
-
rgbColor
- the DeviceRgb color which will be converted to DeviceCmyk color - Returns:
- converted color
-
createColorWithColorSpace
Creates a color object based on the passed through values.- Parameters:
-
colorValue
- the float array with the valuesThe number of array elements determines the colour space in which the colour shall be defined: 0 - No colour; transparent 1 - DeviceGray 3 - DeviceRGB 4 - DeviceCMYK
- Returns:
- Color the color or null if it's invalid
-
getNumberOfComponents
public int getNumberOfComponents()Returns the number of color value components- Returns:
- the number of color value components
-
getColorSpace
Returns thecolor space
to which the color is related.- Returns:
- the color space of the color
-
getColorValue
public float[] getColorValue()Returns the color value of the color- Returns:
- the color value
-
setColorValue
public void setColorValue(float[] value) Sets the color value of the color- Parameters:
-
value
- new color value
-
hashCode
public int hashCode() -
equals
Indicates whether the color is equal to the given color. Thecolor space
andcolor value
are considered during the comparison.
-