Class PDAbstractAppearanceHandler
- All Implemented Interfaces:
PDAppearanceHandler
- Direct Known Subclasses:
PDCaretAppearanceHandler
,PDCircleAppearanceHandler
,PDFileAttachmentAppearanceHandler
,PDFreeTextAppearanceHandler
,PDHighlightAppearanceHandler
,PDInkAppearanceHandler
,PDLineAppearanceHandler
,PDLinkAppearanceHandler
,PDPolygonAppearanceHandler
,PDPolylineAppearanceHandler
,PDSoundAppearanceHandler
,PDSquareAppearanceHandler
,PDSquigglyAppearanceHandler
,PDStrikeoutAppearanceHandler
,PDTextAppearanceHandler
,PDUnderlineAppearanceHandler
-
Field Summary
FieldsModifier and TypeFieldDescriptionLine ending styles where the shape changes its angle, e.g.private final PDAnnotation
(package private) static final double
protected PDDocument
Line ending styles where there is an interior color.Line ending styles where the line has to be drawn shorter (minus line width). -
Constructor Summary
ConstructorsConstructorDescriptionPDAbstractAppearanceHandler
(PDAnnotation annotation) PDAbstractAppearanceHandler
(PDAnnotation annotation, PDDocument document) -
Method Summary
Modifier and TypeMethodDescription(package private) PDRectangle
addRectDifferences
(PDRectangle rectangle, float[] differences) Get a rectangle enlarged by the differences.(package private) PDRectangle
applyRectDifferences
(PDRectangle rectangle, float[] differences) Get a rectangle with the differences applied to each side.protected COSStream
(package private) void
drawArrow
(PDAppearanceContentStream cs, float x, float y, float len) Add the two arms of a horizontal arrow.(package private) void
drawCircle
(PDAppearanceContentStream cs, float x, float y, float r) Add a circle shape to the path in clockwise direction.(package private) void
drawCircle2
(PDAppearanceContentStream cs, float x, float y, float r) Add a circle shape to the path in counterclockwise direction.(package private) void
drawDiamond
(PDAppearanceContentStream cs, float x, float y, float r) Add a square diamond shape (corner on top) to the path.(package private) void
drawStyle
(String style, PDAppearanceContentStream cs, float x, float y, float width, boolean hasStroke, boolean hasBackground, boolean ending) Draw a line ending style.void
(package private) PDAnnotation
(package private) PDAppearanceDictionary
Get the annotations appearance dictionary.private PDAppearanceContentStream
getAppearanceEntryAsContentStream
(PDAppearanceEntry appearanceEntry, boolean compress) (package private) PDColor
getColor()
(package private) PDAppearanceEntry
Get the annotations down appearance.private PDAppearanceEntry
Get the annotations normal appearance.(package private) PDAppearanceContentStream
Get the annotations normal appearance content stream.(package private) PDAppearanceContentStream
getNormalAppearanceAsContentStream
(boolean compress) Get the annotations normal appearance content stream.(package private) PDRectangle
getPaddedRectangle
(PDRectangle rectangle, float padding) Get a padded rectangle.(package private) PDRectangle
(package private) PDAppearanceEntry
Get the annotations rollover appearance.(package private) PDRectangle
handleBorderBox
(PDAnnotationSquareCircle annotation, float lineWidth) (package private) void
setOpacity
(PDAppearanceContentStream contentStream, float opacity) private void
setTransformationMatrix
(PDAppearanceStream appearanceStream) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.pdfbox.pdmodel.interactive.annotation.handlers.PDAppearanceHandler
generateDownAppearance, generateNormalAppearance, generateRolloverAppearance
-
Field Details
-
annotation
-
document
-
SHORT_STYLES
Line ending styles where the line has to be drawn shorter (minus line width). -
ARROW_ANGLE
static final double ARROW_ANGLE -
INTERIOR_COLOR_STYLES
Line ending styles where there is an interior color. -
ANGLED_STYLES
Line ending styles where the shape changes its angle, e.g. arrows.
-
-
Constructor Details
-
PDAbstractAppearanceHandler
-
PDAbstractAppearanceHandler
-
-
Method Details
-
generateAppearanceStreams
public void generateAppearanceStreams()- Specified by:
generateAppearanceStreams
in interfacePDAppearanceHandler
-
getAnnotation
PDAnnotation getAnnotation() -
getColor
PDColor getColor() -
getRectangle
PDRectangle getRectangle() -
createCOSStream
-
getAppearance
PDAppearanceDictionary getAppearance()Get the annotations appearance dictionary.This will get the annotations appearance dictionary. If this is not existent an empty appearance dictionary will be created.
- Returns:
- the annotations appearance dictionary
-
getNormalAppearanceAsContentStream
Get the annotations normal appearance content stream.This will get the annotations normal appearance content stream, to 'draw' to. It will be uncompressed.
- Returns:
- the appearance entry representing the normal appearance.
- Throws:
IOException
-
getNormalAppearanceAsContentStream
Get the annotations normal appearance content stream.This will get the annotations normal appearance content stream, to 'draw' to.
- Parameters:
compress
- whether the content stream is to be compressed. Set this to true when creating long content streams.- Returns:
- the appearance entry representing the normal appearance.
- Throws:
IOException
-
getDownAppearance
PDAppearanceEntry getDownAppearance()Get the annotations down appearance.This will get the annotations down appearance. If this is not existent an empty appearance entry will be created.
- Returns:
- the appearance entry representing the down appearance.
-
getRolloverAppearance
PDAppearanceEntry getRolloverAppearance()Get the annotations rollover appearance.This will get the annotations rollover appearance. If this is not existent an empty appearance entry will be created.
- Returns:
- the appearance entry representing the rollover appearance.
-
getPaddedRectangle
Get a padded rectangle.Creates a new rectangle with padding applied to each side. .
- Parameters:
rectangle
- the rectangle.padding
- the padding to apply.- Returns:
- the padded rectangle.
-
addRectDifferences
Get a rectangle enlarged by the differences.Creates a new rectangle with differences added to each side. If there are no valid differences, then the original rectangle is returned.
- Parameters:
rectangle
- the rectangle.differences
- the differences to apply.- Returns:
- the padded rectangle.
-
applyRectDifferences
Get a rectangle with the differences applied to each side.Creates a new rectangle with differences added to each side. If there are no valid differences, then the original rectangle is returned.
- Parameters:
rectangle
- the rectangle.differences
- the differences to apply.- Returns:
- the padded rectangle.
-
setOpacity
- Throws:
IOException
-
drawStyle
void drawStyle(String style, PDAppearanceContentStream cs, float x, float y, float width, boolean hasStroke, boolean hasBackground, boolean ending) throws IOException Draw a line ending style.- Parameters:
style
-cs
-x
-y
-width
-hasStroke
-hasBackground
-ending
- false if left, true if right of an imagined horizontal line (important for arrows).- Throws:
IOException
-
drawArrow
Add the two arms of a horizontal arrow.- Parameters:
cs
- Content streamx
-y
-len
- The arm length. Positive goes to the right, negative goes to the left.- Throws:
IOException
- If the content stream could not be written
-
drawDiamond
Add a square diamond shape (corner on top) to the path.- Parameters:
cs
- Content streamx
-y
-r
- Radius (to a corner)- Throws:
IOException
- If the content stream could not be written
-
drawCircle
Add a circle shape to the path in clockwise direction.- Parameters:
cs
- Content streamx
-y
-r
- Radius- Throws:
IOException
- If the content stream could not be written.
-
drawCircle2
Add a circle shape to the path in counterclockwise direction. You'll need this e.g. when drawing a doughnut shape. See "Nonzero Winding Number Rule" for more information.- Parameters:
cs
- Content streamx
-y
-r
- Radius- Throws:
IOException
- If the content stream could not be written.
-
createShortStyles
-
createInteriorColorStyles
-
createAngledStyles
-
getNormalAppearance
Get the annotations normal appearance.This will get the annotations normal appearance. If this is not existent an empty appearance entry will be created.
- Returns:
- the appearance entry representing the normal appearance.
-
getAppearanceEntryAsContentStream
private PDAppearanceContentStream getAppearanceEntryAsContentStream(PDAppearanceEntry appearanceEntry, boolean compress) throws IOException - Throws:
IOException
-
setTransformationMatrix
-
handleBorderBox
-