Package com.sun.pdfview.colorspace
Class IndexedColor
- java.lang.Object
-
- com.sun.pdfview.colorspace.PDFColorSpace
-
- com.sun.pdfview.colorspace.IndexedColor
-
public class IndexedColor extends PDFColorSpace
A PDFColorSpace for an IndexedColor model
-
-
Field Summary
Fields Modifier and Type Field Description (package private) int
count
size of the color tableprotected byte[]
finalcolors
r,g,and b components of the color table as a single array, for Java's IndexColorModel(package private) int
nchannels
number of channels in the base Color Space (unused)(package private) java.awt.Color[]
table
the color table-
Fields inherited from class com.sun.pdfview.colorspace.PDFColorSpace
COLORSPACE_CMYK, COLORSPACE_GRAY, COLORSPACE_PATTERN, COLORSPACE_RGB, cs
-
-
Constructor Summary
Constructors Constructor Description IndexedColor(PDFColorSpace base, int count, PDFObject stream)
create a new IndexColor PDFColorSpace based on another PDFColorSpace, a count of colors, and a stream of values.IndexedColor(java.awt.Color[] table)
create a new IndexColor PDFColorSpace based on a table of colors.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getColorComponents()
Get the table of color componentsint
getCount()
Get the number of indicesint
getNumComponents()
get the number of components of this colorspace (1)PDFPaint
getPaint(float[] components)
get the color represented by the index.-
Methods inherited from class com.sun.pdfview.colorspace.PDFColorSpace
getColorSpace, getColorSpace, getColorSpace
-
-
-
-
Field Detail
-
finalcolors
protected byte[] finalcolors
r,g,and b components of the color table as a single array, for Java's IndexColorModel
-
table
java.awt.Color[] table
the color table
-
count
int count
size of the color table
-
nchannels
int nchannels
number of channels in the base Color Space (unused)
-
-
Constructor Detail
-
IndexedColor
public IndexedColor(PDFColorSpace base, int count, PDFObject stream) throws java.io.IOException
create a new IndexColor PDFColorSpace based on another PDFColorSpace, a count of colors, and a stream of values. Every consecutive n bytes of the stream is interpreted as a color in the base ColorSpace, where n is the number of components in that color space.- Parameters:
base
- the color space in which the data is interpretedcount
- the number of colors in the tablestream
- a stream of bytes. The number of bytes must be count*n, where n is the number of components in the base colorspace.- Throws:
java.io.IOException
-
IndexedColor
public IndexedColor(java.awt.Color[] table) throws java.io.IOException
create a new IndexColor PDFColorSpace based on a table of colors.- Parameters:
table
- an array of colors- Throws:
java.io.IOException
-
-
Method Detail
-
getCount
public int getCount()
Get the number of indices
-
getColorComponents
public byte[] getColorComponents()
Get the table of color components
-
getNumComponents
public int getNumComponents()
get the number of components of this colorspace (1)- Overrides:
getNumComponents
in classPDFColorSpace
-
getPaint
public PDFPaint getPaint(float[] components)
get the color represented by the index.- Overrides:
getPaint
in classPDFColorSpace
- Parameters:
components
- an array of exactly one integer number whose value is between 0 and the size of the color table - 1.- Returns:
- a PDFPaint object representing the closest Color to the given components.
-
-