KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lowagie > text > pdf > PdfPattern


1 /*
2  * The contents of this file are subject to the Mozilla Public License Version 1.1
3  * (the "License"); you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
5  *
6  * Software distributed under the License is distributed on an "AS IS" basis,
7  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
8  * for the specific language governing rights and limitations under the License.
9  *
10  * The Original Code is 'iText, a free JAVA-PDF library'.
11  *
12  * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
13  * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
14  * All Rights Reserved.
15  * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
16  * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
17  *
18  * Contributor(s): all the names of the contributors are added in the source code
19  * where applicable.
20  *
21  * Alternatively, the contents of this file may be used under the terms of the
22  * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
23  * provisions of LGPL are applicable instead of those above. If you wish to
24  * allow use of your version of this file only under the terms of the LGPL
25  * License and not to allow others to use your version of this file under
26  * the MPL, indicate your decision by deleting the provisions above and
27  * replace them with the notice and other provisions required by the LGPL.
28  * If you do not delete the provisions above, a recipient may use your version
29  * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
30  *
31  * This library is free software; you can redistribute it and/or modify it
32  * under the terms of the MPL as stated above or under the terms of the GNU
33  * Library General Public License as published by the Free Software Foundation;
34  * either version 2 of the License, or any later version.
35  *
36  * This library is distributed in the hope that it will be useful, but WITHOUT
37  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
38  * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
39  * details.
40  *
41  * If you didn't download this code from the following link, you should check if
42  * you aren't using an obsolete version:
43  * http://www.lowagie.com/iText/
44  */

45 package com.lowagie.text.pdf;
46
47 import com.lowagie.text.ExceptionConverter;
48
49 /**
50  * A <CODE>PdfPattern</CODE> defines a ColorSpace
51  *
52  * @see PdfStream
53  */

54
55 public class PdfPattern extends PdfStream {
56     
57     PdfPattern(PdfPatternPainter painter) {
58         super();
59         PdfNumber one = new PdfNumber(1);
60         PdfArray matrix = painter.getMatrix();
61         if ( matrix != null ) {
62             put(PdfName.MATRIX, matrix);
63         }
64         put(PdfName.TYPE, PdfName.PATTERN);
65         put(PdfName.BBOX, new PdfRectangle(painter.getBoundingBox()));
66         put(PdfName.RESOURCES, painter.getResources());
67         put(PdfName.TILINGTYPE, one);
68         put(PdfName.PATTERNTYPE, one);
69         if (painter.isStencil())
70             put(PdfName.PAINTTYPE, new PdfNumber(2));
71         else
72             put(PdfName.PAINTTYPE, one);
73         put(PdfName.XSTEP, new PdfNumber(painter.getXStep()));
74         put(PdfName.YSTEP, new PdfNumber(painter.getYStep()));
75         bytes = painter.toPdf(null);
76         put(PdfName.LENGTH, new PdfNumber(bytes.length));
77         try {
78             flateCompress();
79         } catch (Exception JavaDoc e) {
80             throw new ExceptionConverter(e);
81         }
82     }
83 }
84
Popular Tags