PDFPatternTiling.java
10.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.io.stream.InputByteStream
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosNumeric
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.graphics.patterns;
import com.adobe.internal.io.stream.InputByteStream;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosNumeric;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFContents;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosStream;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import com.adobe.internal.pdftoolkit.pdf.document.PDFResources;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRectangle;
import com.adobe.internal.pdftoolkit.pdf.graphics.patterns.PDFPattern;
import java.io.IOException;
import java.io.InputStream;
public class PDFPatternTiling
extends PDFCosStream
implements PDFPattern {
private PDFPatternTiling(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
super(cosObject);
}
private PDFPatternTiling(PDFDocument pdfDocument, PDFRectangle key_BBox, PDFResources key_Resources, int key_PaintType, int key_TilingType, double key_XStep, double key_YStep) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
super((CosObject)PDFCosObject.newCosStream(pdfDocument));
this.setBBox(key_BBox);
this.setResources(key_Resources);
this.setDictionaryIntValue(ASName.k_PatternType, 1);
this.setPaintType(key_PaintType);
this.setTilingType(key_TilingType);
this.setXStep(key_XStep);
this.setYStep(key_YStep);
}
public static PDFPatternTiling newInstance(PDFDocument pdfDocument, PDFRectangle key_BBox, PDFResources key_Resources, int key_PaintType, int key_TilingType, double key_XStep, double key_YStep) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (key_BBox == null) {
throw new PDFInvalidParameterException("BBox is required when creating newInstance of PDFPatternTiling.");
}
if (key_Resources == null) {
throw new PDFInvalidParameterException("Resources is required when creating newInstance of PDFPatternTiling.");
}
return new PDFPatternTiling(pdfDocument, key_BBox, key_Resources, key_PaintType, key_TilingType, key_XStep, key_YStep);
}
public static PDFPatternTiling getInstance(CosObject cosObject) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFPatternTiling pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFPatternTiling.class);
if (pdfObject == null) {
pdfObject = new PDFPatternTiling(cosObject);
}
return pdfObject;
}
public int getPatternType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return 1;
}
public double getYStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryDoubleValue(ASName.k_YStep);
}
public void setYStep(double value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_YStep, value);
}
public double requireYStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryCosObjectValue(ASName.k_YStep);
if (cosObject == null) {
throw new PDFInvalidDocumentException("Unable to get YStep.");
}
return ((CosNumeric)cosObject).doubleValue();
}
public boolean hasYStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_YStep);
}
public CosArray getMatrix() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return (CosArray)this.getDictionaryValue(ASName.k_Matrix);
}
public void setMatrix(CosArray value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
this.setDictionaryValue(ASName.k_Matrix, (CosObject)value);
}
public boolean hasMatrix() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_Matrix);
}
public int getTilingType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryIntValue(ASName.k_TilingType);
}
public void setTilingType(int value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(ASName.k_TilingType, value);
}
public int requireTilingType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryCosObjectValue(ASName.k_TilingType);
if (cosObject == null) {
throw new PDFInvalidDocumentException("Unable to get TilingType.");
}
return ((CosNumeric)cosObject).intValue();
}
public boolean hasTilingType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_TilingType);
}
public PDFRectangle getBBox() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFRectangle.getInstance(this.getDictionaryCosObjectValue(ASName.k_BBox));
}
public void setBBox(PDFRectangle children) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (children == null) {
throw new PDFInvalidParameterException("BBox is a required key therefore cannot be removed.");
}
this.setDictionaryArrayValue(ASName.k_BBox, children.getCosArray());
}
public boolean hasBBox() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_BBox);
}
public int getPaintType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryIntValue(ASName.k_PaintType);
}
public void setPaintType(int value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryIntValue(ASName.k_PaintType, value);
}
public int requirePaintType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryCosObjectValue(ASName.k_PaintType);
if (cosObject == null) {
throw new PDFInvalidDocumentException("Unable to get PaintType.");
}
return ((CosNumeric)cosObject).intValue();
}
public boolean hasPaintType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_PaintType);
}
public PDFResources getResources() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFResources.getInstance(this.getDictionaryCosObjectValue(ASName.k_Resources));
}
public void setResources(PDFResources value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (value == null) {
throw new PDFInvalidParameterException("Resources is a required key therefore cannot be removed.");
}
this.setDictionaryValue(ASName.k_Resources, value);
}
public PDFResources requireResources() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFResources pdfObject = PDFResources.getInstance(this.getDictionaryCosObjectValue(ASName.k_Resources));
if (pdfObject == null) {
throw new PDFInvalidDocumentException("Could not get Resources");
}
return pdfObject;
}
public boolean hasResources() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_Resources);
}
public double getXStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryDoubleValue(ASName.k_XStep);
}
public void setXStep(double value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_XStep, value);
}
public double requireXStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosObject cosObject = this.getDictionaryCosObjectValue(ASName.k_XStep);
if (cosObject == null) {
throw new PDFInvalidDocumentException("Unable to get XStep.");
}
return ((CosNumeric)cosObject).doubleValue();
}
public boolean hasXStep() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_XStep);
}
public PDFContents getContents() throws PDFInvalidDocumentException {
return PDFContents.getInstance(this.getCosObject());
}
public void setContents(PDFContents pdfContents) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (pdfContents == null) {
throw new PDFInvalidDocumentException("Invalid Parameter: pdfContents is null");
}
InputByteStream contents = pdfContents.getContents();
try {
if (contents != null) {
this.setStreamData(contents.toInputStream());
}
}
catch (IOException e) {
throw new PDFIOException((Throwable)e);
}
finally {
try {
if (contents != null) {
contents.close();
}
}
catch (IOException e) {}
}
}
public PDFCosDictionary getPDFCosObject() {
return this;
}
}