pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1857414 - /pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Date Fri, 12 Apr 2019 17:06:13 GMT
Author: tilman
Date: Fri Apr 12 17:06:12 2019
New Revision: 1857414

URL: http://svn.apache.org/viewvc?rev=1857414&view=rev
Log:
PDFBOX-4071: split long method

Modified:
    pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java

Modified: pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java?rev=1857414&r1=1857413&r2=1857414&view=diff
==============================================================================
--- pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
(original)
+++ pdfbox/branches/issue45/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/AppearanceGeneratorHelper.java
Fri Apr 12 17:06:12 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);



Mime
View raw message