KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > text > PDTextState


1 /**
2  * Copyright (c) 2003-2006, www.pdfbox.org
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice,
11  * this list of conditions and the following disclaimer in the documentation
12  * and/or other materials provided with the distribution.
13  * 3. Neither the name of pdfbox; nor the names of its
14  * contributors may be used to endorse or promote products derived from this
15  * software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  * http://www.pdfbox.org
29  *
30  */

31 package org.pdfbox.pdmodel.text;
32
33 import org.pdfbox.pdmodel.font.PDFont;
34
35 /**
36  * This class will hold the current state of the text parameters when executing a
37  * content stream.
38  *
39  * @author <a HREF="mailto:ben@benlitchfield.com">Ben Litchfield</a>
40  * @version $Revision: 1.4 $
41  */

42 public class PDTextState implements Cloneable JavaDoc
43 {
44     /**
45      * See PDF Reference 1.5 Table 5.3.
46      */

47     public static final int RENDERING_MODE_FILL_TEXT = 0;
48     /**
49      * See PDF Reference 1.5 Table 5.3.
50      */

51     public static final int RENDERING_MODE_STROKE_TEXT = 1;
52     /**
53      * See PDF Reference 1.5 Table 5.3.
54      */

55     public static final int RENDERING_MODE_FILL_THEN_STROKE_TEXT = 2;
56     /**
57      * See PDF Reference 1.5 Table 5.3.
58      */

59     public static final int RENDERING_MODE_NEITHER_FILL_NOR_STROKE_TEXT = 3;
60     /**
61      * See PDF Reference 1.5 Table 5.3.
62      */

63     public static final int RENDERING_MODE_FILL_TEXT_AND_ADD_TO_PATH_FOR_CLIPPING = 4;
64     /**
65      * See PDF Reference 1.5 Table 5.3.
66      */

67     public static final int RENDERING_MODE_STROKE_TEXT_AND_ADD_TO_PATH_FOR_CLIPPING = 5;
68     /**
69      * See PDF Reference 1.5 Table 5.3.
70      */

71     public static final int RENDERING_MODE_FILL_THEN_STROKE_TEXT_AND_ADD_TO_PATH_FOR_CLIPPING = 6;
72     /**
73      * See PDF Reference 1.5 Table 5.3.
74      */

75     public static final int RENDERING_MODE_ADD_TEXT_TO_PATH_FOR_CLIPPING = 7;
76
77
78     //these are set default according to PDF Reference 1.5 section 5.2
79
private float characterSpacing = 0;
80     private float wordSpacing = 0;
81     private float horizontalScaling = 100;
82     private float leading = 0;
83     private PDFont font;
84     private float fontSize;
85     private int renderingMode = 0;
86     private float rise = 0;
87     private boolean knockout = true;
88
89     /**
90      * Get the value of the characterSpacing.
91      *
92      * @return The current characterSpacing.
93      */

94     public float getCharacterSpacing()
95     {
96         return characterSpacing;
97     }
98
99     /**
100      * Set the value of the characterSpacing.
101      *
102      * @param value The characterSpacing.
103      */

104     public void setCharacterSpacing(float value)
105     {
106         characterSpacing = value;
107     }
108
109     /**
110      * Get the value of the wordSpacing.
111      *
112      * @return The wordSpacing.
113      */

114     public float getWordSpacing()
115     {
116         return wordSpacing;
117     }
118
119     /**
120      * Set the value of the wordSpacing.
121      *
122      * @param value The wordSpacing.
123      */

124     public void setWordSpacing(float value)
125     {
126         wordSpacing = value;
127     }
128
129     /**
130      * Get the value of the horizontalScaling. The default is 100. This value
131      * is the percentage value 0-100 and not 0-1. So for mathematical operations
132      * you will probably need to divide by 100 first.
133      *
134      * @return The horizontalScaling.
135      */

136     public float getHorizontalScalingPercent()
137     {
138         return horizontalScaling;
139     }
140
141     /**
142      * Set the value of the horizontalScaling.
143      *
144      * @param value The horizontalScaling.
145      */

146     public void setHorizontalScalingPercent(float value)
147     {
148         horizontalScaling = value;
149     }
150
151     /**
152      * Get the value of the leading.
153      *
154      * @return The leading.
155      */

156     public float getLeading()
157     {
158         return leading;
159     }
160
161     /**
162      * Set the value of the leading.
163      *
164      * @param value The leading.
165      */

166     public void setLeading(float value)
167     {
168         leading = value;
169     }
170
171     /**
172      * Get the value of the font.
173      *
174      * @return The font.
175      */

176     public PDFont getFont()
177     {
178         return font;
179     }
180
181     /**
182      * Set the value of the font.
183      *
184      * @param value The font.
185      */

186     public void setFont(PDFont value)
187     {
188         font = value;
189     }
190
191     /**
192      * Get the value of the fontSize.
193      *
194      * @return The fontSize.
195      */

196     public float getFontSize()
197     {
198         return fontSize;
199     }
200
201     /**
202      * Set the value of the fontSize.
203      *
204      * @param value The fontSize.
205      */

206     public void setFontSize(float value)
207     {
208         fontSize = value;
209     }
210
211     /**
212      * Get the value of the renderingMode.
213      *
214      * @return The renderingMode.
215      */

216     public int getRenderingMode()
217     {
218         return renderingMode;
219     }
220
221     /**
222      * Set the value of the renderingMode.
223      *
224      * @param value The renderingMode.
225      */

226     public void setRenderingMode(int value)
227     {
228         renderingMode = value;
229     }
230
231     /**
232      * Get the value of the rise.
233      *
234      * @return The rise.
235      */

236     public float getRise()
237     {
238         return rise;
239     }
240
241     /**
242      * Set the value of the rise.
243      *
244      * @param value The rise.
245      */

246     public void setRise(float value)
247     {
248         rise = value;
249     }
250
251     /**
252      * Get the value of the knockout.
253      *
254      * @return The knockout.
255      */

256     public boolean getKnockoutFlag()
257     {
258         return knockout;
259     }
260
261     /**
262      * Set the value of the knockout.
263      *
264      * @param value The knockout.
265      */

266     public void setKnockoutFlag(boolean value)
267     {
268         knockout = value;
269     }
270
271     /**
272      * {@inheritDoc}
273      */

274     public Object JavaDoc clone()
275     {
276         try
277         {
278             return super.clone();
279         }
280         catch (CloneNotSupportedException JavaDoc ignore)
281         {
282             //ignore
283
}
284         return null;
285     }
286 }
Popular Tags