pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1654339 - in /pdfbox/trunk: pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/ preflight/src/main/java/org/apache/pdfbox/preflight/annotation/
Date Fri, 23 Jan 2015 19:37:12 GMT
Author: jahewson
Date: Fri Jan 23 19:37:12 2015
New Revision: 1654339

URL: http://svn.apache.org/r1654339
Log:
PDFBOX-2629: Don't use PDGamma for colors

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/PDAnnotationLine.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationSquareCircle.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAppearanceCharacteristicsDictionary.java
    pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.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=1654339&r1=1654338&r2=1654339&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
Fri Jan 23 19:37:12 2015
@@ -17,7 +17,6 @@
 package org.apache.pdfbox.pdmodel.interactive.annotation;
 
 import java.io.IOException;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.pdfbox.cos.COSArray;
@@ -28,7 +27,8 @@ import org.apache.pdfbox.cos.COSNumber;
 import org.apache.pdfbox.pdmodel.PDPage;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
-import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 
 /**
  * A PDF annotation.
@@ -617,7 +617,7 @@ public abstract class PDAnnotation imple
     }
 
     /**
-     * This will set the colour used in drawing various elements. As of PDF 1.6 these are
: Background of icon when
+     * This will set the color used in drawing various elements. As of PDF 1.6 these are
: Background of icon when
      * closed Title bar of popup window Border of a link annotation
      * 
      * Colour is in DeviceRGB colourspace
@@ -625,13 +625,13 @@ public abstract class PDAnnotation imple
      * @param c colour in the DeviceRGB colourspace
      * 
      */
-    public void setColour(PDGamma c)
+    public void setColor(PDColor c)
     {
-        getDictionary().setItem(COSName.C, c);
+        getDictionary().setItem(COSName.C, c.toCOSArray());
     }
 
     /**
-     * This will retrieve the colour used in drawing various elements. As of PDF 1.6 these
are : Background of icon when
+     * This will retrieve the color used in drawing various elements. As of PDF 1.6 these
are : Background of icon when
      * closed Title bar of popup window Border of a link annotation
      * 
      * Colour is in DeviceRGB colourspace
@@ -639,12 +639,12 @@ public abstract class PDAnnotation imple
      * @return PDGamma object representing the colour
      * 
      */
-    public PDGamma getColour()
+    public PDColor getColor()
     {
         COSBase obj = getDictionary().getDictionaryObject(COSName.C);
         if (obj instanceof COSArray)
         {
-            return new PDGamma((COSArray) obj);
+            return new PDColor((COSArray) obj, PDDeviceRGB.INSTANCE);
         }
         else
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java?rev=1654339&r1=1654338&r2=1654339&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationLine.java
Fri Jan 23 19:37:12 2015
@@ -20,7 +20,8 @@ import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSFloat;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 
 /**
  * This is the class that represents a line annotation.
@@ -249,33 +250,29 @@ public class PDAnnotationLine extends PD
     }
 
     /**
-     * This will set interior colour of the line endings defined in the LE
-     * entry. Colour is in DeviceRGB colourspace.
-     *
-     * @param ic
-     *            colour in the DeviceRGB colourspace.
+     * This will set interior color of the line endings defined in the LE
+     * entry. color is in DeviceRGB color space.
      *
+     * @param ic color in the DeviceRGB color space.
      */
-    public void setInteriorColour( PDGamma ic )
+    public void setInteriorColor( PDColor ic )
     {
-        getDictionary().setItem( "IC", ic );
+        getDictionary().setItem( "IC", ic.toCOSArray() );
     }
 
     /**
-     * This will retrieve the interior colour of the line endings defined in the
-     * LE entry. Colour is in DeviceRGB colourspace.
-     *
-     *
-     * @return PDGamma object representing the colour.
+     * This will retrieve the interior color of the line endings defined in the
+     * LE entry. color is in DeviceRGB color space.
      *
+     * @return object representing the color.
      */
-    public PDGamma getInteriorColour()
+    public PDColor getInteriorColor()
     {
 
         COSArray ic = (COSArray) getDictionary().getDictionaryObject( "IC" );
         if (ic != null)
         {
-            return new PDGamma( ic );
+            return new PDColor( ic, PDDeviceRGB.INSTANCE );
         }
         else
         {

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationSquareCircle.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationSquareCircle.java?rev=1654339&r1=1654338&r2=1654339&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationSquareCircle.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/annotation/PDAnnotationSquareCircle.java
Fri Jan 23 19:37:12 2015
@@ -19,8 +19,9 @@ package org.apache.pdfbox.pdmodel.intera
 import org.apache.pdfbox.cos.COSArray;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSName;
-import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
 import org.apache.pdfbox.pdmodel.common.PDRectangle;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 
 /**
  * This is the class that represents a rectangular or eliptical annotation
@@ -66,34 +67,30 @@ public class PDAnnotationSquareCircle ex
 
 
     /**
-     * This will set interior colour of the drawn area
-     * Colour is in DeviceRGB colourspace.
+     * This will set interior color of the drawn area
+     * color is in DeviceRGB colo rspace.
      *
-     * @param ic
-     *            colour in the DeviceRGB colourspace.
+     * @param ic color in the DeviceRGB color space.
      *
      */
-    public void setInteriorColour( PDGamma ic )
+    public void setInteriorColor( PDColor ic )
     {
-        getDictionary().setItem( "IC", ic );
+        getDictionary().setItem( "IC", ic.toCOSArray() );
     }
 
     /**
-     * This will retrieve the interior colour of the drawn area
-     * Colour is in DeviceRGB colourspace.
-     *
-     *
-     * @return PDGamma object representing the colour.
+     * This will retrieve the interior color of the drawn area
+     * color is in DeviceRGB color space.
      *
+     * @return  object representing the color.
      */
-    public PDGamma getInteriorColour()
+    public PDColor getInteriorColor()
     {
-
         COSArray ic = (COSArray) getDictionary().getItem(
                 COSName.getPDFName( "IC" ) );
         if (ic != null)
         {
-            return new PDGamma( ic );
+            return new PDColor( ic, PDDeviceRGB.INSTANCE );
         }
         else
         {

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=1654339&r1=1654338&r2=1654339&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
Fri Jan 23 19:37:12 2015
@@ -23,7 +23,11 @@ import org.apache.pdfbox.cos.COSName;
 import org.apache.pdfbox.cos.COSStream;
 import org.apache.pdfbox.pdmodel.common.COSObjectable;
 import org.apache.pdfbox.pdmodel.common.PDStream;
-import org.apache.pdfbox.pdmodel.graphics.color.PDGamma;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColor;
+import org.apache.pdfbox.pdmodel.graphics.color.PDColorSpace;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceCMYK;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceGray;
+import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB;
 import org.apache.pdfbox.pdmodel.graphics.form.PDFormXObject;
 
 /**
@@ -91,12 +95,19 @@ public class PDAppearanceCharacteristics
      * 
      * @return the border color.
      */
-    public PDGamma getBorderColour()
+    public PDColor getBorderColour()
     {
         COSBase c = this.getDictionary().getItem(COSName.getPDFName("BC"));
         if (c instanceof COSArray)
         {
-            return new PDGamma((COSArray) c);
+            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;
     }
@@ -106,9 +117,9 @@ public class PDAppearanceCharacteristics
      * 
      * @param c the border color
      */
-    public void setBorderColour(PDGamma c)
+    public void setBorderColour(PDColor c)
     {
-        this.getDictionary().setItem("BC", c);
+        this.getDictionary().setItem("BC", c.toCOSArray());
     }
 
     /**
@@ -116,12 +127,19 @@ public class PDAppearanceCharacteristics
      * 
      * @return the background color.
      */
-    public PDGamma getBackground()
+    public PDColor getBackground()
     {
         COSBase c = this.getDictionary().getItem(COSName.getPDFName("BG"));
         if (c instanceof COSArray)
         {
-            return new PDGamma((COSArray) c);
+            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;
     }
@@ -131,9 +149,9 @@ public class PDAppearanceCharacteristics
      * 
      * @param c the background color
      */
-    public void setBackground(PDGamma c)
+    public void setBackground(PDColor c)
     {
-        this.getDictionary().setItem("BG", c);
+        this.getDictionary().setItem("BG", c.toCOSArray());
     }
 
     /**

Modified: pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java?rev=1654339&r1=1654338&r2=1654339&view=diff
==============================================================================
--- pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java
(original)
+++ pdfbox/trunk/preflight/src/main/java/org/apache/pdfbox/preflight/annotation/AnnotationValidator.java
Fri Jan 23 19:37:12 2015
@@ -21,17 +21,6 @@
 
 package org.apache.pdfbox.preflight.annotation;
 
-import static org.apache.pdfbox.preflight.PreflightConfiguration.ACTIONS_PROCESS;
-import static org.apache.pdfbox.preflight.PreflightConfiguration.GRAPHIC_PROCESS;
-import static org.apache.pdfbox.preflight.PreflightConstants.ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_FORBIDDEN_COLOR;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_FORBIDDEN_FLAG;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_INVALID_AP_CONTENT;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_INVALID_CA;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_MISSING_AP_N_CONTENT;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_MISSING_FIELDS;
-import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_DICT_INVALID;
-
 import org.apache.pdfbox.cos.COSBase;
 import org.apache.pdfbox.cos.COSDictionary;
 import org.apache.pdfbox.cos.COSDocument;
@@ -47,6 +36,18 @@ import org.apache.pdfbox.preflight.graph
 import org.apache.pdfbox.preflight.utils.COSUtils;
 import org.apache.pdfbox.preflight.utils.ContextHelper;
 
+
+import static org.apache.pdfbox.preflight.PreflightConfiguration.ACTIONS_PROCESS;
+import static org.apache.pdfbox.preflight.PreflightConfiguration.GRAPHIC_PROCESS;
+import static org.apache.pdfbox.preflight.PreflightConstants.ANNOT_DICTIONARY_VALUE_SUBTYPE_POPUP;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_FORBIDDEN_COLOR;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_FORBIDDEN_FLAG;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_INVALID_AP_CONTENT;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_INVALID_CA;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_MISSING_AP_N_CONTENT;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_ANNOT_MISSING_FIELDS;
+import static org.apache.pdfbox.preflight.PreflightConstants.ERROR_SYNTAX_DICT_INVALID;
+
 public abstract class AnnotationValidator
 {
 
@@ -129,7 +130,7 @@ public abstract class AnnotationValidato
      */
     protected boolean checkColors() throws ValidationException
     {
-        if (this.pdAnnot.getColour() != null)
+        if (this.pdAnnot.getColor() != null)
         {
             if (!searchRGBProfile())
             {



Mime
View raw message