class CloudyBorder
extends java.lang.Object
Dashed stroke styles are not recommended with cloudy borders. The result would not look good because some parts of the arcs are traced twice by the stroked path. Actually Acrobat Reader's line style dialog does not allow to choose a dashed and a cloudy style at the same time.
Modifier and Type | Field and Description |
---|---|
private static double |
ANGLE_12_DEG |
private static double |
ANGLE_180_DEG |
private static double |
ANGLE_30_DEG |
private static double |
ANGLE_34_DEG |
private static double |
ANGLE_90_DEG |
private PDRectangle |
annotRect |
private double |
bboxMaxX |
private double |
bboxMaxY |
private double |
bboxMinX |
private double |
bboxMinY |
private double |
intensity |
private double |
lineWidth |
private PDAppearanceContentStream |
output |
private boolean |
outputStarted |
private PDRectangle |
rectWithDiff |
Constructor and Description |
---|
CloudyBorder(PDAppearanceContentStream stream,
double intensity,
double lineWidth,
PDRectangle rect)
Creates a new
CloudyBorder that writes to the specified
content stream. |
Modifier and Type | Method and Description |
---|---|
private void |
addCornerCurl(double anglePrev,
double angleCur,
double radius,
double cx,
double cy,
double alpha,
double alphaPrev,
boolean addMoveTo)
Creates a corner curl for polygons and ellipses.
|
private void |
addFirstIntermediateCurl(double angleCur,
double r,
double alpha,
double cx,
double cy)
Generates the first intermediate curl for a cloudy polygon.
|
private PDRectangle |
applyRectDiff(PDRectangle rd,
double min) |
private void |
beginOutput(double x,
double y) |
private void |
cloudyEllipseImpl(double leftOrig,
double bottomOrig,
double rightOrig,
double topOrig)
Cloudy ellipse implementation.
|
private void |
cloudyPolygonImpl(java.awt.geom.Point2D.Double[] vertices,
boolean isEllipse)
Cloudy polygon implementation.
|
private void |
cloudyRectangleImpl(double left,
double bottom,
double right,
double top,
boolean isEllipse)
Cloudy rectangle implementation is based on converting the rectangle
to a polygon.
|
private double |
computeParamsEllipse(java.awt.geom.Point2D.Double pt,
java.awt.geom.Point2D.Double ptNext,
double r,
double curlAdv)
Computes the alpha parameter for an ellipse curl.
|
private int |
computeParamsPolygon(double advInterm,
double advCorner,
double k,
double r,
double length,
double[] array)
Computes parameters for a cloudy polygon: n, alpha, and dx.
|
private static double |
cosine(double dx,
double hypot) |
(package private) void |
createCloudyEllipse(PDRectangle rd)
Creates a cloudy border for a Circle annotation.
|
(package private) void |
createCloudyPolygon(float[][] path)
Creates a cloudy border for a Polygon annotation.
|
(package private) void |
createCloudyRectangle(PDRectangle rd)
Creates a cloudy border for a rectangular annotation.
|
private void |
curveTo(double ax,
double ay,
double bx,
double by,
double cx,
double cy) |
private void |
drawBasicEllipse(double left,
double bottom,
double right,
double top)
Draws an ellipse without a cloudy border effect.
|
private void |
finish() |
private static java.awt.geom.Point2D.Double[] |
flattenEllipse(double left,
double bottom,
double right,
double top)
Flattens an ellipse into a polygon.
|
private void |
getArc(double startAng,
double endAng,
double rx,
double ry,
double cx,
double cy,
java.util.ArrayList<java.awt.geom.Point2D.Double> out,
boolean addMoveTo)
Creates one or more Bézier curves that represent an elliptical arc.
|
private void |
getArcSegment(double startAng,
double endAng,
double cx,
double cy,
double rx,
double ry,
java.util.ArrayList<java.awt.geom.Point2D.Double> out,
boolean addMoveTo)
Creates a single Bézier curve that represents a section of an elliptical
arc.
|
(package private) PDRectangle |
getBBox()
Returns the
BBox entry (bounding box) for the
appearance stream form XObject. |
private double |
getEllipseCloudRadius() |
private java.awt.geom.Point2D.Double[] |
getIntermediateCurlTemplate(double angleCur,
double r)
Returns a template for intermediate curls in a cloudy polygon.
|
(package private) java.awt.geom.AffineTransform |
getMatrix()
Returns the
Matrix entry for the appearance stream form XObject. |
private double |
getPolygonCloudRadius() |
private double |
getPolygonDirection(java.awt.geom.Point2D.Double[] points)
Returns the direction of the specified polygon.
|
private void |
getPositivePolygon(java.awt.geom.Point2D.Double[] points)
Makes a polygon whose direction is the same as the positive angle
direction in the coordinate system.
|
(package private) PDRectangle |
getRectangle()
Returns the updated
Rect entry for the annotation. |
(package private) PDRectangle |
getRectDifference()
Returns the updated
RD entry for Square and Circle annotations. |
private void |
lineTo(double x,
double y) |
private void |
lineTo(java.awt.geom.Point2D.Double p) |
private void |
moveTo(double x,
double y) |
private void |
moveTo(java.awt.geom.Point2D.Double p) |
private void |
outputCurlTemplate(java.awt.geom.Point2D.Double[] template,
double x,
double y)
Writes the curl template points to the output and applies translation (x, y).
|
private java.awt.geom.Point2D.Double[] |
removeZeroLengthSegments(java.awt.geom.Point2D.Double[] polygon) |
private void |
reversePolygon(java.awt.geom.Point2D.Double[] points) |
private static double |
sine(double dy,
double hypot) |
private void |
updateBBox(double x,
double y) |
private static final double ANGLE_180_DEG
private static final double ANGLE_90_DEG
private static final double ANGLE_34_DEG
private static final double ANGLE_30_DEG
private static final double ANGLE_12_DEG
private final PDAppearanceContentStream output
private final PDRectangle annotRect
private final double intensity
private final double lineWidth
private PDRectangle rectWithDiff
private boolean outputStarted
private double bboxMinX
private double bboxMinY
private double bboxMaxX
private double bboxMaxY
CloudyBorder(PDAppearanceContentStream stream, double intensity, double lineWidth, PDRectangle rect)
CloudyBorder
that writes to the specified
content stream.stream
- content streamintensity
- intensity of cloudy effect (entry I
); typically 1.0 or 2.0lineWidth
- line width for annotation border (entry W
)rect
- annotation rectangle (entry Rect
)void createCloudyRectangle(PDRectangle rd) throws java.io.IOException
RD
entry and the
Rect
entry that was passed in to the constructor.
This can be used for Square and FreeText annotations. However, this does not produce the text and the callout line for FreeTexts.
rd
- entry RD
, or null if the entry does not existjava.io.IOException
- If there is an error writing to the stream.void createCloudyPolygon(float[][] path) throws java.io.IOException
path
- polygon pathjava.io.IOException
- If there is an error writing to the stream.void createCloudyEllipse(PDRectangle rd) throws java.io.IOException
RD
entry and the
Rect
entry that was passed in to the constructor.rd
- entry RD
, or null if the entry does not existjava.io.IOException
- If there is an error writing to the stream.PDRectangle getBBox()
BBox
entry (bounding box) for the
appearance stream form XObject.PDRectangle getRectangle()
Rect
entry for the annotation.
The rectangle completely contains the cloudy border.Rect
.java.awt.geom.AffineTransform getMatrix()
Matrix
entry for the appearance stream form XObject.PDRectangle getRectDifference()
RD
entry for Square and Circle annotations.RD
value.private static double cosine(double dx, double hypot)
private static double sine(double dy, double hypot)
private void cloudyRectangleImpl(double left, double bottom, double right, double top, boolean isEllipse) throws java.io.IOException
java.io.IOException
private void cloudyPolygonImpl(java.awt.geom.Point2D.Double[] vertices, boolean isEllipse) throws java.io.IOException
vertices
- polygon vertices; first and last point must be equalisEllipse
- specifies if the polygon represents an ellipsejava.io.IOException
private int computeParamsPolygon(double advInterm, double advCorner, double k, double r, double length, double[] array)
private void addCornerCurl(double anglePrev, double angleCur, double radius, double cx, double cy, double alpha, double alphaPrev, boolean addMoveTo) throws java.io.IOException
java.io.IOException
private void addFirstIntermediateCurl(double angleCur, double r, double alpha, double cx, double cy) throws java.io.IOException
java.io.IOException
private java.awt.geom.Point2D.Double[] getIntermediateCurlTemplate(double angleCur, double r) throws java.io.IOException
java.io.IOException
private void outputCurlTemplate(java.awt.geom.Point2D.Double[] template, double x, double y) throws java.io.IOException
java.io.IOException
private PDRectangle applyRectDiff(PDRectangle rd, double min)
private void reversePolygon(java.awt.geom.Point2D.Double[] points)
private void getPositivePolygon(java.awt.geom.Point2D.Double[] points)
private double getPolygonDirection(java.awt.geom.Point2D.Double[] points)
private void getArc(double startAng, double endAng, double rx, double ry, double cx, double cy, java.util.ArrayList<java.awt.geom.Point2D.Double> out, boolean addMoveTo) throws java.io.IOException
java.io.IOException
private void getArcSegment(double startAng, double endAng, double cx, double cy, double rx, double ry, java.util.ArrayList<java.awt.geom.Point2D.Double> out, boolean addMoveTo) throws java.io.IOException
java.io.IOException
private static java.awt.geom.Point2D.Double[] flattenEllipse(double left, double bottom, double right, double top)
private void cloudyEllipseImpl(double leftOrig, double bottomOrig, double rightOrig, double topOrig) throws java.io.IOException
java.io.IOException
private double computeParamsEllipse(java.awt.geom.Point2D.Double pt, java.awt.geom.Point2D.Double ptNext, double r, double curlAdv)
private java.awt.geom.Point2D.Double[] removeZeroLengthSegments(java.awt.geom.Point2D.Double[] polygon)
private void drawBasicEllipse(double left, double bottom, double right, double top) throws java.io.IOException
java.io.IOException
private void beginOutput(double x, double y) throws java.io.IOException
java.io.IOException
private void updateBBox(double x, double y)
private void moveTo(java.awt.geom.Point2D.Double p) throws java.io.IOException
java.io.IOException
private void moveTo(double x, double y) throws java.io.IOException
java.io.IOException
private void lineTo(java.awt.geom.Point2D.Double p) throws java.io.IOException
java.io.IOException
private void lineTo(double x, double y) throws java.io.IOException
java.io.IOException
private void curveTo(double ax, double ay, double bx, double by, double cx, double cy) throws java.io.IOException
java.io.IOException
private void finish() throws java.io.IOException
java.io.IOException
private double getEllipseCloudRadius()
private double getPolygonCloudRadius()