001/*
002 * $Id: PdfGState.java 4784 2011-03-15 08:33:00Z blowagie $
003 *
004 * This file is part of the iText (R) project.
005 * Copyright (c) 1998-2011 1T3XT BVBA
006 * Authors: Bruno Lowagie, Paulo Soares, et al.
007 *
008 * This program is free software; you can redistribute it and/or modify
009 * it under the terms of the GNU Affero General Public License version 3
010 * as published by the Free Software Foundation with the addition of the
011 * following permission added to Section 15 as permitted in Section 7(a):
012 * FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS OWNED BY 1T3XT,
013 * 1T3XT DISCLAIMS THE WARRANTY OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
014 *
015 * This program is distributed in the hope that it will be useful, but
016 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
017 * or FITNESS FOR A PARTICULAR PURPOSE.
018 * See the GNU Affero General Public License for more details.
019 * You should have received a copy of the GNU Affero General Public License
020 * along with this program; if not, see http://www.gnu.org/licenses or write to
021 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
022 * Boston, MA, 02110-1301 USA, or download the license from the following URL:
023 * http://itextpdf.com/terms-of-use/
024 *
025 * The interactive user interfaces in modified source and object code versions
026 * of this program must display Appropriate Legal Notices, as required under
027 * Section 5 of the GNU Affero General Public License.
028 *
029 * In accordance with Section 7(b) of the GNU Affero General Public License,
030 * a covered work must retain the producer line in every PDF that is created
031 * or manipulated using iText.
032 *
033 * You can be released from the requirements of the license by purchasing
034 * a commercial license. Buying such a license is mandatory as soon as you
035 * develop commercial activities involving the iText software without
036 * disclosing the source code of your own applications.
037 * These activities include: offering paid services to customers as an ASP,
038 * serving PDFs on the fly in a web application, shipping iText with a closed
039 * source product.
040 *
041 * For more information, please contact iText Software Corp. at this
042 * address: sales@itextpdf.com
043 */
044package com.itextpdf.text.pdf;
045
046/** The graphic state dictionary.
047 *
048 * @author Paulo Soares
049 */
050public class PdfGState extends PdfDictionary {
051    /** A possible blend mode */
052    public static final PdfName BM_NORMAL = new PdfName("Normal");
053    /** A possible blend mode */
054    public static final PdfName BM_COMPATIBLE = new PdfName("Compatible");
055    /** A possible blend mode */
056    public static final PdfName BM_MULTIPLY = new PdfName("Multiply");
057    /** A possible blend mode */
058    public static final PdfName BM_SCREEN = new PdfName("Screen");
059    /** A possible blend mode */
060    public static final PdfName BM_OVERLAY = new PdfName("Overlay");
061    /** A possible blend mode */
062    public static final PdfName BM_DARKEN = new PdfName("Darken");
063    /** A possible blend mode */
064    public static final PdfName BM_LIGHTEN = new PdfName("Lighten");
065    /** A possible blend mode */
066    public static final PdfName BM_COLORDODGE = new PdfName("ColorDodge");
067    /** A possible blend mode */
068    public static final PdfName BM_COLORBURN = new PdfName("ColorBurn");
069    /** A possible blend mode */
070    public static final PdfName BM_HARDLIGHT = new PdfName("HardLight");
071    /** A possible blend mode */
072    public static final PdfName BM_SOFTLIGHT = new PdfName("SoftLight");
073    /** A possible blend mode */
074    public static final PdfName BM_DIFFERENCE = new PdfName("Difference");
075    /** A possible blend mode */
076    public static final PdfName BM_EXCLUSION = new PdfName("Exclusion");
077    
078    /**
079     * Sets the flag whether to apply overprint for stroking.
080     * @param ov
081     */
082    public void setOverPrintStroking(boolean ov) {
083        put(PdfName.OP, ov ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE);
084    }
085
086    /**
087     * Sets the flag whether to apply overprint for non stroking painting operations.
088     * @param ov
089     */
090    public void setOverPrintNonStroking(boolean ov) {
091        put(PdfName.op, ov ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE);
092    }
093
094    /**
095     * Sets the flag whether to toggle knockout behavior for overprinted objects.
096     * @param ov - accepts 0 or 1
097     */
098    public void setOverPrintMode(int ov) {
099        put(PdfName.OPM, new PdfNumber(ov==0 ? 0 : 1));
100    }
101    
102    /**
103     * Sets the current stroking alpha constant, specifying the constant shape or
104     * constant opacity value to be used for stroking operations in the transparent
105     * imaging model.
106     * @param n
107     */
108    public void setStrokeOpacity(float n) {
109        put(PdfName.CA, new PdfNumber(n));
110    }
111    
112    /**
113     * Sets the current stroking alpha constant, specifying the constant shape or
114     * constant opacity value to be used for nonstroking operations in the transparent
115     * imaging model.
116     * @param n
117     */
118    public void setFillOpacity(float n) {
119        put(PdfName.ca, new PdfNumber(n));
120    }
121    
122    /**
123     * The alpha source flag specifying whether the current soft mask
124     * and alpha constant are to be interpreted as shape values (true)
125     * or opacity values (false). 
126     * @param v
127     */
128    public void setAlphaIsShape(boolean v) {
129        put(PdfName.AIS, v ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE);
130    }
131    
132    /**
133     * Determines the behavior of overlapping glyphs within a text object
134     * in the transparent imaging model.
135     * @param v
136     */
137    public void setTextKnockout(boolean v) {
138        put(PdfName.TK, v ? PdfBoolean.PDFTRUE : PdfBoolean.PDFFALSE);
139    }
140    
141    /**
142     * The current blend mode to be used in the transparent imaging model.
143     * @param bm
144     */
145    public void setBlendMode(PdfName bm) {
146        put(PdfName.BM, bm);
147    }
148    
149    /**
150     * Set the rendering intent, possible values are: PdfName.ABSOLUTECOLORIMETRIC,
151     * PdfName.RELATIVECOLORIMETRIC, PdfName.SATURATION, PdfName.PERCEPTUAL.
152     * @param ri
153     * @since 5.0.2
154     */
155    public void setRenderingIntent(PdfName ri) {
156        put(PdfName.RI, ri);
157    }
158}