pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1608176 - in /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function: PDFunction.java PDFunctionTypeIdentity.java
Date Sun, 06 Jul 2014 09:14:46 GMT
Author: tilman
Date: Sun Jul  6 09:14:45 2014
New Revision: 1608176

URL: http://svn.apache.org/r1608176
Log:
PDFBOX-2191: introduced an identity function

Added:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java
  (with props)
Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java?rev=1608176&r1=1608175&r2=1608176&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunction.java
Sun Jul  6 09:14:45 2014
@@ -129,6 +129,11 @@ public abstract class PDFunction impleme
      */
     public static PDFunction create( COSBase function ) throws IOException
     {
+        if (function == COSName.IDENTITY)
+        {
+            return new PDFunctionTypeIdentity(null);
+        }
+
         PDFunction retval = null;
         if( function instanceof COSObject )
         {
@@ -310,7 +315,7 @@ public abstract class PDFunction impleme
     protected float[] clipToRange(float[] inputValues) 
     {
         COSArray rangesArray = getRangeValues();
-        float[] result = null;
+        float[] result;
         if (rangesArray != null) 
         {
             float[] rangeValues = rangesArray.toFloatArray();
@@ -362,6 +367,7 @@ public abstract class PDFunction impleme
     /**
      * {@inheritDoc}
      */
+    @Override
     public String toString()
     {
         return "FunctionType" + getFunctionType();

Added: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java?rev=1608176&view=auto
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java
(added)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java
Sun Jul  6 09:14:45 2014
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.pdfbox.pdmodel.common.function;
+
+import java.io.IOException;
+import org.apache.pdfbox.cos.COSBase;
+
+/**
+ * The identity function.
+ *
+ * @author Tilman Hausherr
+ */
+public class PDFunctionTypeIdentity extends PDFunction
+{
+
+    public PDFunctionTypeIdentity(COSBase function)
+    {
+        super(null);
+    }
+
+    @Override
+    public int getFunctionType()
+    {
+        // shouldn't be called
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public float[] eval(float[] input) throws IOException
+    {
+        return input;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public String toString()
+    {
+        return "FunctionTypeIdentity";
+    }
+
+}

Propchange: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/function/PDFunctionTypeIdentity.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message