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
public class Color extends java.lang.ObjectRepresents a color
-
-
Field Summary
Fields Modifier and Type Field Description protected PdfColorSpacecolorSpaceThe color space of the colorprotected float[]colorValueThe color value of the color
-
Constructor Summary
Constructors Modifier Constructor Description protectedColor(PdfColorSpace colorSpace, float[] colorValue)Creates a Color of certain color space and color value.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DeviceRgbconvertCmykToRgb(DeviceCmyk cmykColor)ConvertsDeviceCmykcolor toDeviceRgbcolorstatic DeviceCmykconvertRgbToCmyk(DeviceRgb rgbColor)ConvertsDeviceRgbcolor toDeviceCmykcolorstatic ColorcreateColorWithColorSpace(float[] colorValue)Creates a color object based on the passed through values.booleanequals(java.lang.Object o)Indicates whether the color is equal to the given color.PdfColorSpacegetColorSpace()Returns thecolor spaceto which the color is related.float[]getColorValue()Returns the color value of the colorintgetNumberOfComponents()Returns the number of color value componentsinthashCode()static ColormakeColor(PdfColorSpace colorSpace)Makes a Color of certain color space.static ColormakeColor(PdfColorSpace colorSpace, float[] colorValue)Makes a Color of certain color space and color value.voidsetColorValue(float[] value)Sets the color value of the color
-
-
-
Field Detail
-
colorSpace
protected PdfColorSpace colorSpace
The color space of the color
-
colorValue
protected float[] colorValue
The color value of the color
-
-
Constructor Detail
-
Color
protected Color(PdfColorSpace colorSpace, float[] colorValue)
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 relatescolorValue- the color value of the created Color object
-
-
Method Detail
-
makeColor
public static Color makeColor(PdfColorSpace colorSpace)
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
public static Color makeColor(PdfColorSpace colorSpace, float[] colorValue)
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 relatescolorValue- the color value of the returned Color object- Returns:
- the created Color object.
-
convertCmykToRgb
public static DeviceRgb convertCmykToRgb(DeviceCmyk cmykColor)
ConvertsDeviceCmykcolor toDeviceRgbcolor- Parameters:
cmykColor- the DeviceCmyk color which will be converted to DeviceRgb color- Returns:
- converted color
-
convertRgbToCmyk
public static DeviceCmyk convertRgbToCmyk(DeviceRgb rgbColor)
ConvertsDeviceRgbcolor toDeviceCmykcolor- Parameters:
rgbColor- the DeviceRgb color which will be converted to DeviceCmyk color- Returns:
- converted color
-
createColorWithColorSpace
public static Color createColorWithColorSpace(float[] colorValue)
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
public PdfColorSpace getColorSpace()
Returns thecolor spaceto 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()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
Indicates whether the color is equal to the given color. Thecolor spaceandcolor valueare considered during the comparison.- Overrides:
equalsin classjava.lang.Object
-
-