Package org.faceless.pdf2
Class DeviceNColorSpace.Builder
- java.lang.Object
-
- org.faceless.pdf2.DeviceNColorSpace.Builder
-
- Enclosing class:
- DeviceNColorSpace
public static class DeviceNColorSpace.Builder extends Object
The Builder subclass allows the creation of a custom DeviceN ColorSpace, by specifying first the fallback ColorSpace, then the individual inks. For example, to create a linear gradient from "PANTONE Warm Red C" to "PANTONE Reflex Blue C", you could do the following:
DeviceNColorSpace.Builder builder = new DeviceNColorSpace(); builder.setFallback(CMYKColorSpace.getInstance()); builder.addInk("PANTONE Warm Red C", new float[] { 0, 0.75f, 0.9f, 0 }, 1); builder.addInk("PANTONE Reflex Blue C", new float[] { 1, 0.723f, 0, 0.02f }, 1); DeviceNColorSpace dn = builder.create(); Color red = new Color(dn, new float[] { 1, 0 }, 1); // 100% Warm Red Color blue = new Color(dn, new float[] { 0, 1 }, 1); // 100% Reflex Blue PDFStyle gradient = new PDFStyle(); gradient.setLineColor(Color.black); gradient.setFillColor(new GradientPaint(50, 100, red, 500, 100, blue)); page.setStyle(gradient); page.drawRectangle(50, 100, 500, 200);
The ColorSpace can theoretically be any space, but in practise should be a CMYK space, either
CMYKColorSpace
or anICCColorSpace
if you prefer. The blending will be unlikely to work as expected ifLabColorSpace
is used.- Since:
- 2.23.1
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addInk(String name, float[] comps, float gamma)
Add an ink to this ColorSpace.void
addInk(SpotColorSpace scs)
Add an ink to this ColorSpace.DeviceNColorSpace
create()
Create a DeviceNColorSpace from this buildervoid
setColorSpace(ColorSpace cs)
Set the ColorSpace which is used to define the inks.
-
-
-
Method Detail
-
setColorSpace
public void setColorSpace(ColorSpace cs)
Set the ColorSpace which is used to define the inks. This should normally be a CMYK based ColorSpace. This method must be called before any Inks are added.
-
addInk
public void addInk(SpotColorSpace scs)
Add an ink to this ColorSpace. The supplied SpotColorSpace must use the same fallback ColorSpace as this builder.- Parameters:
scs
- the SpotColorSpace defining the ink.- Since:
- 2.24.3
-
addInk
public void addInk(String name, float[] comps, float gamma)
Add an ink to this ColorSpace. The ink can be a spot color, it can be the name of one of the process colors that make up the ColorSpace for this object, or it can be the string "None" - which is the only name that doesn't have to be unique.- Parameters:
name
- the name of the ink, eg "PANTONE Warm Red C"comps
- the components in this builder's ColorSpace that define that ink.gamma
- the gamma value. Currently this must be always be one.
-
create
public DeviceNColorSpace create()
Create a DeviceNColorSpace from this builder
-
-