You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2019/04/12 17:06:02 UTC
svn commit: r1857412 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Author: tilman
Date: Fri Apr 12 17:06:02 2019
New Revision: 1857412
URL: http://svn.apache.org/viewvc?rev=1857412&view=rev
Log:
PDFBOX-4071: split long method
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1857412&r1=1857411&r2=1857412&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java Fri Apr 12 17:06:02 2019
@@ -203,25 +203,7 @@ class AppearanceGeneratorHelper
}
else
{
- appearanceStream = new PDAppearanceStream(field.getAcroForm().getDocument());
-
- // Calculate the entries for the bounding box and the transformation matrix
- // settings for the appearance stream
- int rotation = resolveRotation(widget);
- Matrix matrix = Matrix.getRotateInstance(Math.toRadians(rotation), 0, 0);
- Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight());
-
- PDRectangle bbox = new PDRectangle(Math.abs((float) point2D.getX()), Math.abs((float) point2D.getY()));
- appearanceStream.setBBox(bbox);
-
- AffineTransform at = calculateMatrix(bbox, rotation);
- if (!at.isIdentity())
- {
- appearanceStream.setMatrix(at);
- }
- appearanceStream.setFormType(1);
-
- appearanceStream.setResources(new PDResources());
+ appearanceStream = prepareNormalAppearanceStream(widget);
appearanceDict.setNormalAppearance(appearanceStream);
// TODO support appearances other than "normal"
@@ -246,6 +228,30 @@ class AppearanceGeneratorHelper
}
}
+ private PDAppearanceStream prepareNormalAppearanceStream(PDAnnotationWidget widget)
+ {
+ PDAppearanceStream appearanceStream = new PDAppearanceStream(field.getAcroForm().getDocument());
+
+ // Calculate the entries for the bounding box and the transformation matrix
+ // settings for the appearance stream
+ int rotation = resolveRotation(widget);
+ PDRectangle rect = widget.getRectangle();
+ Matrix matrix = Matrix.getRotateInstance(Math.toRadians(rotation), 0, 0);
+ Point2D.Float point2D = matrix.transformPoint(rect.getWidth(), rect.getHeight());
+
+ PDRectangle bbox = new PDRectangle(Math.abs((float) point2D.getX()), Math.abs((float) point2D.getY()));
+ appearanceStream.setBBox(bbox);
+
+ AffineTransform at = calculateMatrix(bbox, rotation);
+ if (!at.isIdentity())
+ {
+ appearanceStream.setMatrix(at);
+ }
+ appearanceStream.setFormType(1);
+ appearanceStream.setResources(new PDResources());
+ return appearanceStream;
+ }
+
private PDDefaultAppearanceString getWidgetDefaultAppearanceString(PDAnnotationWidget widget) throws IOException
{
COSString da = (COSString) widget.getCOSObject().getDictionaryObject(COSName.DA);