# Color Class

> A color specified by values appropriate for its color space.

- Product: Adobe PDF Library 18
- Language: Java
- Version: APDFL18.0.5PlusP2e
- HTML page: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color
- Version index: https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/llms.txt

```java
class Color
```

**Namespace:** `com::datalogics::PDFL`

## Description

A color specified by values appropriate for its color space. The values that are offered range from 0 to 1.0 for red, green, and blue (RGB) or cyan, magenta, yellow, and black (CYMK).

**Referenced by:** [`Annotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Annotation.md), [`AxialShadingPattern`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/AxialShadingPattern.md), [`Bookmark`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Bookmark.md), [`CircleAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/CircleAnnotation.md), [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md), [`FreeTextAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/FreeTextAnnotation.md), [`GraphicState`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/GraphicState.md), [`HighlightAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/HighlightAnnotation.md), [`InkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/InkAnnotation.md), [`LineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LineAnnotation.md), [`LinkAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/LinkAnnotation.md), [`PolyLineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PolyLineAnnotation.md), [`PolygonAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/PolygonAnnotation.md), [`Redaction`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Redaction.md), [`ShadingPattern`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ShadingPattern.md), [`SquareAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/SquareAnnotation.md), [`Style`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Style.md), [`TextMarkupAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/TextMarkupAnnotation.md), [`UnderlineAnnotation`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/UnderlineAnnotation.md), [`WatermarkTextParams`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/WatermarkTextParams.md)

**Uses types:** [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md), [`ColorSpace`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ColorSpace.md), [`Pattern`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Pattern.md)

## Constructors

### Color

```java
com.datalogics.PDFL.Color.Color(ColorSpace colorSpace, java.util.List< Double > values)
```

*constructor*

**Parameters**

- `colorSpace` ([`ColorSpace`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ColorSpace.md)): the color space in which to create the color
- `values` (`java.util.List< Double >`): the values to place into the color

Create a new color in an arbitrary color space. The number of values passed must match the number of values in the color space.

### Color

```java
com.datalogics.PDFL.Color.Color(double c, double m, double y, double k)
```

*constructor*

**Parameters**

- `c` (`double`): the cyan color value for the new color (0.0 - 1.0)
- `m` (`double`): the magenta color value for the new color (0.0 - 1.0)
- `y` (`double`): the yellow color value for the new color (0.0 - 1.0)
- `k` (`double`): the black color value for the new color (0.0 - 1.0)

Create a new color in the DeviceCMYK colorspace with the specified value.

### Color

```java
com.datalogics.PDFL.Color.Color(double grey)
```

*constructor*

**Parameters**

- `grey` (`double`): the grayscale color value for the new color (0.0 - 1.0)

Create a new color in the DeviceGray colorspace with the specified value.

### Color

```java
com.datalogics.PDFL.Color.Color(double r, double g, double b)
```

*constructor*

**Parameters**

- `r` (`double`): the red color value for the new color (0.0 - 1.0)
- `g` (`double`): the green color value for the new color (0.0 - 1.0)
- `b` (`double`): the blue color value for the new color (0.0 - 1.0)

Create a new color in the DeviceRGB colorspace with the specified value.

### Color

```java
com.datalogics.PDFL.Color.Color(Pattern pattern)
```

*constructor*

**Parameters**

- `pattern` ([`Pattern`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Pattern.md)): The pattern to turn into a color

Create a new color in the pattern color space.

## Methods

### colorFromAWTColor

```java
static Color com.datalogics.PDFL.Color.colorFromAWTColor(java.awt.Color c)
```

*static*

**Parameters**

- `c` (`java.awt.Color`): the java.awt.Color object to use as a source

**Returns:** [`Color`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Color.md)

Create a Color from a standard java.awt.Color object.

### delete

```java
synchronized void com.datalogics.PDFL.Color.delete(Boolean disposing)
```

*protected*

**Parameters**

- `disposing` (`Boolean`)

**Returns:** `synchronized void`

### delete

```java
synchronized void com.datalogics.PDFL.Color.delete()
```

**Returns:** `synchronized void`

### equals

```java
boolean com.datalogics.PDFL.Color.equals(Object rhs)
```

**Parameters**

- `rhs` (`Object`)

**Returns:** `boolean`

### finalize

```java
void com.datalogics.PDFL.Color.finalize()
```

*protected*

**Returns:** `void`

### getPattern

```java
Pattern com.datalogics.PDFL.Color.getPattern()
```

**Returns:** [`Pattern`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/Pattern.md)

The Pattern associated with this color, or null if the color is not pattern-based.

The pattern of the color. Only valid for pattern-based colors.

### getSpace

```java
ColorSpace com.datalogics.PDFL.Color.getSpace()
```

**Returns:** [`ColorSpace`](https://docs.datalogics.com/apdfl18/Java/APDFL18.0.5PlusP2e/class/ColorSpace.md)

The ColorSpace that this color belongs to.

The color space of the color.

### getValue

```java
java.util.List< Double > com.datalogics.PDFL.Color.getValue()
```

**Returns:** `java.util.List< Double >`

A list of color component values, each ranging from 0.0 to 1.0.

The values of the color. Not valid for pattern-based colors.

### toString

```java
String com.datalogics.PDFL.Color.toString()
```

**Returns:** `String`

A string describing the color, including its color space and component values.

Returns a string representation of this Color.
