Class PDIndexed
- java.lang.Object
-
- org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
-
- org.apache.pdfbox.pdmodel.graphics.color.PDIndexed
-
- All Implemented Interfaces:
COSObjectable
public class PDIndexed extends PDColorSpace
This class represents an Indexed color space.- Author:
- Ben Litchfield
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringABBREVIATED_NAMEThe abbreviated name of this color space.static java.lang.StringNAMEThe name of this color space.-
Fields inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
array
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float[]calculateColorValues(int index)Returns the components of the color for the given index.java.awt.image.ColorModelcreateColorModel(int bpc)Create a Java color model for this colorspace.java.awt.image.ColorModelcreateColorModel(int bpc, int mask)Create a Java color model for this colorspace including the given mask value.protected java.awt.color.ColorSpacecreateColorSpace()Create a Java colorspace for this colorspace.PDColorSpacegetBaseColorSpace()This will get the color space that acts as the index for this color space.COSBasegetCOSObject()Convert this standard java object to a COS object.intgetHighValue()Get the highest value for the lookup.byte[]getLookupData()Get the lookup data table.java.lang.StringgetName()This will return the name of the color space.intgetNumberOfComponents()This will return the number of color components.intlookupColor(int lookupIndex, int componentNumber)This will perform a lookup into the color lookup table.voidsetBaseColorSpace(PDColorSpace base)This will set the base color space.voidsetHighValue(int high)This will set the highest value that is allowed.voidsetLookupColor(int lookupIndex, int componentNumber, int color)This will set a color in the color lookup table.-
Methods inherited from class org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace
getJavaColorSpace, toString
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
The name of this color space.- See Also:
- Constant Field Values
-
ABBREVIATED_NAME
public static final java.lang.String ABBREVIATED_NAME
The abbreviated name of this color space.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PDIndexed
public PDIndexed()
Constructor, default DeviceRGB, hival 255.
-
PDIndexed
public PDIndexed(COSArray indexedArray)
Constructor.- Parameters:
indexedArray- The array containing the indexed parameters
-
-
Method Detail
-
getCOSObject
public COSBase getCOSObject()
Description copied from class:PDColorSpaceConvert this standard java object to a COS object.- Specified by:
getCOSObjectin interfaceCOSObjectable- Overrides:
getCOSObjectin classPDColorSpace- Returns:
- The cos object that matches this Java object.
-
getNumberOfComponents
public int getNumberOfComponents() throws java.io.IOExceptionThis will return the number of color components. This will return the number of color components in the base color.- Specified by:
getNumberOfComponentsin classPDColorSpace- Returns:
- The number of components in this color space.
- Throws:
java.io.IOException- If there is an error getting the number of color components.
-
getName
public java.lang.String getName()
This will return the name of the color space.- Specified by:
getNamein classPDColorSpace- Returns:
- The name of the color space.
-
createColorSpace
protected java.awt.color.ColorSpace createColorSpace() throws java.io.IOExceptionCreate a Java colorspace for this colorspace.- Specified by:
createColorSpacein classPDColorSpace- Returns:
- A color space that can be used for Java AWT operations.
- Throws:
java.io.IOException- If there is an error creating the color space.
-
createColorModel
public java.awt.image.ColorModel createColorModel(int bpc) throws java.io.IOExceptionCreate a Java color model for this colorspace.- Specified by:
createColorModelin classPDColorSpace- Parameters:
bpc- The number of bits per component.- Returns:
- A color model that can be used for Java AWT operations.
- Throws:
java.io.IOException- If there is an error creating the color model.
-
createColorModel
public java.awt.image.ColorModel createColorModel(int bpc, int mask) throws java.io.IOExceptionCreate a Java color model for this colorspace including the given mask value.- Parameters:
bpc- The number of bits per component of the indexed color model.mask- the mask value, -1 indicates no mask- Returns:
- A color model that can be used for Java AWT operations.
- Throws:
java.io.IOException- If there is an error creating the color model.
-
getBaseColorSpace
public PDColorSpace getBaseColorSpace() throws java.io.IOException
This will get the color space that acts as the index for this color space.- Returns:
- The base color space.
- Throws:
java.io.IOException- If there is error creating the base color space.
-
setBaseColorSpace
public void setBaseColorSpace(PDColorSpace base)
This will set the base color space.- Parameters:
base- The base color space to use as the index.
-
getHighValue
public int getHighValue()
Get the highest value for the lookup.- Returns:
- The hival entry.
-
setHighValue
public void setHighValue(int high)
This will set the highest value that is allowed. This cannot be higher than 255.- Parameters:
high- The highest value for the lookup table.
-
lookupColor
public int lookupColor(int lookupIndex, int componentNumber) throws java.io.IOExceptionThis will perform a lookup into the color lookup table.- Parameters:
lookupIndex- The zero-based index into the table, should not exceed the high value.componentNumber- The component number, probably 1,2,3,3.- Returns:
- The value that was from the lookup table.
- Throws:
java.io.IOException- If there is an error looking up the color.
-
getLookupData
public byte[] getLookupData() throws java.io.IOExceptionGet the lookup data table.- Returns:
- a byte array containing the lookup data.
- Throws:
java.io.IOException- if an error occurs.
-
setLookupColor
public void setLookupColor(int lookupIndex, int componentNumber, int color) throws java.io.IOExceptionThis will set a color in the color lookup table.- Parameters:
lookupIndex- The zero-based index into the table, should not exceed the high value.componentNumber- The component number, probably 1,2,3,3.color- The color that will go into the table.- Throws:
java.io.IOException- If there is an error looking up the color.
-
calculateColorValues
public float[] calculateColorValues(int index) throws java.io.IOExceptionReturns the components of the color for the given index.- Parameters:
index- the index of the color value- Returns:
- COSArray with the color components
- Throws:
java.io.IOException- If the tint function is not supported
-
-