001/* 002 * $Id: GraphicsState.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: Kevin Day, 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.parser; 045 046import com.itextpdf.text.pdf.CMapAwareDocumentFont; 047 048/** 049 * Keeps all the parameters of the graphics state. 050 * @since 2.1.4 051 */ 052public class GraphicsState { 053 /** The current transformation matrix. */ 054 Matrix ctm; 055 /** The current character spacing. */ 056 float characterSpacing; 057 /** The current word spacing. */ 058 float wordSpacing; 059 /** The current horizontal scaling */ 060 float horizontalScaling; 061 /** The current leading. */ 062 float leading; 063 /** The active font. */ 064 CMapAwareDocumentFont font; 065 /** The current font size. */ 066 float fontSize; 067 /** The current render mode. */ 068 int renderMode; 069 /** The current text rise */ 070 float rise; 071 /** The current knockout value. */ 072 boolean knockout; 073 074 /** 075 * Constructs a new Graphics State object with the default values. 076 */ 077 public GraphicsState(){ 078 ctm = new Matrix(); 079 characterSpacing = 0; 080 wordSpacing = 0; 081 horizontalScaling = 1.0f; 082 leading = 0; 083 font = null; 084 fontSize = 0; 085 renderMode = 0; 086 rise = 0; 087 knockout = true; 088 } 089 090 /** 091 * Copy constructor. 092 * @param source another GraphicsState object 093 */ 094 public GraphicsState(GraphicsState source){ 095 // note: all of the following are immutable, with the possible exception of font 096 // so it is safe to copy them as-is 097 ctm = source.ctm; 098 characterSpacing = source.characterSpacing; 099 wordSpacing = source.wordSpacing; 100 horizontalScaling = source.horizontalScaling; 101 leading = source.leading; 102 font = source.font; 103 fontSize = source.fontSize; 104 renderMode = source.renderMode; 105 rise = source.rise; 106 knockout = source.knockout; 107 } 108 109 /** 110 * Getter for the current transformation matrix 111 * @return the ctm 112 * @since iText 5.0.1 113 */ 114 public Matrix getCtm() { 115 return ctm; 116 } 117 118 /** 119 * Getter for the character spacing. 120 * @return the character spacing 121 * @since iText 5.0.1 122 */ 123 public float getCharacterSpacing() { 124 return characterSpacing; 125 } 126 127 /** 128 * Getter for the word spacing 129 * @return the word spacing 130 * @since iText 5.0.1 131 */ 132 public float getWordSpacing() { 133 return wordSpacing; 134 } 135 136 /** 137 * Getter for the horizontal scaling 138 * @return the horizontal scaling 139 * @since iText 5.0.1 140 */ 141 public float getHorizontalScaling() { 142 return horizontalScaling; 143 } 144 145 /** 146 * Getter for the leading 147 * @return the leading 148 * @since iText 5.0.1 149 */ 150 public float getLeading() { 151 return leading; 152 } 153 154 /** 155 * Getter for the font 156 * @return the font 157 * @since iText 5.0.1 158 */ 159 public CMapAwareDocumentFont getFont() { 160 return font; 161 } 162 163 /** 164 * Getter for the font size 165 * @return the font size 166 * @since iText 5.0.1 167 */ 168 public float getFontSize() { 169 return fontSize; 170 } 171 172 /** 173 * Getter for the render mode 174 * @return the renderMode 175 * @since iText 5.0.1 176 */ 177 public int getRenderMode() { 178 return renderMode; 179 } 180 181 /** 182 * Getter for text rise 183 * @return the text rise 184 * @since iText 5.0.1 185 */ 186 public float getRise() { 187 return rise; 188 } 189 190 /** 191 * Getter for knockout 192 * @return the knockout 193 * @since iText 5.0.1 194 */ 195 public boolean isKnockout() { 196 return knockout; 197 } 198}