PDFFunction.java
4.86 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosObject
* com.adobe.internal.pdftoolkit.core.exceptions.PDFException
* 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.PDFRuntimeException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASName
*/
package com.adobe.internal.pdftoolkit.pdf.graphics;
import com.adobe.internal.pdftoolkit.color.Function;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosObject;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFException;
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.PDFRuntimeException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASName;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFDomain;
import com.adobe.internal.pdftoolkit.pdf.graphics.PDFRange;
import com.adobe.internal.pdftoolkit.pdf.graphics.impl.FunctionCacheImpl;
import com.adobe.internal.pdftoolkit.pdf.graphics.impl.PDFFunctionIdentity;
public abstract class PDFFunction
extends PDFCosDictionary
implements Function {
public static final int FUNCTION_TYPE0 = 0;
public static final int FUNCTION_TYPE2 = 2;
public static final int FUNCTION_TYPE3 = 3;
public static final int FUNCTION_TYPE4 = 4;
private static final PDFFunctionIdentity identityFunc = new PDFFunctionIdentity();
public static PDFFunctionIdentity getIdentityFunction() {
return identityFunc;
}
protected PDFFunction(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public int getFunctionType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getDictionaryIntValue(ASName.k_FunctionType);
}
public boolean hasFunctionType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_FunctionType);
}
public boolean hasDomain() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_Domain);
}
public PDFDomain getFunctionDomain() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFDomain domain = PDFDomain.getInstance((CosObject)this.getDictionaryArrayValue(ASName.k_Domain));
if (domain == null) {
throw new PDFInvalidDocumentException("Required Domain Entry is missing.");
}
return domain;
}
public void setFunctionDomain(PDFDomain value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (value == null) {
throw new PDFInvalidParameterException("Domain is a required key therefore cannot be removed.");
}
this.setDictionaryValue(ASName.k_Domain, value);
}
public PDFRange getFunctionRange() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return PDFRange.getInstance((CosObject)this.getDictionaryArrayValue(ASName.k_Range));
}
public void setFunctionRange(PDFRange value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
int functionType = this.getFunctionType();
if (value == null && (functionType == 0 || functionType == 4)) {
throw new PDFInvalidParameterException("Range is a required key therefore cannot be removed.");
}
this.setDictionaryValue(ASName.k_Range, value);
}
public boolean hasRange() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_Range);
}
public double[] apply(double[] inputData) {
try {
return new FunctionCacheImpl(this).apply(inputData);
}
catch (PDFIOException e) {
throw new PDFRuntimeException((PDFException)e);
}
catch (PDFSecurityException e) {
throw new PDFRuntimeException((PDFException)e);
}
catch (PDFInvalidDocumentException e) {
throw new PDFRuntimeException((PDFException)e);
}
}
}