ContentPathItem.java
4.12 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.exceptions.PDFException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFIOException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFInvalidDocumentException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFRuntimeException
* com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException
* com.adobe.internal.pdftoolkit.core.types.ASMatrix
* com.adobe.internal.pdftoolkit.core.types.ASRectangle
*/
package com.adobe.internal.pdftoolkit.graphicsDOM;
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.PDFRuntimeException;
import com.adobe.internal.pdftoolkit.core.exceptions.PDFSecurityException;
import com.adobe.internal.pdftoolkit.core.types.ASMatrix;
import com.adobe.internal.pdftoolkit.core.types.ASRectangle;
import com.adobe.internal.pdftoolkit.graphicsDOM.AbstractContentItem;
import com.adobe.internal.pdftoolkit.graphicsDOM.ContentType;
import com.adobe.internal.pdftoolkit.graphicsDOM.DocumentContext;
import com.adobe.internal.pdftoolkit.graphicsDOM.GraphicsState;
import com.adobe.internal.pdftoolkit.graphicsDOM.PathPainting;
import com.adobe.internal.pdftoolkit.graphicsDOM.PrimitiveContentItem;
import java.awt.geom.GeneralPath;
import java.awt.geom.Rectangle2D;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
public abstract class ContentPathItem<G extends GraphicsState>
extends AbstractContentItem<G>
implements PrimitiveContentItem<G> {
private GeneralPath genPath;
private PathPainting pathPaintType;
private ASMatrix transformationMatrix = null;
private Rectangle2D boundingBox = null;
private boolean isShadingPresent = false;
public ContentPathItem(G graphicsState, int id) {
super(graphicsState, id);
}
public GeneralPath getPath() {
return this.genPath;
}
public PathPainting getPathPaintingType() {
return this.pathPaintType;
}
public void setPath(GeneralPath genPath, PathPainting pathPaintType) {
this.genPath = genPath;
this.pathPaintType = pathPaintType;
this.boundingBox = null;
}
@Override
public ContentType getType() {
return ContentType.Path;
}
public void setTransformationMatrix(ASMatrix matrix) {
this.transformationMatrix = matrix;
}
public ASMatrix getTransformationMatrix() {
return this.transformationMatrix;
}
@Override
public Rectangle2D getBoundingBox(DocumentContext context) {
if (this.boundingBox != null) {
return this.boundingBox;
}
Rectangle2D rect = this.genPath.getBounds2D();
double lineWidth = this.getGState().getLineWidth();
double miterLimit = this.getGState().getMiterLimit();
lineWidth = this.getPathPaintingType().isStroke() && lineWidth > 0.0 ? (miterLimit > 1.0 ? lineWidth * miterLimit / 4.0 : lineWidth / 2.0 * Math.sqrt(2.0)) : 0.25;
ASRectangle newRect = new ASRectangle(rect.getMinX() - lineWidth, rect.getMinY() - lineWidth, rect.getMaxX() + lineWidth, rect.getMaxY() + lineWidth);
try {
newRect = newRect.transform(this.transformationMatrix).normalized();
}
catch (PDFInvalidDocumentException e) {
throw new PDFRuntimeException((PDFException)e);
}
catch (PDFIOException e) {
throw new PDFRuntimeException((PDFException)e);
}
catch (PDFSecurityException e) {
throw new PDFRuntimeException((PDFException)e);
}
rect.setRect(newRect.left(), newRect.bottom(), newRect.width(), newRect.height());
this.boundingBox = rect;
return this.boundingBox;
}
public boolean getIsShadingPresent() {
return this.isShadingPresent;
}
public void setIsShadingPresent(boolean isShadingPresent) {
this.isShadingPresent = isShadingPresent;
}
}