KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pdfbox > pdmodel > graphics > PDGraphicsState


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.graphics;
32
33 import org.pdfbox.util.Matrix;
34
35 import org.pdfbox.pdmodel.text.PDTextState;
36
37 import org.pdfbox.pdmodel.graphics.color.PDColorSpaceInstance;
38
39 /**
40  * This class will hold the current state of the graphics parameters when executing a
41  * content stream.
42  *
43  * @author <a HREF="ben@benlitchfield.com">Ben Litchfield</a>
44  * @version $Revision: 1.4 $
45  */

46 public class PDGraphicsState implements Cloneable JavaDoc
47 {
48     private Matrix currentTransformationMatrix = new Matrix();
49
50     //Here are some attributes of the Graphics state, but have not been created yet.
51
//
52
//clippingPath
53
private PDColorSpaceInstance strokingColorSpace = new PDColorSpaceInstance();
54     private PDColorSpaceInstance nonStrokingColorSpace = new PDColorSpaceInstance();
55     private PDTextState textState = new PDTextState();
56     private double lineWidth = 0;
57     private int lineCap = 0;
58     private int lineJoin = 0;
59     private double miterLimit = 0;
60     private PDLineDashPattern lineDashPattern;
61     private String JavaDoc renderingIntent;
62     private boolean strokeAdjustment = false;
63     //blend mode
64
//soft mask
65
private double alphaConstants = 0;
66     private boolean alphaSource = false;
67
68     //DEVICE DEPENDENT parameters
69
private boolean overprint = false;
70     private double overprintMode = 0;
71     //black generation
72
//undercolor removal
73
//transfer
74
//halftone
75
private double flatness = 1.0;
76     private double smoothness = 0;
77
78     /**
79      * Get the value of the CTM.
80      *
81      * @return The current transformation matrix.
82      */

83     public Matrix getCurrentTransformationMatrix()
84     {
85         return currentTransformationMatrix;
86     }
87
88     /**
89      * Set the value of the CTM.
90      *
91      * @param value The current transformation matrix.
92      */

93     public void setCurrentTransformationMatrix(Matrix value)
94     {
95         currentTransformationMatrix = value;
96     }
97
98     /**
99      * Get the value of the line width.
100      *
101      * @return The current line width.
102      */

103     public double getLineWidth()
104     {
105         return lineWidth;
106     }
107
108     /**
109      * set the value of the line width.
110      *
111      * @param value The current line width.
112      */

113     public void setLineWidth(double value)
114     {
115         lineWidth = value;
116     }
117
118     /**
119      * Get the value of the line cap.
120      *
121      * @return The current line cap.
122      */

123     public int getLineCap()
124     {
125         return lineCap;
126     }
127
128     /**
129      * set the value of the line cap.
130      *
131      * @param value The current line cap.
132      */

133     public void setLineCap(int value)
134     {
135         lineCap = value;
136     }
137
138     /**
139      * Get the value of the line join.
140      *
141      * @return The current line join value.
142      */

143     public int getLineJoin()
144     {
145         return lineJoin;
146     }
147
148     /**
149      * Get the value of the line join.
150      *
151      * @param value The current line join
152      */

153     public void setLineJoin(int value)
154     {
155         lineJoin = value;
156     }
157
158     /**
159      * Get the value of the miter limit.
160      *
161      * @return The current miter limit.
162      */

163     public double getMiterLimit()
164     {
165         return miterLimit;
166     }
167
168     /**
169      * set the value of the miter limit.
170      *
171      * @param value The current miter limit.
172      */

173     public void setMiterLimit(double value)
174     {
175         miterLimit = value;
176     }
177
178     /**
179      * Get the value of the stroke adjustment parameter.
180      *
181      * @return The current stroke adjustment.
182      */

183     public boolean isStrokeAdjustment()
184     {
185         return strokeAdjustment;
186     }
187
188     /**
189      * set the value of the stroke adjustment.
190      *
191      * @param value The value of the stroke adjustment parameter.
192      */

193     public void setStrokeAdjustment(boolean value)
194     {
195         strokeAdjustment = value;
196     }
197
198     /**
199      * Get the value of the alpha constants property.
200      *
201      * @return The value of the alpha constants parameter.
202      */

203     public double getAlphaConstants()
204     {
205         return alphaConstants;
206     }
207
208     /**
209      * set the value of the alpha constants property.
210      *
211      * @param value The value of the alpha constants parameter.
212      */

213     public void setAlphaConstants(double value)
214     {
215         alphaConstants = value;
216     }
217
218     /**
219      * get the value of the alpha source property.
220      *
221      * @return The value of the alpha source parameter.
222      */

223     public boolean isAlphaSource()
224     {
225         return alphaSource;
226     }
227
228     /**
229      * set the value of the alpha source property.
230      *
231      * @param value The value of the alpha source parameter.
232      */

233     public void setAlphaSource(boolean value)
234     {
235         alphaSource = value;
236     }
237
238     /**
239      * get the value of the overprint property.
240      *
241      * @return The value of the overprint parameter.
242      */

243     public boolean isOverprint()
244     {
245         return overprint;
246     }
247
248     /**
249      * set the value of the overprint property.
250      *
251      * @param value The value of the overprint parameter.
252      */

253     public void setOverprint(boolean value)
254     {
255         overprint = value;
256     }
257
258     /**
259      * get the value of the overprint mode property.
260      *
261      * @return The value of the overprint mode parameter.
262      */

263     public double getOverprintMode()
264     {
265         return overprintMode;
266     }
267
268     /**
269      * set the value of the overprint mode property.
270      *
271      * @param value The value of the overprint mode parameter.
272      */

273     public void setOverprintMode(double value)
274     {
275         overprintMode = value;
276     }
277
278     /**
279      * get the value of the flatness property.
280      *
281      * @return The value of the flatness parameter.
282      */

283     public double getFlatness()
284     {
285         return flatness;
286     }
287
288     /**
289      * set the value of the flatness property.
290      *
291      * @param value The value of the flatness parameter.
292      */

293     public void setFlatness(double value)
294     {
295         flatness = value;
296     }
297
298     /**
299      * get the value of the smoothness property.
300      *
301      * @return The value of the smoothness parameter.
302      */

303     public double getSmoothness()
304     {
305         return smoothness;
306     }
307
308     /**
309      * set the value of the smoothness property.
310      *
311      * @param value The value of the smoothness parameter.
312      */

313     public void setSmoothness(double value)
314     {
315         smoothness = value;
316     }
317
318     /**
319      * This will get the graphics text state.
320      *
321      * @return The graphics text state.
322      */

323     public PDTextState getTextState()
324     {
325         return textState;
326     }
327
328     /**
329      * This will set the graphics text state.
330      *
331      * @param value The graphics text state.
332      */

333     public void setTextState(PDTextState value)
334     {
335         textState = value;
336     }
337
338     /**
339      * This will get the current line dash pattern.
340      *
341      * @return The line dash pattern.
342      */

343     public PDLineDashPattern getLineDashPattern()
344     {
345         return lineDashPattern;
346     }
347
348     /**
349      * This will set the current line dash pattern.
350      *
351      * @param value The new line dash pattern.
352      */

353     public void setLineDashPattern(PDLineDashPattern value)
354     {
355         lineDashPattern = value;
356     }
357
358     /**
359      * This will get the rendering intent.
360      *
361      * @see PDExtendedGraphicsState
362      *
363      * @return The rendering intent
364      */

365     public String JavaDoc getRenderingIntent()
366     {
367         return renderingIntent;
368     }
369
370     /**
371      * This will set the rendering intent.
372      *
373      * @param value The new rendering intent.
374      */

375     public void setRenderingIntent(String JavaDoc value)
376     {
377         renderingIntent = value;
378     }
379
380     /**
381      * {@inheritDoc}
382      */

383     public Object JavaDoc clone()
384     {
385         PDGraphicsState clone = null;
386         try
387         {
388             clone = (PDGraphicsState)super.clone();
389             clone.setTextState( (PDTextState)textState.clone() );
390             clone.setCurrentTransformationMatrix( currentTransformationMatrix.copy() );
391         }
392         catch( CloneNotSupportedException JavaDoc e )
393         {
394             e.printStackTrace();
395         }
396         return clone;
397     }
398
399     /**
400      * This will get the current stroking colorspace.
401      *
402      * @return The current stroking colorspace.
403      */

404     public PDColorSpaceInstance getStrokingColorSpace()
405     {
406         return strokingColorSpace;
407     }
408
409     /**
410      * This will set the current stroking colorspace.
411      *
412      * @param value The new stroking colorspace instance.
413      */

414     public void setStrokingColorSpace(PDColorSpaceInstance value)
415     {
416         strokingColorSpace = value;
417     }
418
419     /**
420      * This will get the nonstroking color space instance.
421      *
422      * @return The colorspace instance.
423      */

424     public PDColorSpaceInstance getNonStrokingColorSpace()
425     {
426         return nonStrokingColorSpace;
427     }
428
429     /**
430      * This will set the non-stroking colorspace instance.
431      *
432      * @param value The non-stroking colorspace instance.
433      */

434     public void setNonStrokingColorSpace(PDColorSpaceInstance value)
435     {
436         nonStrokingColorSpace = value;
437     }
438 }
Popular Tags