PDFBorderStyle.java
6.57 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
/*
* 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.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.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 com.adobe.internal.pdftoolkit.pdf.utils.PDFUtil;
import java.util.ArrayList;
import java.util.List;
public class PDFBorderStyle
extends PDFCosDictionary {
private PDFBorderStyle(CosObject cosObject) throws PDFInvalidDocumentException {
super(cosObject);
}
public static PDFBorderStyle getInstance(CosObject cosObject) throws PDFInvalidDocumentException {
if (PDFCosObject.checkNullCosObject(cosObject) == null) {
return null;
}
PDFBorderStyle pdfObject = PDFCosObject.getCachedInstance(cosObject, PDFBorderStyle.class);
if (pdfObject == null) {
pdfObject = new PDFBorderStyle(cosObject);
}
return pdfObject;
}
public static PDFBorderStyle newInstance(PDFDocument pdfDocument, double width, Style style, long[] dash) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
PDFBorderStyle pdfObject = PDFBorderStyle.newInstance(pdfDocument);
pdfObject.setDictionaryNameValue(ASName.k_Type, ASName.k_Border);
pdfObject.setDictionaryDoubleValue(ASName.k_W, width);
if (style != null) {
pdfObject.setDictionaryNameValue(ASName.k_S, style.getValue());
}
if (dash != null) {
pdfObject.setDictionaryArrayValue(ASName.k_D, dash);
}
return pdfObject;
}
static PDFBorderStyle newInstance(PDFDocument pdfDocument) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosDictionary cosObject = PDFCosObject.newCosDictionary(pdfDocument);
PDFBorderStyle pdfObject = new PDFBorderStyle((CosObject)cosObject);
return pdfObject;
}
public double getWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
Number width = this.getDictionaryNumericValue(ASName.k_W);
if (width == null) {
return 1.0;
}
return width.doubleValue();
}
public void setWidth(String width) throws PDFInvalidDocumentException, PDFIOException, PDFInvalidParameterException, PDFSecurityException {
this.setDictionaryDoubleValue(ASName.k_W, width);
}
public boolean hasWidth() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_W);
}
public Style getStyle() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return Style.getInstance(this.getDictionaryNameValue(ASName.k_S));
}
public void setStyle(Style style) throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
this.setDictionaryNameValue(ASName.k_S, style.value);
}
public boolean hasStyle() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_S);
}
public double[] getDash() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
CosArray cosDash = (CosArray)this.getDictionaryCosObjectValue(ASName.k_D);
return cosDash.getArrayDouble();
}
public void setDash(String dashes, String separator) throws PDFInvalidParameterException, PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
ArrayList dashArray = PDFUtil.parseNumbers(dashes, separator);
this.setDash(dashArray);
}
public void setDash(ArrayList dashArray) throws PDFInvalidParameterException, PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
if (dashArray == null) {
this.removeValue(ASName.k_D);
return;
}
this.setDictionaryArrayValue(ASName.k_D, dashArray);
}
public boolean hasDash() throws PDFInvalidDocumentException, PDFIOException, PDFSecurityException {
return this.dictionaryContains(ASName.k_D);
}
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public static enum Style {
Solid(ASName.k_S),
Dashed(ASName.k_D),
Beveled(ASName.k_B),
Inset(ASName.k_I),
Underline(ASName.k_U);
private final ASName value;
private Style(ASName value) {
this.value = value;
}
public ASName getValue() {
return this.value;
}
public String toString() {
return this.value.asString(true);
}
public static Style getInstance(String stringValue) {
return Style.getInstance(ASName.create((String)stringValue));
}
private static final Style getInstance(ASName value) {
if (value != null) {
if (value.equals((Object)Solid.getValue())) {
return Solid;
}
if (value.equals((Object)Dashed.getValue())) {
return Dashed;
}
if (value.equals((Object)Beveled.getValue())) {
return Beveled;
}
if (value.equals((Object)Inset.getValue())) {
return Inset;
}
if (value.equals((Object)Underline.getValue())) {
return Underline;
}
}
return null;
}
}
}