pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1635714 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Date Fri, 31 Oct 2014 07:44:05 GMT
Author: jahewson
Date: Fri Oct 31 07:44:04 2014
New Revision: 1635714

URL: http://svn.apache.org/r1635714
Log:
PDFBOX-1292: Blend modes were always null!

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java?rev=1635714&r1=1635713&r2=1635714&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/graphics/blend/BlendMode.java
Fri Oct 31 07:44:04 2014
@@ -30,28 +30,6 @@ import java.util.Map;
  */
 public abstract class BlendMode
 {
-    private static final Map<COSName, BlendMode> BLEND_MODES = createBlendModeMap();
-
-    private static Map<COSName, BlendMode> createBlendModeMap()
-    {
-        Map<COSName, BlendMode> map = new HashMap<COSName, BlendMode>();
-        map.put(COSName.NORMAL, BlendMode.NORMAL);
-        map.put(COSName.COMPATIBLE, BlendMode.COMPATIBLE);
-        map.put(COSName.MULTIPLY, BlendMode.MULTIPLY);
-        map.put(COSName.SCREEN, BlendMode.SCREEN);
-        map.put(COSName.OVERLAY, BlendMode.OVERLAY);
-        map.put(COSName.DARKEN, BlendMode.DARKEN);
-        map.put(COSName.LIGHTEN, BlendMode.LIGHTEN);
-        map.put(COSName.COLOR_DODGE, BlendMode.COLOR_DODGE);
-        map.put(COSName.COLOR_BURN, BlendMode.COLOR_BURN);
-        map.put(COSName.HARD_LIGHT, BlendMode.HARD_LIGHT);
-        map.put(COSName.SOFT_LIGHT, BlendMode.SOFT_LIGHT);
-        map.put(COSName.DIFFERENCE, BlendMode.DIFFERENCE);
-        map.put(COSName.EXCLUSION, BlendMode.EXCLUSION);
-        // TODO - non-separable blending modes
-        return map;
-    }
-
     /**
      * Determines the blend mode from the BM entry in the COS ExtGState.
      *
@@ -63,7 +41,7 @@ public abstract class BlendMode
         BlendMode result = null;
         if (cosBlendMode instanceof COSName)
         {
-            result = BLEND_MODES.get(cosBlendMode);
+            result = BLEND_MODES.get((COSName)cosBlendMode);
         }
         else if (cosBlendMode instanceof COSArray)
         {
@@ -77,6 +55,7 @@ public abstract class BlendMode
                 }
             }
         }
+
         if (result != null)
         {
             return result;
@@ -84,7 +63,7 @@ public abstract class BlendMode
         return BlendMode.COMPATIBLE;
     }
 
-    public static SeparableBlendMode NORMAL = new SeparableBlendMode()
+    public static final SeparableBlendMode NORMAL = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -92,9 +71,9 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode COMPATIBLE = NORMAL;
+    public static final SeparableBlendMode COMPATIBLE = NORMAL;
 
-    public static SeparableBlendMode MULTIPLY = new SeparableBlendMode()
+    public static final SeparableBlendMode MULTIPLY = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -102,7 +81,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode SCREEN = new SeparableBlendMode()
+    public static final SeparableBlendMode SCREEN = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -110,7 +89,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode OVERLAY = new SeparableBlendMode()
+    public static final SeparableBlendMode OVERLAY = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -119,7 +98,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode DARKEN = new SeparableBlendMode()
+    public static final SeparableBlendMode DARKEN = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -127,7 +106,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode LIGHTEN = new SeparableBlendMode()
+    public static final SeparableBlendMode LIGHTEN = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -135,7 +114,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode COLOR_DODGE = new SeparableBlendMode()
+    public static final SeparableBlendMode COLOR_DODGE = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -143,7 +122,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode COLOR_BURN = new SeparableBlendMode()
+    public static final SeparableBlendMode COLOR_BURN = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -151,7 +130,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode HARD_LIGHT = new SeparableBlendMode()
+    public static final SeparableBlendMode HARD_LIGHT = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -160,7 +139,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode SOFT_LIGHT = new SeparableBlendMode()
+    public static final SeparableBlendMode SOFT_LIGHT = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -177,7 +156,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode DIFFERENCE = new SeparableBlendMode()
+    public static final SeparableBlendMode DIFFERENCE = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -185,7 +164,7 @@ public abstract class BlendMode
         }
     };
 
-    public static SeparableBlendMode EXCLUSION = new SeparableBlendMode()
+    public static final SeparableBlendMode EXCLUSION = new SeparableBlendMode()
     {
         public float blendChannel(float srcValue, float dstValue)
         {
@@ -193,6 +172,29 @@ public abstract class BlendMode
         }
     };
 
+    // this map *must* come after the declarations above, otherwise its values will be null
+    private static final Map<COSName, BlendMode> BLEND_MODES = createBlendModeMap();
+
+    private static Map<COSName, BlendMode> createBlendModeMap()
+    {
+        Map<COSName, BlendMode> map = new HashMap<COSName, BlendMode>();
+        map.put(COSName.NORMAL, BlendMode.NORMAL);
+        map.put(COSName.COMPATIBLE, BlendMode.COMPATIBLE);
+        map.put(COSName.MULTIPLY, BlendMode.MULTIPLY);
+        map.put(COSName.SCREEN, BlendMode.SCREEN);
+        map.put(COSName.OVERLAY, BlendMode.OVERLAY);
+        map.put(COSName.DARKEN, BlendMode.DARKEN);
+        map.put(COSName.LIGHTEN, BlendMode.LIGHTEN);
+        map.put(COSName.COLOR_DODGE, BlendMode.COLOR_DODGE);
+        map.put(COSName.COLOR_BURN, BlendMode.COLOR_BURN);
+        map.put(COSName.HARD_LIGHT, BlendMode.HARD_LIGHT);
+        map.put(COSName.SOFT_LIGHT, BlendMode.SOFT_LIGHT);
+        map.put(COSName.DIFFERENCE, BlendMode.DIFFERENCE);
+        map.put(COSName.EXCLUSION, BlendMode.EXCLUSION);
+        // TODO - non-separable blending modes
+        return map;
+    }
+
     BlendMode()
     {
     }



Mime
View raw message