PDFRotation.java
1.58 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException
*/
package com.adobe.internal.pdftoolkit.pdf.graphics;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidParameterException;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public enum PDFRotation {
ROTATE_0(0),
ROTATE_90(90),
ROTATE_180(180),
ROTATE_270(270);
private final int rotation;
private PDFRotation(int rotation) {
this.rotation = rotation;
}
public String toString() {
return Integer.toString(this.rotation);
}
public int getValue() {
return this.rotation;
}
public static final PDFRotation getInstance(int angle) throws PDFInvalidParameterException {
PDFRotation rotation = null;
int normAngle = angle % 360;
normAngle = normAngle >= 0 ? normAngle : normAngle + 360;
switch (normAngle) {
case 0: {
rotation = ROTATE_0;
break;
}
case 90: {
rotation = ROTATE_90;
break;
}
case 180: {
rotation = ROTATE_180;
break;
}
case 270: {
rotation = ROTATE_270;
break;
}
default: {
throw new PDFInvalidParameterException("PDFRotation must be a multiple of 90 degrees.");
}
}
return rotation;
}
}