pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1839594 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/
Date Wed, 29 Aug 2018 18:26:40 GMT
Author: tilman
Date: Wed Aug 29 18:26:40 2018
New Revision: 1839594

URL: http://svn.apache.org/viewvc?rev=1839594&view=rev
Log:
PDFBOX-3353: use base type where possible for future DRY refactoring + simplify code

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDCircleAppearanceHandler.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLinkAppearanceHandler.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolylineAppearanceHandler.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDSquareAppearanceHandler.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDCircleAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDCircleAppearanceHandler.java?rev=1839594&r1=1839593&r2=1839594&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDCircleAppearanceHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDCircleAppearanceHandler.java
Wed Aug 29 18:26:40 2018
@@ -27,6 +27,7 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationCircle;
 import org.apache.pdfbox.pdmodel.PDAppearanceContentStream;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderEffectDictionary;
@@ -153,7 +154,7 @@ public class PDCircleAppearanceHandler e
     // here and removed from the individual handlers.
     float getLineWidth()
     {
-        PDAnnotationCircle annotation = (PDAnnotationCircle) getAnnotation();
+        PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
 
         PDBorderStyleDictionary bs = annotation.getBorderStyle();
 
@@ -161,16 +162,14 @@ public class PDCircleAppearanceHandler e
         {
             return bs.getWidth();
         }
-        else
+
+        COSArray borderCharacteristics = annotation.getBorder();
+        if (borderCharacteristics.size() >= 3)
         {
-            COSArray borderCharacteristics = annotation.getBorder();
-            if (borderCharacteristics.size() >= 3)
+            COSBase base = borderCharacteristics.getObject(2);
+            if (base instanceof COSNumber)
             {
-                COSBase base = borderCharacteristics.getObject(2);
-                if (base instanceof COSNumber)
-                {
-                    return ((COSNumber) base).floatValue();
-                }
+                return ((COSNumber) base).floatValue();
             }
         }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLinkAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLinkAppearanceHandler.java?rev=1839594&r1=1839593&r2=1839594&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLinkAppearanceHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLinkAppearanceHandler.java
Wed Aug 29 18:26:40 2018
@@ -185,16 +185,14 @@ public class PDLinkAppearanceHandler ext
         {
             return bs.getWidth();
         }
-        else
+
+        COSArray borderCharacteristics = annotation.getBorder();
+        if (borderCharacteristics.size() >= 3)
         {
-            COSArray borderCharacteristics = annotation.getBorder();
-            if (borderCharacteristics.size() >= 3)
+            COSBase base = borderCharacteristics.getObject(2);
+            if (base instanceof COSNumber)
             {
-                COSBase base = borderCharacteristics.getObject(2);
-                if (base instanceof COSNumber)
-                {
-                    return ((COSNumber) base).floatValue();
-                }
+                return ((COSNumber) base).floatValue();
             }
         }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java?rev=1839594&r1=1839593&r2=1839594&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolygonAppearanceHandler.java
Wed Aug 29 18:26:40 2018
@@ -28,6 +28,7 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPolygon;
 import org.apache.pdfbox.pdmodel.PDAppearanceContentStream;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderEffectDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
@@ -206,7 +207,7 @@ public class PDPolygonAppearanceHandler
     // here and removed from the individual handlers.
     float getLineWidth()
     {
-        PDAnnotationPolygon annotation = (PDAnnotationPolygon) getAnnotation();
+        PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
 
         PDBorderStyleDictionary bs = annotation.getBorderStyle();
 
@@ -214,16 +215,14 @@ public class PDPolygonAppearanceHandler
         {
             return bs.getWidth();
         }
-        else
+
+        COSArray borderCharacteristics = annotation.getBorder();
+        if (borderCharacteristics.size() >= 3)
         {
-            COSArray borderCharacteristics = annotation.getBorder();
-            if (borderCharacteristics.size() >= 3)
+            COSBase base = borderCharacteristics.getObject(2);
+            if (base instanceof COSNumber)
             {
-                COSBase base = borderCharacteristics.getObject(2);
-                if (base instanceof COSNumber)
-                {
-                    return ((COSNumber) base).floatValue();
-                }
+                return ((COSNumber) base).floatValue();
             }
         }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolylineAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolylineAppearanceHandler.java?rev=1839594&r1=1839593&r2=1839594&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolylineAppearanceHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDPolylineAppearanceHandler.java
Wed Aug 29 18:26:40 2018
@@ -29,6 +29,7 @@ import org.apache.pdfbox.pdmodel.interac
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPolyline;
 import org.apache.pdfbox.pdmodel.PDAppearanceContentStream;
 import static org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLine.LE_NONE;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
 import org.apache.pdfbox.util.Matrix;
 
@@ -238,7 +239,7 @@ public class PDPolylineAppearanceHandler
     // here and removed from the individual handlers.
     float getLineWidth()
     {
-        PDAnnotationPolyline annotation = (PDAnnotationPolyline) getAnnotation();
+        PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
 
         PDBorderStyleDictionary bs = annotation.getBorderStyle();
 
@@ -246,16 +247,14 @@ public class PDPolylineAppearanceHandler
         {
             return bs.getWidth();
         }
-        else
+
+        COSArray borderCharacteristics = annotation.getBorder();
+        if (borderCharacteristics.size() >= 3)
         {
-            COSArray borderCharacteristics = annotation.getBorder();
-            if (borderCharacteristics.size() >= 3)
+            COSBase base = borderCharacteristics.getObject(2);
+            if (base instanceof COSNumber)
             {
-                COSBase base = borderCharacteristics.getObject(2);
-                if (base instanceof COSNumber)
-                {
-                    return ((COSNumber) base).floatValue();
-                }
+                return ((COSNumber) base).floatValue();
             }
         }
 

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDSquareAppearanceHandler.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDSquareAppearanceHandler.java?rev=1839594&r1=1839593&r2=1839594&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDSquareAppearanceHandler.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDSquareAppearanceHandler.java
Wed Aug 29 18:26:40 2018
@@ -29,6 +29,7 @@ import org.apache.pdfbox.pdmodel.common.
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationSquare;
 import org.apache.pdfbox.pdmodel.PDAppearanceContentStream;
+import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderEffectDictionary;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
@@ -156,7 +157,7 @@ public class PDSquareAppearanceHandler e
     // here and removed from the individual handlers.
     float getLineWidth()
     {
-        PDAnnotationSquare annotation = (PDAnnotationSquare) getAnnotation();
+        PDAnnotationMarkup annotation = (PDAnnotationMarkup) getAnnotation();
 
         PDBorderStyleDictionary bs = annotation.getBorderStyle();
 
@@ -164,16 +165,14 @@ public class PDSquareAppearanceHandler e
         {
             return bs.getWidth();
         }
-        else
+
+        COSArray borderCharacteristics = annotation.getBorder();
+        if (borderCharacteristics.size() >= 3)
         {
-            COSArray borderCharacteristics = annotation.getBorder();
-            if (borderCharacteristics.size() >= 3)
+            COSBase base = borderCharacteristics.getObject(2);
+            if (base instanceof COSNumber)
             {
-                COSBase base = borderCharacteristics.getObject(2);
-                if (base instanceof COSNumber)
-                {
-                    return ((COSNumber) base).floatValue();
-                }
+                return ((COSNumber) base).floatValue();
             }
         }
 



Mime
View raw message