pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1655775 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation: PDAnnotation.java PDAppearanceCharacteristicsDictionary.java
Date Thu, 29 Jan 2015 18:08:54 GMT
Author: tilman
Date: Thu Jan 29 18:08:54 2015
New Revision: 1655775

URL: http://svn.apache.org/r1655775
Log:
PDFBOX-2576: remove double code; insert default to appease SonarQube

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java?rev=1655775&r1=1655774&r2=1655775&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotation.java
Thu Jan 29 18:08:54 2015
@@ -660,6 +660,7 @@ public abstract class PDAnnotation imple
                 case 1: colorSpace = PDDeviceGray.INSTANCE; break;
                 case 3: colorSpace = PDDeviceRGB.INSTANCE; break;
                 case 4: colorSpace = PDDeviceCMYK.INSTANCE; break;
+                default: break;
             }
             return new PDColor((COSArray) c, colorSpace);
         }

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java?rev=1655775&r1=1655774&r2=1655775&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java
Thu Jan 29 18:08:54 2015
@@ -97,19 +97,7 @@ public class PDAppearanceCharacteristics
      */
     public PDColor getBorderColour()
     {
-        COSBase c = this.getDictionary().getItem(COSName.BC);
-        if (c instanceof COSArray)
-        {
-            PDColorSpace colorSpace = null;
-            switch (((COSArray) c).size())
-            {
-                case 1: colorSpace = PDDeviceGray.INSTANCE; break;
-                case 3: colorSpace = PDDeviceRGB.INSTANCE; break;
-                case 4: colorSpace = PDDeviceCMYK.INSTANCE; break;
-            }
-            return new PDColor((COSArray) c, colorSpace);
-        }
-        return null;
+        return getColor(COSName.BC);
     }
 
     /**
@@ -129,21 +117,9 @@ public class PDAppearanceCharacteristics
      */
     public PDColor getBackground()
     {
-        COSBase c = this.getDictionary().getItem(COSName.BG);
-        if (c instanceof COSArray)
-        {
-            PDColorSpace colorSpace = null;
-            switch (((COSArray) c).size())
-            {
-                case 1: colorSpace = PDDeviceGray.INSTANCE; break;
-                case 3: colorSpace = PDDeviceRGB.INSTANCE; break;
-                case 4: colorSpace = PDDeviceCMYK.INSTANCE; break;
-            }
-            return new PDColor((COSArray) c, colorSpace);
-        }
-        return null;
+        return getColor(COSName.BG);
     }
-
+    
     /**
      * This will set the background color.
      * 
@@ -258,5 +234,23 @@ public class PDAppearanceCharacteristics
         }
         return null;
     }
+
+    private PDColor getColor(COSName itemName)
+    {
+        COSBase c = this.getDictionary().getItem(itemName);
+        if (c instanceof COSArray)
+        {
+            PDColorSpace colorSpace = null;
+            switch (((COSArray) c).size())
+            {
+                case 1: colorSpace = PDDeviceGray.INSTANCE; break;
+                case 3: colorSpace = PDDeviceRGB.INSTANCE; break;
+                case 4: colorSpace = PDDeviceCMYK.INSTANCE; break;
+                default: break;
+            }
+            return new PDColor((COSArray) c, colorSpace);
+        }
+        return null;
+    }
 
 }



Mime
View raw message