⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 spotcolorspace.java

📁 Java生成PDF Java生成PDF Java生成PDF
💻 JAVA
字号:
// $Id: SpotColorSpace.java,v 1.4 2005/07/29 11:32:50 mike Exp $package org.faceless.pdf;import java.awt.color.*;import java.awt.*;/** * <p> * A type of <tt>ColorSpace</tt> dealing with Separation ("Spot") Colors. * </p><p> * Spot colors are used to define an <i>exact</i> color in the printed * output. This is usually done by printing these colors using a matching * ink onto a separate film, ink which may be outside the gamut of the normal * CMYK printing process. Commonly used Spot colors include those from the * PANTONE&trade; and Focoltone&trade; range of colors. * </p><p> * Every Spot colorspace has a name, which is the name used by the printer * to identify the ink. Because not every output device may have the specified * ink available (displaying the PDF on screen for example), every Spot color * must have a "fallback" color specified as a process color (RGB or CMYK) * as well. Remembering that not every spot color can be reproduced in CMYK, * the fallback color is often just a close match. * </p><p> * Like normal colorspaces (RGB, CMYK and so on), different colors can be * specified within this space, although they will all be just a different * intensity  of the specified ink - ranging from zero (no ink is applied) * to one (the full intensity of the specified color is applied). * </p><p> * Here's an example showing how to use the PANTONE&trade; color "PANTONE * Reflex Blue" to print a line of text. * </p><pre> *   Color fallback = CYMKColorSpace.getColor(1.0, 0.72, 0, 0.06); *   SpotColorSpace blueink = new SpotColorSpace("PANTONE Reflex Blue CVC", fallback); *   Color logoblue = blueink.getColor(1); * *   PDFStyle style = new PDFStyle(); *   style.setFillColor(logoblue); *   page.setStyle(style); *   page.drawText("This is in PANTONE Reflex Blue CVC", 100, 100); * </pre><p> * Note the three stages. First we create the fallback color, specified in * CMYK. As it happens this spot color is outside the gamut of the CMYK * colorspace, so our fallback is an approximation only. Then we create the * colorspace, and finally we select a color which is this ink at 100% * intensity. From there we can just use the color as normal. * </p> * In the PDF specification Spot color is referred to as a "Separation" color. * </p> * @since 1.1.5 * @version $Revision: 1.4 $ */public class SpotColorSpace extends ColorSpace{    private org.faceless.pdf2.SpotColorSpace cspace;    private Color fallback;    /**     * Create a new SpotColorSpace representing a single custom ink.     * @param name the name of the ink     * @param color the color to use as a fallback color if this ink is     * not available. Must be from either an RGB, CMYK or Grayscale     * ColorSpace, or an <tt>IllegalArgumentException</tt> is thrown.     */    public SpotColorSpace(String name, Color color)    {	super(color.getColorSpace().getType(), 1);	cspace = new org.faceless.pdf2.SpotColorSpace(name, color);        this.fallback = fallback;    }    public float[] toCIEXYZ(float[] comp)    {	return cspace.toCIEXYZ(comp);    }    public float[] fromCIEXYZ(float[] comp)    {	return cspace.fromCIEXYZ(comp);    }    public float[] toRGB(float[] comp)    {	return cspace.toRGB(comp);    }    public float[] fromRGB(float[] comp)    {	return cspace.fromRGB(comp);    }    /**     * Get the name of this colorspace     */    public String getName()    {        return cspace.getName();    }    /**     * Get the fallback color to use if this ink is not available     */    public Color getFallbackColor()    {	return fallback;    }    /**     * A convenience method to return a color from this ColorSpace.     * @param amt the intensity of the color. Any value between zero and     * one, where zero means no ink at all and one means the full intensity.     * If the number is outside this range, an <tt>IllegalArgumentException</tt>     * is thrown     * @throws IllegalArgumentException     */    public Color getColor(float amt)    {	return cspace.getColor(amt);    }    /**     * A convenience method returning the color specified by the full intensity     * of this colorspace. Equivalent to <tt>getColor(1)</tt>.     */    public Color getColor()    {	return cspace.getColor();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -