PDFIconFit.java
7.85 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.cos.CosArray
* com.adobe.internal.pdftoolkit.core.cos.CosDictionary
* com.adobe.internal.pdftoolkit.core.cos.CosDocument
* 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.interactive.annotation;
import com.adobe.internal.pdftoolkit.core.cos.CosArray;
import com.adobe.internal.pdftoolkit.core.cos.CosDictionary;
import com.adobe.internal.pdftoolkit.core.cos.CosDocument;
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.PDFCosDictionary;
import com.adobe.internal.pdftoolkit.pdf.document.PDFCosObject;
import com.adobe.internal.pdftoolkit.pdf.document.PDFDocument;
import java.util.ArrayList;
public final class PDFIconFit
extends PDFCosDictionary {
public static final ASName k_SW = ASName.create((String)"SW");
public static final ASName k_FB = ASName.create((String)"FB");
private PDFIconFit(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFIconFit getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFIconFit pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFIconFit.class);
if (pdfObject == null) {
pdfObject = new PDFIconFit(cosObject);
}
return pdfObject;
}
public static PDFIconFit newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
return new PDFIconFit((CosObject)cosObject);
}
public IconScaleCondition getIconScaleCondition() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.containsKey(k_SW)) {
return IconScaleCondition.ALWAYS;
}
return IconScaleCondition.getInstance(this.getDictionaryNameValue(k_SW));
}
public void setIconScaleCondition(IconScaleCondition condition) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(k_SW, condition == null ? null : condition.getValue());
}
public IconScaleType getIconScaleType() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.containsKey(ASName.k_S)) {
return IconScaleType.PROPORTIONAL;
}
return IconScaleType.getInstance(this.getDictionaryNameValue(ASName.k_S));
}
public void setIconScaleType(IconScaleType type) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_S, type == null ? null : type.getValue());
}
public double[] getIconScalePosition() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (!this.containsKey(ASName.k_A)) {
return new double[]{0.5, 0.5};
}
ArrayList scalePositions = (ArrayList)this.getDictionaryArrayValue(ASName.k_A).getValue();
if (scalePositions.size() != 2) {
throw new PDFInvalidDocumentException("Scale Positon array size is not 2.");
}
return new double[]{((Number)scalePositions.get(0)).doubleValue(), ((Number)scalePositions.get(1)).doubleValue()};
}
public double getScalePositionX() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getIconScalePosition()[0];
}
public double getScalePositionY() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.getIconScalePosition()[1];
}
public void setIconScalePosition(double[] pos) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException, PDFInvalidParameterException {
if (pos != null && pos.length != 2) {
throw new PDFInvalidParameterException("Scale Positon array size is not 2.");
}
this.setDictionaryArrayValue(ASName.k_A, pos);
}
public void setScalePositionX(double value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosNumeric cosValue = this.getPDFDocument().getCosDocument().createCosNumeric(value);
if (this.containsKey(ASName.k_A)) {
this.getDictionaryArrayValue(ASName.k_A).set(0, (CosObject)cosValue);
} else {
this.setDictionaryArrayValue(ASName.k_A, new double[]{value, 0.5});
}
}
public void setScalePositionY(double value) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosNumeric cosValue = this.getPDFDocument().getCosDocument().createCosNumeric(value);
if (this.containsKey(ASName.k_A)) {
this.getDictionaryArrayValue(ASName.k_A).set(1, (CosObject)cosValue);
} else {
this.setDictionaryArrayValue(ASName.k_A, new double[]{0.5, value});
}
}
public boolean getScaleFit() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (this.dictionaryContains(k_FB)) {
return this.getDictionaryBooleanValue(k_FB);
}
return false;
}
public void setScaleFit(Boolean type) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryBooleanValue(k_FB, type);
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum IconScaleType {
ANAMORPHIC(ASName.k_A),
PROPORTIONAL(ASName.k_P);
private ASName value;
public static IconScaleType getInstance(ASName value) {
if (value == ASName.k_A) {
return ANAMORPHIC;
}
if (value == ASName.k_P) {
return PROPORTIONAL;
}
return null;
}
private IconScaleType(ASName value) {
this.value = value;
}
public ASName getValue() {
return this.value;
}
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum IconScaleCondition {
ALWAYS(ASName.k_A),
SCALE_WHEN_BIG(ASName.k_B),
SCALE_WHEN_SMALL(ASName.k_S),
NEVER_SCALE(ASName.k_N);
private ASName value;
public static IconScaleCondition getInstance(ASName value) {
if (value == ASName.k_A) {
return ALWAYS;
}
if (value == ASName.k_B) {
return SCALE_WHEN_BIG;
}
if (value == ASName.k_S) {
return SCALE_WHEN_SMALL;
}
if (value == ASName.k_N) {
return NEVER_SCALE;
}
return null;
}
private IconScaleCondition(ASName value) {
this.value = value;
}
public ASName getValue() {
return this.value;
}
}
}