Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.fop.pdf
Class PDFColor

    java.lang.Object
      org.apache.fop.pdf.PDFObject
          org.apache.fop.pdf.PDFPathPaint
              org.apache.fop.pdf.PDFColor

All Implemented Interfaces:
  PDFWritable

    public class PDFColor

extends PDFPathPaint

PDF Color object. It is currently only used to hold the transparent color of a masked bitmap image. And in this context, only RGB and Gray values are used.

Use of this class is discouraged. `PDFColorHandler` is now used for in-content color selection. For masked bitmaps, it may be wiser to switch to `Color` in the long run.

Field Summary

Fields inherited from class org.apache.fop.pdf.PDFPathPaint
`colorSpace`

Fields inherited from class org.apache.fop.pdf.PDFObject
`log`

Constructor Summary
`PDFColor(java.awt.Color col)` Create a PDF color from a java.awt.Color object.
`PDFColor(double theRed, double theGreen, double theBlue)` Create a PDF color with double values ranging from 0 to 1.
`PDFColor(double theCyan, double theMagenta, double theYellow, double theBlack)` Create a PDF color with CMYK values.
`PDFColor(int theRed, int theGreen, int theBlue)` Create a PDF color with int values ranging from 0 to 255

Method Summary
`double` | `black()` Get the black component.
`double` | `blue()` Get the blue component.
`int` | `blue255()` Get the blue integer component.
`protected boolean` | `contentEquals(PDFObject obj)` Check if the other PDFObject has the same content as the current object.
`protected void` | `convertCMYKtoGRAY()` Convert the color from CMYK to Gray.
`protected void` | `convertCMYKtoRGB()` Convert the color from CMYK to RGB.
`protected void` | `convertGRAYtoCMYK()` Convert the color from Gray to CMYK.
`protected void` | `convertGRAYtoRGB()` Convert the color from Gray to RGB.
`protected void` | `convertRGBtoCMYK()` Convert the color from RGB to CMYK.
`protected void` | `convertRGBtoGRAY()` Convert the color from RGB to Gray.
`double` | `cyan()` Get the cyan component.
`java.lang.String` | `getColorSpaceOut(boolean fillNotStroke)` Get the PDF output string for this color.
`java.util.List` | `getVector()` Return a vector representation of the color in the appropriate colorspace.
`double` | `green()` Get the green component.
`int` | `green255()` Get the green integer component.
`double` | `magenta()` Get the magenta component.
`double` | `red()` Get the red component.
`int` | `red255()` Get the red integer component.
`void` | `setColorSpace(int theColorSpace)` Set the color space for this color.
`byte[]` | `toPDF()` Create pdf.
`double` | `yellow()` Get the yellow component.

Methods inherited from class org.apache.fop.pdf.PDFPathPaint
`getColorSpace`

Methods inherited from class org.apache.fop.pdf.PDFObject
`encode, encodeBinaryToHexString, encodeString, encodeText, formatObject, getChildren, getDocument, getDocumentSafely, getGeneration, getObjectID, getObjectNumber, getParent, hasObjectNumber, makeReference, output, outputInline, referencePDF, setDocument, setObjectNumber, setObjectNumber, setObjectNumber, setParent, toPDFString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PDFColor

    public PDFColor(double theRed,
                    double theGreen,
                    double theBlue)

  Create a PDF color with double values ranging from 0 to 1.

  Parameters:
    `theRed` - the red double value
    `theGreen` - the green double value
    `theBlue` - the blue double value

### PDFColor

    public PDFColor(java.awt.Color col)

  Create a PDF color from a java.awt.Color object. Different Color objects are handled differently. Cases recognized are. 1. CMYK color 3. 'Normal' java.awt.Color (RGB case assumed or implicit conversion to sRGB)

  Parameters:
    `col` - the java.awt.Color object for which to create a PDFColor object

### PDFColor

    public PDFColor(int theRed,
                    int theGreen,
                    int theBlue)

  Create a PDF color with int values ranging from 0 to 255

  Parameters:
    `theRed` - the red integer value
    `theGreen` - the green integer value
    `theBlue` - the blue integer value

### PDFColor

    public PDFColor(double theCyan,
                    double theMagenta,
                    double theYellow,
                    double theBlack)

  Create a PDF color with CMYK values.

  Parameters:
    `theCyan` - the cyan value
    `theMagenta` - the magenta value
    `theYellow` - the yellow value
    `theBlack` - the black value

Method Detail

### getVector

    public java.util.List getVector()

  Return a vector representation of the color in the appropriate colorspace.

  Returns:
    a list containing the Double values of the color

### red

    public double red()

  Get the red component.

  Returns:
    the red double value

### green

    public double green()

  Get the green component.

  Returns:
    the green double value

### blue

    public double blue()

  Get the blue component.

  Returns:
    the blue double value

### red255

    public int red255()

  Get the red integer component.

  Returns:
    the red integer value

### green255

    public int green255()

  Get the green integer component.

  Returns:
    the green integer value

### blue255

    public int blue255()

  Get the blue integer component.

  Returns:
    the blue integer value

### cyan

    public double cyan()

  Get the cyan component.

  Returns:
    the cyan double value

### magenta

    public double magenta()

  Get the magenta component.

  Returns:
    the magenta double value

### yellow

    public double yellow()

  Get the yellow component.

  Returns:
    the yellow double value

### black

    public double black()

  Get the black component.

  Returns:
    the black double value

### setColorSpace

    public void setColorSpace(int theColorSpace)

  Set the color space for this color. If the new color space is different the values are converted to the new color space.

  Overrides:
    `setColorSpace` in class `PDFPathPaint`
  Parameters:
    `theColorSpace` - the new color space

### getColorSpaceOut

    public java.lang.String getColorSpaceOut(boolean fillNotStroke)

  Get the PDF output string for this color. This returns the string to be inserted into PDF for setting the current color.

  Overrides:
    `getColorSpaceOut` in class `PDFPathPaint`
  Parameters:
    `fillNotStroke` - whether to return fill or stroke command
  Returns:
    the PDF string for setting the fill/stroke color

### convertCMYKtoRGB

    protected void convertCMYKtoRGB()

  Convert the color from CMYK to RGB.

### convertRGBtoCMYK

    protected void convertRGBtoCMYK()

  Convert the color from RGB to CMYK.

### convertGRAYtoRGB

    protected void convertGRAYtoRGB()

  Convert the color from Gray to RGB.

### convertGRAYtoCMYK

    protected void convertGRAYtoCMYK()

  Convert the color from Gray to CMYK.

### convertCMYKtoGRAY

    protected void convertCMYKtoGRAY()

  Convert the color from CMYK to Gray.

### convertRGBtoGRAY

    protected void convertRGBtoGRAY()

  Convert the color from RGB to Gray.

### toPDF

    public byte[] toPDF()

  Create pdf. Not used for this object.

  Overrides:
    `toPDF` in class `PDFObject`
  Returns:
    the bytes for the pdf

### contentEquals

    protected boolean contentEquals(PDFObject obj)

  Check if the other PDFObject has the same content as the current object.

  Note: This function has a contract which is less binding than `Object.equals(Object)`. Whereas equals would require all values to be identical, this method is not required to check everything. In the case of PDFObjects, this means that the overriding function does not have to check for `PDFObject.getObjectID()`.

  Overrides:
    `contentEquals` in class `PDFObject`
  Parameters:
    `obj` - object to compare to.
  Returns:
    true if the other object has the same content.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| fop 2.1
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright 1999-2016 The Apache Software Foundation. All Rights Reserved.