Author: tilman
Date: Fri Feb  9 18:22:52 2018
New Revision: 1823685

URL: http://svn.apache.org/viewvc?rev=1823685&view=rev
Log:
PDFBOX-3353: don't use AnnotationBorder class for color handling

Modified:
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDHighlightAppearanceHandler.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDInkAppearanceHandler.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.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/PDStrikeoutAppearanceHandler.java
    
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDUnderlineAppearanceHandler.java

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/AnnotationBorder.java
 Fri Feb  9 18:22:52 2018
@@ -19,8 +19,6 @@ package org.apache.pdfbox.pdmodel.intera
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSNumber;
-import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
-import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDBorderStyleDictionary;
 
@@ -34,7 +32,6 @@ class AnnotationBorder
     float[] dashArray = null;
     boolean underline = false;
     float width = 0;
-    PDColor color;
 
     // return border info. BorderStyle must be provided as parameter because
     // method is not available in the base class
@@ -70,12 +67,6 @@ class AnnotationBorder
                 ab.underline = true;
             }
         }
-        ab.color = annotation.getColor();
-        if (ab.color == null)
-        {
-            // spec is unclear, but black seems to be the right thing to do
-            ab.color = new PDColor(new float[] { 0 }, PDDeviceGray.INSTANCE);
-        }
         if (ab.dashArray != null)
         {
             boolean allZero = true;

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDHighlightAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDHighlightAppearanceHandler.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDHighlightAppearanceHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDHighlightAppearanceHandler.java
 Fri Feb  9 18:22:52 2018
@@ -26,6 +26,7 @@ import org.apache.pdfbox.pdmodel.PDFormC
 import org.apache.pdfbox.pdmodel.PDResources;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.graphics.blend.BlendMode;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
@@ -64,11 +65,9 @@ public class PDHighlightAppearanceHandle
             return;
         }
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(annotation, 
annotation.getBorderStyle());
-        if (annotation.getColor() == null || ab.color.getComponents().length 
== 0)
+        PDColor color = annotation.getColor();
+        if (color == null || color.getComponents().length == 0)
         {
-            //TODO Annotation border color handling is different here than 
with shape annotations,
-            // consider this when/if refactoring AnnotationBorder class,
-            // e.g. set a parameter what to use as default.
             return;
         }
 
@@ -140,7 +139,7 @@ public class PDHighlightAppearanceHandle
                 frm2.setBBox(annotation.getRectangle());
                 try (PDFormContentStream frm2CS = new 
PDFormContentStream(frm2))
                 {
-                    frm2CS.setNonStrokingColor(ab.color);
+                    frm2CS.setNonStrokingColor(color);
                     int of = 0;
                     while (of + 7 < pathsArray.length)
                     {

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDInkAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDInkAppearanceHandler.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDInkAppearanceHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDInkAppearanceHandler.java
 Fri Feb  9 18:22:52 2018
@@ -19,6 +19,7 @@ package org.apache.pdfbox.pdmodel.intera
 import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationInk;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
@@ -50,7 +51,8 @@ public class PDInkAppearanceHandler exte
         PDAnnotationInk ink = (PDAnnotationInk) getAnnotation();
         // PDF spec does not mention /Border for ink annotations, but it is 
used if /BS is not available
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(ink, 
ink.getBorderStyle());
-        if (ab.width == 0 || ab.color.getComponents().length == 0)
+        PDColor color = ink.getColor();
+        if (color == null || color.getComponents().length == 0 || ab.width == 
0)
         {
             return;
         }
@@ -61,7 +63,7 @@ public class PDInkAppearanceHandler exte
             {
                 handleOpacity(ink.getConstantOpacity());
 
-                cs.setStrokingColor(ab.color);
+                cs.setStrokingColor(color);
                 if (ab.dashArray != null)
                 {
                     cs.setLineDashPattern(ab.dashArray, 0);

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDLineAppearanceHandler.java
 Fri Feb  9 18:22:52 2018
@@ -24,6 +24,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.pdfbox.contentstream.PDAbstractContentStream;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
 import org.apache.pdfbox.pdmodel.font.PDType1Font;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationLine;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
@@ -88,7 +89,8 @@ public class PDLineAppearanceHandler ext
             return;
         }
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(annotation, 
annotation.getBorderStyle());
-        if (ab.color.getComponents().length == 0)
+        PDColor color = annotation.getColor();
+        if (color == null || color.getComponents().length == 0)
         {
             return;
         }
@@ -142,7 +144,7 @@ public class PDLineAppearanceHandler ext
                 // empty color array results in an invisible line ("n" 
operator) but the rest is visible
                 // empty content is like no caption
 
-                boolean hasStroke = cs.setStrokingColorOnDemand(getColor());
+                boolean hasStroke = cs.setStrokingColorOnDemand(color);
 
                 if (ab.dashArray != null)
                 {

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=1823685&r1=1823684&r2=1823685&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
 Fri Feb  9 18:22:52 2018
@@ -24,6 +24,7 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPolyline;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
@@ -61,7 +62,8 @@ public class PDPolylineAppearanceHandler
             return;
         }
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(annotation, 
annotation.getBorderStyle());
-        if (ab.width == 0 || ab.color.getComponents().length == 0)
+        PDColor color = annotation.getColor();
+        if (color == null || color.getComponents().length == 0 || ab.width == 
0)
         {
             return;
         }
@@ -94,7 +96,7 @@ public class PDPolylineAppearanceHandler
             {
                 handleOpacity(annotation.getConstantOpacity());
 
-                cs.setStrokingColor(ab.color);
+                cs.setStrokingColor(color);
                 if (ab.dashArray != null)
                 {
                     cs.setLineDashPattern(ab.dashArray, 0);

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDStrikeoutAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDStrikeoutAppearanceHandler.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDStrikeoutAppearanceHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDStrikeoutAppearanceHandler.java
 Fri Feb  9 18:22:52 2018
@@ -20,6 +20,7 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationStrikeout;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
@@ -55,7 +56,8 @@ public class PDStrikeoutAppearanceHandle
             return;
         }
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(annotation, 
annotation.getBorderStyle());
-        if (ab.color.getComponents().length == 0)
+        PDColor color = annotation.getColor();
+        if (color == null || color.getComponents().length == 0)
         {
             return;
         }
@@ -93,7 +95,7 @@ public class PDStrikeoutAppearanceHandle
             {
                 handleOpacity(annotation.getConstantOpacity());
 
-                cs.setStrokingColor(ab.color);
+                cs.setStrokingColor(color);
                 if (ab.dashArray != null)
                 {
                     cs.setLineDashPattern(ab.dashArray, 0);

Modified: 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDUnderlineAppearanceHandler.java
URL: 
http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDUnderlineAppearanceHandler.java?rev=1823685&r1=1823684&r2=1823685&view=diff
==============================================================================
--- 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDUnderlineAppearanceHandler.java
 (original)
+++ 
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/handlers/PDUnderlineAppearanceHandler.java
 Fri Feb  9 18:22:52 2018
@@ -20,6 +20,7 @@ import java.io.IOException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation;
 import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationUnderline;
 import 
org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceContentStream;
@@ -55,7 +56,8 @@ public class PDUnderlineAppearanceHandle
             return;
         }
         AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(annotation, 
annotation.getBorderStyle());
-        if (ab.color.getComponents().length == 0)
+        PDColor color = annotation.getColor();
+        if (color == null || color.getComponents().length == 0)
         {
             return;
         }
@@ -94,7 +96,7 @@ public class PDUnderlineAppearanceHandle
             {
                 handleOpacity(annotation.getConstantOpacity());
 
-                cs.setStrokingColor(ab.color);
+                cs.setStrokingColor(color);
                 if (ab.dashArray != null)
                 {
                     cs.setLineDashPattern(ab.dashArray, 0);


Reply via email to